schrodinger :: utils :: cmdline :: SingleDashOptionParser :: Class SingleDashOptionParser
[hide private]
[frames] | no frames]

Class SingleDashOptionParser

optparse.OptionContainer --+    
                           |    
       optparse.OptionParser --+
                               |
                              SingleDashOptionParser

An OptionParser subclass that allows long options with a single dash.

Note that this class can therefore not be used for clustering short options - i.e. "-rf" will be interpreted as a long option "rf", not the short options "-r" and "-f".

Instance Methods [hide private]
 
__init__(self, *args, **kwargs)
This constructor takes the same options as the standard library's optparse.OptionParser.
 
parse_args(self, args=None, values=None, ignore_unknown=False)
parse_args(args : [string] = sys.argv[1:], values : Values = None) -> (values : Values, args : [string])
 
has_option(self, option)
 
get_option(self, opt_str)
Return the Option instance with the option string opt_str, or None if no options have that string.
 
remove_option(self, opt_str)
Remove the Option with the option string opt_str.
 
_get_option(self, opt_str, ignore_unknown)
Return an option that matches the opt_str or for which opt_str is an unambiguous abbreviation.
 
print_usage(self, file=None)
print_usage(file : file = stdout)

Inherited from optparse.OptionParser: add_option_group, check_values, destroy, disable_interspersed_args, enable_interspersed_args, error, exit, 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_help, 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, 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, *args, **kwargs)
(Constructor)

 

This constructor takes the same options as the standard library's optparse.OptionParser.

It also takes the keyword argument 'version_source', which should be a string containing a CVS Revision string like $Revision: 1.26 $. The 'version_source' argument is used to create a standard version string that also notes the Schrodinger python version number, so its use should be preferred to specifying a 'version' explicitly.

Overrides: optparse.OptionContainer.__init__

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

 

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)

has_option(self, option)

 
Overrides: optparse.OptionContainer.has_option

get_option(self, opt_str)

 

Return the Option instance with the option string opt_str, or None if no options have that string.

Overrides: optparse.OptionContainer.get_option

remove_option(self, opt_str)

 

Remove the Option with the option string opt_str.

Overrides: optparse.OptionContainer.remove_option

_get_option(self, opt_str, ignore_unknown)

 

Return an option that matches the opt_str or for which opt_str is an unambiguous abbreviation. A long option should begin with a single dash. Options with embedded equals signs are allowed.

print_usage(self, file=None)

 

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