This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

argparse settings with miniconfig

code

from miniconfig_argparse import get_configurator


config = get_configurator()
config.include("yourmodule")
config.include("yourmodule.extra")

args = config.make_args()
# using args

in yourmodule, using config like a below.

def includeme(config):
    parser = config.parser

    parser.add_argument(
        '-v', '--verbose', action='count', default=0,
        help="(default option: increment logging level(default is WARNING))"
    )
    parser.add_argument(
        '-q', '--quiet', action='count', default=0,
        help="(default option: decrement logging level(default is WARNING))"
    )

    def setup_closure(args):
        logging_level = logging.WARN + 10 * args.quiet - 10 * args.verbose
        logging.basicConfig(level=logging_level)
        return args

    parser.add_callback(setup_closure)

default directives

  • make_parser
  • replace_parser
  • call_function_as_command

make_parser(fn) + call_function_as_command

Using make_parser() and call_function_as_command() combinations are useful, sometimes.

  • make_parser(fn) – creating parser from a function definition.
  • call_function_as_command – call function using parsed argument object.

Such as below.

def greeting(message, is_surprised=False, name="foo"):
    """ greeting message

    :param message: message of greeting
    :param is_surprised: surprised or not (default=False)
    :param name: name of actor
    """
    suffix = "!" if is_surprised else ""
    print("{name}: {message}{suffix}".format(name=name, message=message, suffix=suffix))


def includeme(config):
    parser = config.make_parser(greeting)
    config.replace_parser(parser)


if __name__ == "__main__":
    from miniconfig_argparse import get_configurator
    config = get_configurator()
    config.include(includeme)

    args = config.make_args()
    config.call_function_as_command(greeting, args)
Release History

Release History

0.0.4

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.3

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.0.0

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
miniconfig-argparse-0.0.4.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256 Source Jan 10, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting