Steve Piercy
2016-11-28 812bc62a37205353de1d1719b82718dd0699bf1a
use argparse and autoprogram for ptviews
2 files modified
20 ■■■■■ changed files
docs/pscripts/pviews.rst 8 ●●●● patch | view | raw | blame | history
pyramid/scripts/pviews.py 12 ●●●●● patch | view | raw | blame | history
docs/pscripts/pviews.rst
@@ -3,11 +3,7 @@
.. _pviews_script:
``pviews``
----------
.. program-output:: pviews --help
   :prompt:
   :shell:
.. autoprogram:: pyramid.scripts.pviews:PViewsCommand.parser
    :prog: pviews
.. seealso:: :ref:`displaying_matching_views`
pyramid/scripts/pviews.py
@@ -1,4 +1,4 @@
import optparse
import argparse
import sys
import textwrap
@@ -13,7 +13,6 @@
    return command.run()
class PViewsCommand(object):
    usage = '%prog config_uri url'
    description = """\
    Print, for a given URL, the views that might match. Underneath each
    potentially matching route, list the predicates required. Underneath
@@ -28,16 +27,19 @@
    """
    stdout = sys.stdout
    parser = optparse.OptionParser(
        usage,
    parser = argparse.ArgumentParser(
        usage="%(prog)s config_uri url",
        description=textwrap.dedent(description)
        )
    parser.add_argument('config_uri',
                        help='The URI to the configuration file.')
    bootstrap = (bootstrap,) # testing
    def __init__(self, argv, quiet=False):
        self.quiet = quiet
        self.options, self.args = self.parser.parse_args(argv[1:])
        self.args = self.parser.parse_args(argv[1:])
    def out(self, msg): # pragma: no cover
        if not self.quiet: