Package docutils :: Module frontend :: Class OptionParser
[show private | hide private]
[frames | no frames]

Class OptionParser

OptionContainer --+    
                  |    
       OptionParser --+
                      |
       SettingsSpec --+
                      |
                     OptionParser


Parser for command-line and library use. The settings_spec specification here and in other Docutils components are merged to build the set of command-line options and runtime settings for this process.

Common settings (defined below) and component-specific settings must not conflict. Short options are reserved for common settings, and components are restrict to using long options.


Method Summary
  __init__(self, components, defaults, read_config_files, *args, **kwargs)
components is a list of Docutils components each containing a .settings_spec attribute.
  check_args(self, args)
  check_threshold(self, level)
  check_values(self, values, args)
check_values(values : Values, args : [string]) -> (values : Values, args : [string]) Check that the supplied option values and leftover arguments are valid.
  populate_from_components(self, components)
For each component, first populate from the SettingsSpec.settings_spec structure, then from the SettingsSpec.settings_defaults dictionary.
    Inherited from OptionParser
  add_option_group(self, *args, **kwargs)
  disable_interspersed_args(self)
  enable_interspersed_args(self)
  error(self, msg)
error(msg : string) Print a usage message incorporating 'msg' to stderr and exit.
  format_help(self, formatter)
  format_option_help(self, formatter)
  get_default_values(self)
  get_option_group(self, opt_str)
  get_prog_name(self)
  get_usage(self)
  get_version(self)
  parse_args(self, args, values)
parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string]) Parse the command-line options found in 'args' (default: sys.argv[1:]).
  print_help(self, file)
print_help(file : file = stdout) Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).
  print_usage(self, file)
print_usage(file : file = stdout) Print the usage message for the current program (self.usage) to 'file' (default stdout).
  print_version(self, file)
print_version(file : file = stdout) Print the version message for this program (self.version) to 'file' (default stdout).
  set_default(self, dest, value)
  set_defaults(self, **kwargs)
  set_usage(self, usage)
  _create_option_list(self)
  _get_args(self, args)
  _init_parsing_state(self)
  _match_long_opt(self, opt)
_match_long_opt(opt : string) -> string Determine which long option string 'opt' matches, ie.
  _populate_option_list(self, option_list, add_help)
  _process_args(self, largs, rargs, values)
_process_args(largs : [string], rargs : [string], values : Values) Process command-line arguments and populate 'values', consuming options and arguments from 'rargs'.
  _process_long_opt(self, rargs, values)
  _process_short_opts(self, rargs, values)
    Inherited from OptionContainer
  add_option(self, *args, **kwargs)
add_option(Option)...
  add_options(self, option_list)
  format_description(self, formatter)
  get_option(self, opt_str)
  has_option(self, opt_str)
  remove_option(self, opt_str)
  set_conflict_handler(self, handler)
  set_description(self, description)
  _check_conflict(self, option)
  _create_option_mappings(self)
  _share_option_mappings(self, parser)

Class Variable Summary
str default_error_encoding_error_handler = 'replace'
tuple relative_path_settings = ('warning_stream',)
dict settings_defaults = {'_disable_config': None}
tuple settings_spec = ('General Docutils Options', None, (('In...
list threshold_choices = ['info', '1', 'warning', '2', 'error...
dict thresholds = {'info': 1, 'severe': 4, 'warning': 2, 'non...
str version_template = '%prog (Docutils 0.3.0)'
    Inherited from OptionParser
list standard_option_list = []
    Inherited from SettingsSpec
NoneType settings_default_overrides = None                                                                  

Method Details

__init__(self, components=(), defaults=None, read_config_files=None, *args, **kwargs)
(Constructor)

components is a list of Docutils components each containing a .settings_spec attribute. defaults is a mapping of setting default overrides.
Overrides:
optparse.OptionParser.__init__

check_values(self, values, args)

check_values(values : Values, args : [string])
-> (values : Values, args : [string])

Check that the supplied option values and leftover arguments are
valid.  Returns the option values and leftover arguments
(possibly adjusted, possibly completely new -- whatever you
like).  Default implementation just returns the passed-in
values; subclasses may override as desired.
Overrides:
optparse.OptionParser.check_values (inherited documentation)

populate_from_components(self, components)

For each component, first populate from the SettingsSpec.settings_spec structure, then from the SettingsSpec.settings_defaults dictionary. After all components have been processed, check for and populate from each component's SettingsSpec.settings_default_overrides dictionary.

Class Variable Details

default_error_encoding_error_handler

Type:
str
Value:
'replace'                                                              

relative_path_settings

Type:
tuple
Value:
('warning_stream',)                                                    

settings_defaults

Type:
dict
Value:
{'_disable_config': None}                                              

settings_spec

Type:
tuple
Value:
('General Docutils Options',
 None,
 (('Include a "Generated by Docutils" credit and link at the end of th\
e document.',
   ['--generator', '-g'],
   {'action': 'store_true'}),
  ('Do not include a generator credit.',
   ['--no-generator'],
...                                                                    

threshold_choices

Type:
list
Value:
['info', '1', 'warning', '2', 'error', '3', 'severe', '4', 'none']     

thresholds

Type:
dict
Value:
{'info': 1, 'severe': 4, 'warning': 2, 'none': 5, 'error': 3}          

version_template

Type:
str
Value:
'%prog (Docutils 0.3.0)'                                               

Generated by Epydoc 2.0 on Tue Jul 22 05:30:56 2003 http://epydoc.sf.net