Skip to content

Commit

Permalink
Merge pull request #488 from goelakash/display
Browse files Browse the repository at this point in the history
Verbose mode for dataset display using 'retriever ls'
  • Loading branch information
henrykironde committed May 15, 2016
2 parents 8078092 + acaa707 commit 95d9274
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
40 changes: 31 additions & 9 deletions __main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def main():
return

if args.command == 'ls' or args.dataset is None:
import lscolumns

# If scripts have never been downloaded there is nothing to list
if not script_list:
Expand All @@ -97,14 +96,37 @@ def main():
print "\n\nScripts downloaded.\n"
script_list = SCRIPT_LIST()

all_scripts = set([script.shortname for script in script_list])
all_tags = set(["ALL"] +
[tag.strip().upper() for script in script_list for tagset in script.tags for tag in tagset.split('>')])

print "Available datasets : {}".format(len(all_scripts))
lscolumns.printls(sorted(list(all_scripts), key=lambda s: s.lower()))
print "Groups:"
lscolumns.printls(sorted(list(all_tags)))
all_scripts = []

for script in script_list:
if script.name:
if args.l!=None:
script_name = script.name + "\nShortname: " + script.shortname+"\n"
if script.tags:
script_name += "Tags: "+str([tag for tag in script.tags])+"\n"
not_found = 0
for term in args.l:
if script_name.lower().find(term.lower()) == -1:
not_found = 1
break
if not_found == 0:
all_scripts.append(script_name)
else:
script_name = script.shortname
all_scripts.append(script_name)

all_scripts = sorted(all_scripts, key=lambda s: s.lower())

print "Available datasets : {}\n".format(len(all_scripts))

if args.l==None:
import lscolumns
lscolumns.printls(sorted(all_scripts, key=lambda s: s.lower()))
else:
count = 1
for script in all_scripts:
print ("%d. %s"%(count, script))
count += 1
return

engine = choose_engine(args.__dict__)
Expand Down
2 changes: 1 addition & 1 deletion lib/get_opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
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)

ls_parser.add_argument('-l', help='verbose list of datasets containing following keywords (lists all when no keywords are specified)', nargs='*')
# retriever Install {Engine} ..
# retriever download [options]
install_subparsers = install_parser.add_subparsers(help='engine-specific help', dest='engine')
Expand Down

0 comments on commit 95d9274

Please sign in to comment.