From: Mike Frysinger Date: Wed, 4 Apr 2012 18:07:59 +0000 (-0400) Subject: equery: turn sys.argv into a parameter X-Git-Tag: gentoolkit-0.3.0.6~4 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=d3d353c5d9de561d72900c757c49671febe824ea;p=gentoolkit.git 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 --- 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)