From 0c208dd7bf66a41a056514025fa42be8fc428513 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Sun, 27 Nov 2016 22:13:03 -0800 Subject: move parser outside of main into own function get_parser(), and call it from pdistreport.rst --- docs/pscripts/pdistreport.rst | 2 +- pyramid/scripts/pdistreport.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docs/pscripts/pdistreport.rst b/docs/pscripts/pdistreport.rst index 8eebaf8cb..f88ea7fe1 100644 --- a/docs/pscripts/pdistreport.rst +++ b/docs/pscripts/pdistreport.rst @@ -6,7 +6,7 @@ ``pdistreport`` --------------- -.. autoprogram:: pyramid.scripts.pdistreport:parser +.. autoprogram:: pyramid.scripts.pdistreport:get_parser() :prog: pdistreport .. seealso:: :ref:`showing_distributions` diff --git a/pyramid/scripts/pdistreport.py b/pyramid/scripts/pdistreport.py index 64837a36c..6622b4bd8 100644 --- a/pyramid/scripts/pdistreport.py +++ b/pyramid/scripts/pdistreport.py @@ -10,12 +10,16 @@ def out(*args): # pragma: no cover sys.stdout.write(' ') sys.stdout.write('\n') +def get_parser(): + _parser = argparse.ArgumentParser( + usage="%(prog)s", + description="Show Python distribution versions and locations in use") + return _parser + def main(argv=sys.argv, pkg_resources=pkg_resources, platform=platform.platform, out=out): # all args except argv are for unit testing purposes only - parser = argparse.ArgumentParser( - usage="%(prog)s", - description="Show Python distribution versions and locations in use") + parser = get_parser() parser.parse_args(argv[1:]) packages = [] for distribution in pkg_resources.working_set: -- cgit v1.2.3