Logo Search packages:      
Sourcecode: karrigell version File versions  Download package

Cheetah::Utils::optik::option_parser::OptionParser Class Reference

List of all members.


Detailed Description

Class attributes:
  standard_option_list : [Option]
    list of standard options that will be accepted by all instances
    of this parser class (intended to be overridden by subclasses).

Instance attributes:
  usage : string
    a usage string for your program.  Before it is displayed
    to the user, "%prog" will be expanded to the name of
    your program (os.path.basename(sys.argv[0])).
  option_list : [Option]
    the list of all options accepted on the command-line of
    this program
  _short_opt : { string : Option }
    dictionary mapping short option strings, eg. "-f" or "-X",
    to the Option instances that implement them.  If an Option
    has multiple short option strings, it will appears in this
    dictionary multiple times.
  _long_opt : { string : Option }
    dictionary mapping long option strings, eg. "--file" or
    "--exclude", to the Option instances that implement them.
    Again, a given Option can occur multiple times in this
    dictionary.
  _long_opts : [string]
    list of long option strings recognized by this option
    parser.  Should be equal to _long_opt.values().
  defaults : { string : any }
    dictionary mapping option destination names to default
    values for each destination.

  allow_interspersed_args : boolean = true
    if true, positional arguments may be interspersed with options.
    Assuming -a and -b each take a single argument, the command-line
      -ablah foo bar -bboo baz
    will be interpreted the same as
      -ablah -bboo -- foo bar baz
    If this flag were false, that command line would be interpreted as
      -ablah -- foo bar -bboo baz
    -- ie. we stop processing options as soon as we see the first
    non-option argument.  (This is the tradition followed by
    Python's getopt module, Perl's Getopt::Std, and other argument-
    parsing libraries, but it is generally annoying to users.)

  rargs : [string]
    the argument list currently being parsed.  Only set when
    parse_args() is active, and continually trimmed down as
    we consume arguments.  Mainly there for the benefit of
    callback options.
  largs : [string]
    the list of leftover arguments that we have skipped while
    parsing options.  If allow_interspersed_args is false, this
    list is always empty.
  values : Values
    the set of option values currently being accumulated.  Only
    set when parse_args() is active.  Also mainly for callbacks.

Because of the 'rargs', 'largs', and 'values' attributes,
OptionParser is not thread-safe.  If, for some perverse reason, you
need to parse command-line arguments simultaneously in different
threads, use different OptionParser instances.

Definition at line 89 of file option_parser.py.


Public Member Functions

def __init__
def add_option
def add_options
def check_values
def disable_interspersed_args
def enable_interspersed_args
def error
def get_option
def has_option
def parse_args
def print_help
def print_usage
def print_version
def remove_option
def set_conflict_handler
def set_default
def set_defaults
def set_usage

Public Attributes

 allow_interspersed_args
 conflict_handler
 defaults
 largs
 option_class
 option_list
 rargs
 usage
 values
 version

Static Public Attributes

list standard_option_list = [STD_HELP_OPTION]

Private Member Functions

def _check_conflict
def _create_option_list
def _get_args
def _init_parsing_state
def _match_long_opt
def _populate_option_list
def _process_arg
def _process_long_opt
def _process_short_opts

Private Attributes

 _long_opt
 _long_opts
 _short_opt

The documentation for this class was generated from the following file:

Generated by  Doxygen 1.6.0   Back to index