Package flumotion :: Package extern :: Package command :: Module command :: Class CommandOptionParser
[hide private]

Class CommandOptionParser

source code

optparse.OptionContainer --+    
                           |    
       optparse.OptionParser --+
                               |
                              CommandOptionParser

I parse options as usual, but I explicitly allow setting stdout so that our print_help() method (invoked by default with -h/--help) defaults to writing there.

I also override exit() so that I can be used in interactive shells.

Instance Methods [hide private]
 
set_stdout(self, stdout) source code
 
parse_args(self, args=None, values=None)
parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string])
source code
 
print_help(self, file=None)
print_help(file : file = stdout)
source code
 
print_usage(self, file=None)
print_usage(file : file = stdout)
source code
 
exit(self, status=0, msg=None) source code

Inherited from optparse.OptionParser: __init__, add_option_group, check_values, destroy, disable_interspersed_args, enable_interspersed_args, error, expand_prog_name, format_epilog, format_help, format_option_help, get_default_values, get_description, get_option_group, get_prog_name, get_usage, get_version, 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]
  _stdout = sys.stdout
  __pychecker__ = 'no-shadowbuiltin'

Inherited from optparse.OptionParser: standard_option_list

Instance Variables [hide private]
  help_printed = False
whether help was printed during parsing
  usage_printed = False
whether usage was printed during parsing
Method Details [hide private]

parse_args(self, args=None, values=None)

source code 

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:]).  Any errors result in a call to 'error()', which
by default prints the usage message to stderr and calls
sys.exit() with an error message.  On success returns a pair
(values, args) where 'values' is an Values instance (with all
your option values) and 'args' is the list of arguments left
over after parsing options.

Overrides: optparse.OptionParser.parse_args
(inherited documentation)

print_help(self, file=None)

source code 

print_help(file : file = stdout)

Print an extended help message, listing all options and any help text provided with them, to 'file' (default stdout).

Overrides: optparse.OptionParser.print_help
(inherited documentation)

print_usage(self, file=None)

source code 

print_usage(file : file = stdout)

Print the usage message for the current program (self.usage) to 'file' (default stdout). Any occurence of the string "%prog" in self.usage is replaced with the name of the current program (basename of sys.argv[0]). Does nothing if self.usage is empty or not defined.

Overrides: optparse.OptionParser.print_usage
(inherited documentation)

exit(self, status=0, msg=None)

source code 
Overrides: optparse.OptionParser.exit