From 219429ddb3f3355509c0ee3d782d5e6386a38c2b Mon Sep 17 00:00:00 2001 From: Luiz Irber Date: Wed, 8 Jan 2020 04:50:35 +0000 Subject: [PATCH] print citation only once --- sourmash/cli/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sourmash/cli/__init__.py b/sourmash/cli/__init__.py index 7080c00549..d7cfe04d14 100644 --- a/sourmash/cli/__init__.py +++ b/sourmash/cli/__init__.py @@ -38,18 +38,20 @@ class SourmashParser(ArgumentParser): + _citation_printed = False + def __init__(self, citation=True, **kwargs): super(SourmashParser, self).__init__(**kwargs) self.citation = citation - self._citation_printed = False - def print_citation(self): - if self._citation_printed: + @classmethod + def print_citation(cls): + if cls._citation_printed: return from sourmash.logging import notify notify("\n== This is sourmash version {version}. ==", version=sourmash.VERSION) notify("== Please cite Brown and Irber (2016), doi:10.21105/joss.00027. ==\n") - self._citation_printed = True + cls._citation_printed = True def _subparser_from_name(self, name): """Given a name, get the subparser instance registered with this parser.""" @@ -63,8 +65,8 @@ def _subparser_from_name(self, name): return action.choices[name] def print_help(self): - super(SourmashParser, self).print_help() self.print_citation() + super(SourmashParser, self).print_help() def parse_args(self, args=None, namespace=None):