Previous topic

2.1.6.1.1. objectlistiterator.ObjectListIterator

Next topic

2.1.7. solrclient

This Page

2.1.6.1.2. objectlistiterator.OptionParser

class objectlistiterator.OptionParser(usage=None, option_list=None, option_class=<class optparse.Option at 0x100fa5590>, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None)
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 (self.prog or os.path.basename(sys.argv[0])).
prog : string
the name of the current program (to override os.path.basename(sys.argv[0])).
epilog : string
paragraph of help text to print after option help
option_groups : [OptionGroup]
list of option groups in this parser (option groups are irrelevant for parsing the command-line, but very useful for generating help)
allow_interspersed_args : bool = 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.)

process_default_values : bool = true
if true, option default values are processed similarly to option values from the command line: that is, they are passed to the type-checking function for the option’s type (as long as the default value is a string). (This really only matters if you have defined custom types; see SF bug #955889.) Set it to false to restore the behaviour of Optik 1.4.1 and earlier.
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.

__init__(usage=None, option_list=None, option_class=<class optparse.Option at 0x100fa5590>, version=None, conflict_handler='error', description=None, formatter=None, add_help_option=True, prog=None, epilog=None)

Methods

__init__([usage, option_list, option_class, ...])
add_option(Option) add_option(opt_str, ..., kwarg=val, ...)
add_option_group(*args, **kwargs)
add_options(option_list)
check_values(values : Values, args : [string]) -> (values : Values, args : [string])
destroy() Declare that you are done with this OptionParser. This cleans up
disable_interspersed_args() Set parsing to stop on the first non-option.
enable_interspersed_args() Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments.
error(msg : string) Print a usage message incorporating ‘msg’ to stderr and exit.
exit([status, msg])
expand_prog_name(s)
format_description(formatter)
format_epilog(formatter)
format_help([formatter])
format_option_help([formatter])
get_default_values()
get_description()
get_option(opt_str)
get_option_group(opt_str)
get_prog_name()
get_usage()
get_version()
has_option(opt_str)
parse_args([args, values]) parse_args(args : [string] = sys.argv[1:],
print_help(file : file = stdout) Print an extended help message, listing all options and any
print_usage(file : file = stdout) Print the usage message for the current program (self.usage) to ‘file’ (default stdout).
print_version(file : file = stdout) Print the version message for this program (self.version) to ‘file’ (default stdout).
remove_option(opt_str)
set_conflict_handler(handler)
set_default(dest, value)
set_defaults(**kwargs)
set_description(description)
set_process_default_values(process)
set_usage(usage)

Attributes

standard_option_list list() -> new empty list