From 13364682e96b4f3ed5fdef4a958ac7748bc9c12a Mon Sep 17 00:00:00 2001 From: Manuel Gunther <siebenkopf@googlemail.com> Date: Mon, 12 Oct 2015 15:27:43 -0600 Subject: [PATCH] Fixed resource listing to sort resources by package; added option to print dummy tools --- bob/bio/base/script/resources.py | 17 ++++++++++++----- bob/bio/base/utils/resources.py | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/bob/bio/base/script/resources.py b/bob/bio/base/script/resources.py index 8d4ea581..3ede22ed 100644 --- a/bob/bio/base/script/resources.py +++ b/bob/bio/base/script/resources.py @@ -13,27 +13,34 @@ def resources(): default = ('d', 'p', 'e', 'a', 'g'), help = "Select the resource types that should be listed.") + parser.add_argument("--no-strip-dummy", '-s', action = 'store_true', + help = "If given, the dummy elements (usually used for testing purposes only) are **not** removed from the list.") + args = parser.parse_args() + kwargs = {} + if args.no_strip_dummy: + kwargs['strip'] = [] + if 'd' in args.details or 'database' in args.details: print ("\nList of registered databases:") - print (bob.bio.base.list_resources('database')) + print (bob.bio.base.list_resources('database', **kwargs)) if 'p' in args.details or 'preprocessor' in args.details: print ("\nList of registered preprocessors:") - print (bob.bio.base.list_resources('preprocessor')) + print (bob.bio.base.list_resources('preprocessor', **kwargs)) if 'e' in args.details or 'extractor' in args.details: print ("\nList of registered extractors:") - print (bob.bio.base.list_resources('extractor')) + print (bob.bio.base.list_resources('extractor', **kwargs)) if 'a' in args.details or 'algorithm' in args.details: print ("\nList of registered algorithms:") - print (bob.bio.base.list_resources('algorithm')) + print (bob.bio.base.list_resources('algorithm', **kwargs)) if 'g' in args.details or 'grid' in args.details: print ("\nList of registered grid configurations:") - print (bob.bio.base.list_resources('grid')) + print (bob.bio.base.list_resources('grid', **kwargs)) print() diff --git a/bob/bio/base/utils/resources.py b/bob/bio/base/utils/resources.py index 46f80390..693fdd59 100644 --- a/bob/bio/base/utils/resources.py +++ b/bob/bio/base/utils/resources.py @@ -190,7 +190,7 @@ def list_resources(keyword, strip=['dummy']): retval = "" length = max(len(entry_point.name) for entry_point in entry_points) if entry_points else 1 - for entry_point in sorted(entry_points): + for entry_point in sorted(entry_points, key=lambda p: p.dist.project_name): if last_dist != str(entry_point.dist): retval += "\n- %s: \n" % str(entry_point.dist) last_dist = str(entry_point.dist) -- GitLab