~ubuntu-branches/ubuntu/wily/python-argh/wily

« back to all changes in this revision

Viewing changes to argh/assembling.py

  • Committer: Package Import Robot
  • Author(s): Marco Nenciarini
  • Date: 2014-10-09 03:27:42 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20141009032742-6l1dziugjqfx5z6k
Tags: 0.25.0-1
ImportedĀ UpstreamĀ versionĀ 0.25.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from argh.constants import (ATTR_ALIASES, ATTR_ARGS, ATTR_NAME,
23
23
                            ATTR_INFER_ARGS_FROM_SIGNATURE,
24
24
                            ATTR_EXPECTS_NAMESPACE_OBJECT,
25
 
                            PARSER_FORMATTER)
 
25
                            PARSER_FORMATTER, DEFAULT_ARGUMENT_TEMPLATE)
26
26
from argh.utils import get_subparsers, get_arg_spec
27
27
from argh.exceptions import AssemblingError
28
28
 
42
42
 
43
43
 
44
44
SUPPORTS_ALIASES = _check_support_aliases()
45
 
""" Calculated on load. If `True`, current version of argparse supports
 
45
"""
 
46
Calculated on load. If `True`, current version of argparse supports
46
47
alternative command names (can be set via :func:`~argh.decorators.aliases`).
47
48
"""
48
49
 
196
197
 
197
198
 
198
199
def set_default_command(parser, function):
199
 
    """ Sets default command (i.e. a function) for given parser.
 
200
    """
 
201
    Sets default command (i.e. a function) for given parser.
200
202
 
201
203
    If `parser.description` is empty and the function has a docstring,
202
204
    it is used as the description.
309
311
 
310
312
    for draft in command_args:
311
313
        draft = draft.copy()
 
314
        if 'help' not in draft:
 
315
            draft.update(help=DEFAULT_ARGUMENT_TEMPLATE)
312
316
        dest_or_opt_strings = draft.pop('option_strings')
313
317
        if parser.add_help and '-h' in dest_or_opt_strings:
314
318
            dest_or_opt_strings = [x for x in dest_or_opt_strings if x != '-h']
328
332
 
329
333
def add_commands(parser, functions, namespace=None, title=None,
330
334
                 description=None, help=None):
331
 
    """Adds given functions as commands to given parser.
 
335
    """
 
336
    Adds given functions as commands to given parser.
332
337
 
333
338
    :param parser:
334
339