OpenQuizz
Une application de gestion des contenus pédagogiques
|
Public Member Functions | |
def | __init__ (self, option_table=None) |
def | set_option_table (self, option_table) |
def | add_option (self, long_option, short_option=None, help_string=None) |
def | has_option (self, long_option) |
def | get_attr_name (self, long_option) |
def | set_aliases (self, alias) |
def | set_negative_aliases (self, negative_alias) |
def | getopt (self, args=None, object=None) |
def | get_option_order (self) |
def | generate_help (self, header=None) |
def | print_help (self, header=None, file=None) |
Data Fields | |
option_table | |
option_index | |
alias | |
negative_alias | |
short_opts | |
long_opts | |
short2long | |
attr_name | |
takes_arg | |
option_order | |
repeat | |
Wrapper around the standard 'getopt()' module that provides some handy extra functionality: * short and long options are tied together * options have help strings, and help text can be assembled from them * options set attributes of a passed-in object * boolean options can have "negative aliases" -- eg. if --quiet is the "negative alias" of --verbose, then "--quiet" on the command line sets 'verbose' to false
def __init__ | ( | self, | |
option_table = None |
|||
) |
def add_option | ( | self, | |
long_option, | |||
short_option = None , |
|||
help_string = None |
|||
) |
def generate_help | ( | self, | |
header = None |
|||
) |
Generate help text (a list of strings, one per suggested line of output) from the option table for this FancyGetopt object.
def get_attr_name | ( | self, | |
long_option | |||
) |
Translate long option name 'long_option' to the form it has as an attribute of some object: ie., translate hyphens to underscores.
def get_option_order | ( | self | ) |
Returns the list of (option, value) tuples processed by the previous run of 'getopt()'. Raises RuntimeError if 'getopt()' hasn't been called yet.
def getopt | ( | self, | |
args = None , |
|||
object = None |
|||
) |
Parse command-line options in args. Store as attributes on object. If 'args' is None or not supplied, uses 'sys.argv[1:]'. If 'object' is None or not supplied, creates a new OptionDummy object, stores option values there, and returns a tuple (args, object). If 'object' is supplied, it is modified in place and 'getopt()' just returns 'args'; in both cases, the returned 'args' is a modified copy of the passed-in 'args' list, which is left untouched.
def has_option | ( | self, | |
long_option | |||
) |
Return true if the option table for this parser has an option with long name 'long_option'.
def print_help | ( | self, | |
header = None , |
|||
file = None |
|||
) |
def set_aliases | ( | self, | |
alias | |||
) |
Set the aliases for this option parser.
def set_negative_aliases | ( | self, | |
negative_alias | |||
) |
Set the negative aliases for this option parser. 'negative_alias' should be a dictionary mapping option names to option names, both the key and value must already be defined in the option table.
def set_option_table | ( | self, | |
option_table | |||
) |
alias |
attr_name |
long_opts |
negative_alias |
option_index |
option_order |
option_table |
repeat |
short2long |
short_opts |
takes_arg |