| | |
- FancyGetopt
- OptionDummy
class FancyGetopt |
| |
Wrapper around the standard 'getopt()' module that provides some
handy extra functionality:
* short and long options are tied together
* options have help strings, and help text can be assembled
from them
* options set attributes of a passed-in object
* boolean options can have "negative aliases" -- eg. if
--quiet is the "negative alias" of --verbose, then "--quiet"
on the command line sets 'verbose' to false |
| |
Methods defined here:
- __init__(self, option_table=None)
- _build_index(self)
- _check_alias_dict(self, aliases, what)
- _grok_option_table(self)
- Populate the various data structures that keep tabs on the
option table. Called by 'getopt()' before it can do anything
worthwhile.
- add_option(self, long_option, short_option=None, help_string=None)
- generate_help(self, header=None)
- Generate help text (a list of strings, one per suggested line of
output) from the option table for this FancyGetopt object.
- get_attr_name(self, long_option)
- Translate long option name 'long_option' to the form it
has as an attribute of some object: ie., translate hyphens
to underscores.
- get_option_order(self)
- Returns the list of (option, value) tuples processed by the
previous run of 'getopt()'. Raises RuntimeError if
'getopt()' hasn't been called yet.
- getopt(self, args=None, object=None)
- Parse the command-line options in 'args' and store the results
as attributes of 'object'. If 'args' is None or not supplied, uses
'sys.argv[1:]'. If 'object' is None or not supplied, creates a new
OptionDummy object, stores option values there, and returns a tuple
(args, object). If 'object' is supplied, it is modified in place
and 'getopt()' just returns 'args'; in both cases, the returned
'args' is a modified copy of the passed-in 'args' list, which is
left untouched.
- has_option(self, long_option)
- Return true if the option table for this parser has an
option with long name 'long_option'.
- print_help(self, header=None, file=None)
- set_aliases(self, alias)
- Set the aliases for this option parser.
- set_negative_aliases(self, negative_alias)
- Set the negative aliases for this option parser.
'negative_alias' should be a dictionary mapping option names to
option names, both the key and value must already be defined
in the option table.
- set_option_table(self, option_table)
Data and non-method functions defined here:
- __doc__ = "Wrapper around the standard 'getopt()' module t...n the command line sets 'verbose' to false\n "
- __module__ = 'distutils.fancy_getopt'
|
class OptionDummy |
| |
Dummy class just used as a place to hold command-line option
values as instance attributes. |
| |
Methods defined here:
- __init__(self, options=[])
- Create a new OptionDummy instance. The attributes listed in
'options' will be initialized to None.
Data and non-method functions defined here:
- __doc__ = 'Dummy class just used as a place to hold command-line option\n values as instance attributes.'
- __module__ = 'distutils.fancy_getopt'
| |