| |
- __builtin__.object
-
- FileType
- HelpFormatter
-
- ArgumentDefaultsHelpFormatter
- RawDescriptionHelpFormatter
-
- RawTextHelpFormatter
- _ActionsContainer(__builtin__.object)
-
- ArgumentParser(_AttributeHolder, _ActionsContainer)
- _AttributeHolder(__builtin__.object)
-
- Action
- ArgumentParser(_AttributeHolder, _ActionsContainer)
- Namespace
- exceptions.Exception(exceptions.BaseException)
-
- ArgumentError
- ArgumentTypeError
class Action(_AttributeHolder) |
|
Information about how to convert command line strings to Python objects.
Action objects are used by an ArgumentParser to represent the information
needed to parse a single argument from one or more strings from the
command line. The keyword arguments to the Action constructor are also
all attributes of Action instances.
Keyword Arguments:
- option_strings -- A list of command-line option strings which
should be associated with this action.
- dest -- The name of the attribute to hold the created object(s)
- nargs -- The number of command-line arguments that should be
consumed. By default, one argument will be consumed and a single
value will be produced. Other values include:
- N (an integer) consumes N arguments (and produces a list)
- '?' consumes zero or one arguments
- '*' consumes zero or more arguments (and produces a list)
- '+' consumes one or more arguments (and produces a list)
Note that the difference between the default and nargs=1 is that
with the default, a single value will be produced, while with
nargs=1, a list containing a single value will be produced.
- const -- The value to be produced if the option is specified and the
option uses an action that takes no values.
- default -- The value to be produced if the option is not specified.
- type -- The type which the command-line arguments should be converted
to, should be one of 'string', 'int', 'float', 'complex' or a
callable object that accepts a single string argument. If None,
'string' is assumed.
- choices -- A container of values that should be allowed. If not None,
after a command-line argument has been converted to the appropriate
type, an exception will be raised if it is not a member of this
collection.
- required -- True if the action must always be specified at the
command line. This is only meaningful for optional command-line
arguments.
- help -- The help string describing the argument.
- metavar -- The name to be used for the option's argument with the
help string. If None, the 'dest' value will be used as the name. |
|
- Method resolution order:
- Action
- _AttributeHolder
- __builtin__.object
Methods defined here:
- __call__(self, parser, namespace, values, option_string=None)
- __init__(self, option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)
Methods inherited from _AttributeHolder:
- __repr__(self)
Data descriptors inherited from _AttributeHolder:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ArgumentDefaultsHelpFormatter(HelpFormatter) |
|
Help message formatter which adds default values to argument help.
Only the name of this class is considered a public API. All the methods
provided by the class are considered an implementation detail. |
|
- Method resolution order:
- ArgumentDefaultsHelpFormatter
- HelpFormatter
- __builtin__.object
Methods inherited from HelpFormatter:
- __init__(self, prog, indent_increment=2, max_help_position=24, width=None)
- add_argument(self, action)
- add_arguments(self, actions)
- add_text(self, text)
- add_usage(self, usage, actions, groups, prefix=None)
- end_section(self)
- format_help(self)
- # =======================
# Help-formatting methods
# =======================
- start_section(self, heading)
- # ========================
# Message building methods
# ========================
Data descriptors inherited from HelpFormatter:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class ArgumentParser(_AttributeHolder, _ActionsContainer) |
|
Object for parsing command line strings into Python objects.
Keyword Arguments:
- prog -- The name of the program (default: sys.argv[0])
- usage -- A usage message (default: auto-generated from arguments)
- description -- A description of what the program does
- epilog -- Text following the argument descriptions
- parents -- Parsers whose arguments should be copied into this one
- formatter_class -- HelpFormatter class for printing help messages
- prefix_chars -- Characters that prefix optional arguments
- fromfile_prefix_chars -- Characters that prefix files containing
additional arguments
- argument_default -- The default value for all arguments
- conflict_handler -- String indicating how to handle conflicts
- add_help -- Add a -h/-help option |
|
- Method resolution order:
- ArgumentParser
- _AttributeHolder
- _ActionsContainer
- __builtin__.object
Methods defined here:
- __init__(self, prog=None, usage=None, description=None, epilog=None, version=None, parents=[], formatter_class=<class 'argparse.HelpFormatter'>, prefix_chars='-', fromfile_prefix_chars=None, argument_default=None, conflict_handler='error', add_help=True)
- add_subparsers(self, **kwargs)
- # ==================================
# Optional/Positional adding methods
# ==================================
- convert_arg_line_to_args(self, arg_line)
- error(self, message)
- error(message: string)
Prints a usage message incorporating the message to stderr and
exits.
If you override this in a subclass, it should not return -- it
should either exit or raise an exception.
- exit(self, status=0, message=None)
- # ===============
# Exiting methods
# ===============
- format_help(self)
- format_usage(self)
- # =======================
# Help-formatting methods
# =======================
- format_version(self)
- parse_args(self, args=None, namespace=None)
- # =====================================
# Command line argument parsing methods
# =====================================
- parse_known_args(self, args=None, namespace=None)
- print_help(self, file=None)
- print_usage(self, file=None)
- # =====================
# Help-printing methods
# =====================
- print_version(self, file=None)
Methods inherited from _AttributeHolder:
- __repr__(self)
Data descriptors inherited from _AttributeHolder:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
Methods inherited from _ActionsContainer:
- add_argument(self, *args, **kwargs)
- add_argument(dest, ..., name=value, ...)
add_argument(option_string, option_string, ..., name=value, ...)
- add_argument_group(self, *args, **kwargs)
- add_mutually_exclusive_group(self, **kwargs)
- get_default(self, dest)
- register(self, registry_name, value, object)
- # ====================
# Registration methods
# ====================
- set_defaults(self, **kwargs)
- # ==================================
# Namespace default accessor methods
# ==================================
|
class FileType(__builtin__.object) |
|
Factory for creating file object types
Instances of FileType are typically passed as type= arguments to the
ArgumentParser add_argument() method.
Keyword Arguments:
- mode -- A string indicating how the file is to be opened. Accepts the
same values as the builtin open() function.
- bufsize -- The file's desired buffer size. Accepts the same values as
the builtin open() function. |
|
Methods defined here:
- __call__(self, string)
- __init__(self, mode='r', bufsize=None)
- __repr__(self)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class HelpFormatter(__builtin__.object) |
|
Formatter for generating usage messages and argument help strings.
Only the name of this class is considered a public API. All the methods
provided by the class are considered an implementation detail. |
|
Methods defined here:
- __init__(self, prog, indent_increment=2, max_help_position=24, width=None)
- add_argument(self, action)
- add_arguments(self, actions)
- add_text(self, text)
- add_usage(self, usage, actions, groups, prefix=None)
- end_section(self)
- format_help(self)
- # =======================
# Help-formatting methods
# =======================
- start_section(self, heading)
- # ========================
# Message building methods
# ========================
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RawDescriptionHelpFormatter(HelpFormatter) |
|
Help message formatter which retains any formatting in descriptions.
Only the name of this class is considered a public API. All the methods
provided by the class are considered an implementation detail. |
|
- Method resolution order:
- RawDescriptionHelpFormatter
- HelpFormatter
- __builtin__.object
Methods inherited from HelpFormatter:
- __init__(self, prog, indent_increment=2, max_help_position=24, width=None)
- add_argument(self, action)
- add_arguments(self, actions)
- add_text(self, text)
- add_usage(self, usage, actions, groups, prefix=None)
- end_section(self)
- format_help(self)
- # =======================
# Help-formatting methods
# =======================
- start_section(self, heading)
- # ========================
# Message building methods
# ========================
Data descriptors inherited from HelpFormatter:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|
class RawTextHelpFormatter(RawDescriptionHelpFormatter) |
|
Help message formatter which retains formatting of all help text.
Only the name of this class is considered a public API. All the methods
provided by the class are considered an implementation detail. |
|
- Method resolution order:
- RawTextHelpFormatter
- RawDescriptionHelpFormatter
- HelpFormatter
- __builtin__.object
Methods inherited from HelpFormatter:
- __init__(self, prog, indent_increment=2, max_help_position=24, width=None)
- add_argument(self, action)
- add_arguments(self, actions)
- add_text(self, text)
- add_usage(self, usage, actions, groups, prefix=None)
- end_section(self)
- format_help(self)
- # =======================
# Help-formatting methods
# =======================
- start_section(self, heading)
- # ========================
# Message building methods
# ========================
Data descriptors inherited from HelpFormatter:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
| |