From 6e45dc6c55a67ba206efb29ab991b59f8fb4a932 Mon Sep 17 00:00:00 2001 From: henrykironde Date: Thu, 26 Jan 2017 15:27:55 -0500 Subject: [PATCH 1/3] Change download parser to require atleast one argument 1.Add prog name for argparse in lib/get_opts 2.Remove `nargs='?', default=None` so that we have just the default Hence expecting one argument, Any use of nargs will return a list which is not needed in this case --- lib/get_opts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/get_opts.py b/lib/get_opts.py index e64ed5e9e..4f659a8d8 100644 --- a/lib/get_opts.py +++ b/lib/get_opts.py @@ -3,7 +3,7 @@ from retriever.engines import engine_list -parser = argparse.ArgumentParser() +parser = argparse.ArgumentParser(prog="retriever") parser.add_argument('-v', '--version', action='version', version=VERSION) parser.add_argument('-q', '--quiet', help='suppress command-line output', action='store_true') @@ -37,7 +37,7 @@ reset_parser.add_argument('scope', help='things to reset: all, scripts, data, or connections', choices=['all', 'scripts', 'data', 'connections']) install_parser.add_argument('--compile', help='force re-compile of script before downloading', action='store_true') install_parser.add_argument('--debug', help='run in debug mode', action='store_true') -download_parser.add_argument('dataset', help='dataset name', nargs='?', default=None) +download_parser.add_argument('dataset', help='dataset name') ls_parser.add_argument('-l', help='verbose list of datasets containing following keywords (lists all when no keywords are specified)', nargs='*') delete_json_parser.add_argument('dataset', help='dataset name') # retriever Install {Engine} .. From 7e1684020fc0bc3d1aafebf47b540d27a837eb05 Mon Sep 17 00:00:00 2001 From: henrykironde Date: Thu, 26 Jan 2017 16:09:01 -0500 Subject: [PATCH 2/3] Add citation as a string in the source The CITATION file is not installed properly in the right location Using a string for citation is a better reliable method --- __init__.py | 16 ++++++++++++++++ __main__.py | 6 ++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/__init__.py b/__init__.py index 5b5836ede..ef77ea2c0 100644 --- a/__init__.py +++ b/__init__.py @@ -210,3 +210,19 @@ def set_proxy(): } } """ +CITATION = """Morris, B.D. and E.P. White. 2013. The EcoData Retriever: improving access to +existing ecological data. PLOS ONE 8:e65848. +http://doi.org/doi:10.1371/journal.pone.0065848 + +@article{morris2013ecodata, + title={The EcoData Retriever: Improving Access to Existing Ecological Data}, + author={Morris, Benjamin D and White, Ethan P}, + journal={PLOS One}, + volume={8}, + number={6}, + pages={e65848}, + year={2013}, + publisher={Public Library of Science} + doi={10.1371/journal.pone.0065848} +} +""" diff --git a/__main__.py b/__main__.py index d588b9771..8008133bc 100644 --- a/__main__.py +++ b/__main__.py @@ -20,7 +20,7 @@ # set default encoding to latin-1 to decode source text sys.setdefaultencoding('latin-1') -from retriever import VERSION, SCRIPT_LIST, HOME_DIR, sample_script, current_platform +from retriever import VERSION, SCRIPT_LIST, HOME_DIR, sample_script, CITATION from retriever.engines import engine_list from retriever.lib.repository import check_for_updates from retriever.lib.tools import choose_engine, name_matches, reset_retriever @@ -57,10 +57,8 @@ def main(): elif args.command == 'citation': if args.dataset is None: - citation_path = os.path.join(os.path.split(__file__)[0], '../CITATION') print("\nCitation for retriever:\n") - with open(citation_path) as citation_file: - print(citation_file.read()) + print(CITATION) else: scripts = name_matches(script_list, args.dataset) for dataset in scripts: From 3442b05969e55b2c68578d7e0c4768eb642699ef Mon Sep 17 00:00:00 2001 From: henrykironde Date: Thu, 26 Jan 2017 16:27:05 -0500 Subject: [PATCH 3/3] Retriever install -h repair Make sure the dataset is by default required as a sinlge string not list (remove nargs='?', default=None) On Python3 `retriever install` allows engine to be None. On the contrary, python2 does capture this case as an error and prints out the associated help Adding a check `args.command == "install" and not args.engine` enables python3 to manually get help using `retriever install -h` --- __main__.py | 3 +++ lib/get_opts.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/__main__.py b/__main__.py index 8008133bc..a98b46029 100644 --- a/__main__.py +++ b/__main__.py @@ -41,6 +41,9 @@ def main(): args = parser.parse_args() + if args.command == "install" and not args.engine: + parser.parse_args(['install','-h']) + if args.quiet: sys.stdout = open(os.devnull, 'w') diff --git a/lib/get_opts.py b/lib/get_opts.py index 4f659a8d8..da006589f 100644 --- a/lib/get_opts.py +++ b/lib/get_opts.py @@ -49,7 +49,7 @@ pass else: engine_parser = install_subparsers.add_parser(engine.abbreviation, help=engine.name) - engine_parser.add_argument('dataset', help='dataset name', nargs='?', default=None) + engine_parser.add_argument('dataset', help='dataset name') abbreviations = set('h')