Steve Piercy
2016-11-28 7dd4214cccdc417d78a78391cf387ff62489beb0
use argparse and autoprogram for ptweens
2 files modified
20 ■■■■■ changed files
docs/pscripts/ptweens.rst 8 ●●●● patch | view | raw | blame | history
pyramid/scripts/ptweens.py 12 ●●●●● patch | view | raw | blame | history
docs/pscripts/ptweens.rst
@@ -3,11 +3,7 @@
.. _ptweens_script:
``ptweens``
-----------
.. program-output:: ptweens --help
   :prompt:
   :shell:
.. autoprogram:: pyramid.scripts.ptweens:PTweensCommand.parser
    :prog: ptweens
.. seealso:: :ref:`displaying_tweens`
pyramid/scripts/ptweens.py
@@ -1,4 +1,4 @@
import optparse
import argparse
import sys
import textwrap
@@ -14,7 +14,6 @@
    return command.run()
class PTweensCommand(object):
    usage = '%prog config_uri'
    description = """\
    Print all implicit and explicit tween objects used by a Pyramid
    application.  The handler output includes whether the system is using an
@@ -28,17 +27,20 @@
    will be assumed.  Example: "ptweens myapp.ini#main".
    """
    parser = optparse.OptionParser(
        usage,
    parser = argparse.ArgumentParser(
        usage="%(prog)s config_uri",
        description=textwrap.dedent(description),
        )
    parser.add_argument('config_uri',
                        help='The URI to the configuration file.')
    stdout = sys.stdout
    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 _get_tweens(self, registry):
        from pyramid.config import Configurator