Skip to content

Commit

Permalink
Merge pull request #780 from henrykironde/opts
Browse files Browse the repository at this point in the history
Change download parser to require atleast one argument
  • Loading branch information
ethanwhite committed Jan 26, 2017
2 parents 5dede87 + 3442b05 commit f12d89f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
16 changes: 16 additions & 0 deletions __init__.py
Expand Up @@ -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}
}
"""
9 changes: 5 additions & 4 deletions __main__.py
Expand Up @@ -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
Expand All @@ -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')

Expand All @@ -57,10 +60,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:
Expand Down
6 changes: 3 additions & 3 deletions lib/get_opts.py
Expand Up @@ -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')

Expand Down Expand Up @@ -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} ..
Expand All @@ -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')

Expand Down

0 comments on commit f12d89f

Please sign in to comment.