From d3d353c5d9de561d72900c757c49671febe824ea Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 4 Apr 2012 14:07:59 -0400 Subject: [PATCH] equery: turn sys.argv into a parameter This lets other tools import equery and call the main func with its own set of flags. Signed-off-by: Mike Frysinger Signed-off-by: Paul Varner --- bin/equery | 2 +- pym/gentoolkit/equery/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/equery b/bin/equery index 343f92d..35e9d7d 100755 --- a/bin/equery +++ b/bin/equery @@ -35,7 +35,7 @@ except KeyboardInterrupt: from gentoolkit import equery, errors try: - equery.main() + equery.main(sys.argv) except errors.GentoolkitNonZeroExit as err: sys.exit(err.return_code) except errors.GentoolkitException as err: diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py index 9e8834b..a73ef1b 100644 --- a/pym/gentoolkit/equery/__init__.py +++ b/pym/gentoolkit/equery/__init__.py @@ -305,7 +305,7 @@ def split_arguments(args): return args.pop(0), args -def main(): +def main(argv): """Parse input and run the program.""" short_opts = "hqCNV" @@ -316,7 +316,7 @@ def main(): initialize_configuration() try: - global_opts, args = getopt(sys.argv[1:], short_opts, long_opts) + global_opts, args = getopt(argv[1:], short_opts, long_opts) except GetoptError as err: sys.stderr.write(pp.error("Global %s" % err)) print_help(with_description=False) @@ -359,4 +359,4 @@ def main(): raise if __name__ == '__main__': - main() + main(sys.argv) -- 2.26.2