Package wtf :: Module cmdline :: Class _OptionParser
[hide private]
[frames] | no frames]

Class _OptionParser

source code

optparse.OptionContainer --+    
                           |    
       optparse.OptionParser --+
                               |
                              _OptionParser

Extended option parser for better behaviour
Instance Methods [hide private]
 
__init__(self, **kwargs)
Initialization
source code
tuple
parse_args(self, *args, **kwargs)
Parse the argument list provided by sys.argv
source code
 
error(self, msg)
Raise an exception instead of calling sys.exit
source code
str
get_version(self)
Return the version string
source code
str
get_usage(self)
Return the usage string
source code
str
get_prog_name(self)
Returns the program name
source code
str
_get_prog_name(self)
Returns the program name
source code
str
format_help(self, formatter=None)
Return the formatted help string
source code

Inherited from optparse.OptionParser: add_option_group, check_values, destroy, disable_interspersed_args, enable_interspersed_args, exit, expand_prog_name, format_epilog, format_option_help, get_default_values, get_description, get_option_group, print_help, print_usage, print_version, set_default, set_defaults, set_process_default_values, set_usage

Inherited from optparse.OptionParser (private): _add_help_option, _add_version_option, _create_option_list, _get_all_options, _get_args, _get_encoding, _init_parsing_state, _match_long_opt, _populate_option_list, _process_args, _process_long_opt, _process_short_opts

Inherited from optparse.OptionContainer: add_option, add_options, format_description, get_option, has_option, remove_option, set_conflict_handler, set_description

Inherited from optparse.OptionContainer (private): _check_conflict, _create_option_mappings, _share_option_mappings

Class Variables [hide private]

Inherited from optparse.OptionParser: standard_option_list

Method Details [hide private]

__init__(self, **kwargs)
(Constructor)

source code 
Initialization
Overrides: optparse.OptionContainer.__init__

parse_args(self, *args, **kwargs)

source code 
Parse the argument list provided by sys.argv
Parameters:
  • args (tuple) - Additional arguments for the parser
  • kwargs (dict) - Additional arguments for the parser
Returns: tuple
The OptionContainer instance and the positional args ((optparse.OptionContainer, list))
Raises:
Overrides: optparse.OptionParser.parse_args

error(self, msg)

source code 
Raise an exception instead of calling sys.exit
Parameters:
  • msg (str) - The error message
Raises:
Overrides: optparse.OptionParser.error

get_version(self)

source code 
Return the version string
Returns: str
The version string
Overrides: optparse.OptionParser.get_version

get_usage(self)

source code 
Return the usage string
Returns: str
The usage string
Overrides: optparse.OptionParser.get_usage

get_prog_name(self)

source code 
Returns the program name
Returns: str
The program name
Overrides: optparse.OptionParser.get_prog_name

_get_prog_name(self)

source code 
Returns the program name
Returns: str
The program name

format_help(self, formatter=None)

source code 

Return the formatted help string

The string consists of the normal option help generated by the optparse module and a short description of the old style options. All text is tried to be wrapped to fit into the current terminal width.

Parameters:
  • formatter (any) - unused
Returns: str
The formatted help string
Overrides: optparse.OptionContainer.format_help