schrodinger.utils.singledashoptionparser module

SingleDashOptionParser has been deprecated in favor of using the argparse.ArgumentParser directly.

class schrodinger.utils.singledashoptionparser.SingleDashOption(*args, **kwargs)

Bases: optparse.Option

A class to automatically translate long options with single dashes into double dash long options, but still print out help with the single dash.

__init__(*args, **kwargs)
process_option_strings(formatted_option_strings)

Post-process the provided formatted options string to replace the translated double dash options with their original single dash specifications.

ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count', 'callback', 'help', 'version')
ALWAYS_TYPED_ACTIONS = ('store', 'append')
ATTRS = ['action', 'type', 'dest', 'default', 'nargs', 'const', 'choices', 'callback', 'callback_args', 'callback_kwargs', 'help', 'metavar']
CHECK_METHODS = [<function Option._check_action>, <function Option._check_type>, <function Option._check_choice>, <function Option._check_dest>, <function Option._check_const>, <function Option._check_nargs>, <function Option._check_callback>]
CONST_ACTIONS = ('store_const', 'append_const')
STORE_ACTIONS = ('store', 'store_const', 'store_true', 'store_false', 'append', 'append_const', 'count')
TYPED_ACTIONS = ('store', 'append', 'callback')
TYPES = ('string', 'int', 'long', 'float', 'complex', 'choice')
TYPE_CHECKER = {'choice': <function check_choice>, 'complex': <function check_builtin>, 'float': <function check_builtin>, 'int': <function check_builtin>, 'long': <function check_builtin>}
check_value(opt, value)
convert_value(opt, value)
get_opt_string()
process(opt, value, values, parser)
take_action(action, dest, opt, value, values, parser)
takes_value()
class schrodinger.utils.singledashoptionparser.DelegatingIndentedHelpFormatter(indent_increment=2, max_help_position=24, width=None, short_first=1)

Bases: optparse.IndentedHelpFormatter

An IndentedHelpFormatter class that allows an Option class to alter its own option string if it has a process_option_strings method.

format_option_strings(option)

Return a formatted option string.

Allow the provided option to alter the string if it has a process_option_strings() method.

NO_DEFAULT_VALUE = 'none'
__init__(indent_increment=2, max_help_position=24, width=None, short_first=1)
dedent()
expand_default(option)
format_description(description)
format_epilog(epilog)
format_heading(heading)
format_option(option)
format_usage(usage)
indent()
set_long_opt_delimiter(delim)
set_parser(parser)
set_short_opt_delimiter(delim)
store_option_strings(parser)
class schrodinger.utils.singledashoptionparser.SingleDashOptionParser(*args, **kwargs)

Bases: optparse.OptionParser

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”.

__init__(*args, **kwargs)

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.

parse_args(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 a Values instance (with all your option values) and ‘args’ is the list of arguments left over after parsing options.

has_option(option)
get_option(opt_str)

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

remove_option(opt_str)

Remove the Option with the option string opt_str.

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.

add_option(Option)
add_option(opt_str, ..., kwarg=val, ...) None
add_option_group(*args, **kwargs)
add_options(option_list)
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.

destroy()

Declare that you are done with this OptionParser. This cleans up reference cycles so the OptionParser (and all objects referenced by it) can be garbage-collected promptly. After calling destroy(), the OptionParser is unusable.

disable_interspersed_args()

Set parsing to stop on the first non-option. Use this if you have a command processor which runs another command that has options of its own and you want to make sure these options don’t get confused.

enable_interspersed_args()

Set parsing to not stop on the first non-option, allowing interspersing switches with command arguments. This is the default behavior. See also disable_interspersed_args() and the class documentation description of the attribute allow_interspersed_args.

error(msg: string)

Print a usage message incorporating ‘msg’ to stderr and exit. If you override this in a subclass, it should not return – it should either exit or raise an exception.

exit(status=0, msg=None)
expand_prog_name(s)
format_description(formatter)
format_epilog(formatter)
format_help(formatter=None)
format_option_help(formatter=None)
get_default_values()
get_description()
get_option_group(opt_str)
get_prog_name()
get_usage()
get_version()
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_version(file: file = stdout)

Print the version message for this program (self.version) to ‘file’ (default stdout). As with print_usage(), any occurrence of “%prog” in self.version is replaced by the current program’s name. Does nothing if self.version is empty or undefined.

set_conflict_handler(handler)
set_default(dest, value)
set_defaults(**kwargs)
set_description(description)
set_process_default_values(process)
set_usage(usage)
standard_option_list = []
schrodinger.utils.singledashoptionparser.version_string(version_source='')

Form a standard version string from a source string. The source string is searched for an embedded CVS Revision tag. If one is found, that is used as the script version. If no Revision tag is found, only Schrodinger python version information is included.