Package wsatools :: Module CLI :: Class OptGroup
[hide private]

Class OptGroup

source code


Container to store the specified set of command-line options specified by the program. It is a dictionary of CLI.Option objects (option definitions) referenced by both their long and short (single character) names. Supplied options from getopt are passed through to processArgs() to provide a command-line option look-up table for the program.

Instance Methods [hide private]
new empty dictionary

__init__(self, optList=[])
Initialise with the list of option definitions for this program.
source code
 
__add__(self, optList)
Create a new container by adding a new list of options definitions to this container.
source code
 
__iadd__(self, optList)
Increment the list of argument definitions with additional arguments.
source code
 
__prepOptList(self, optList)
Prepares the look-up table for both short and long name references.
source code
 
append(self, option)
Add a single option.
source code
str
getHelpStr(self)
Returns: The program option definitions for the --help mode.
source code
list(str)
getLongNames(self)
Returns: Option long names in the format required by getopt.
source code
str
getShortOpts(self)
Returns: Option short names in the format required by getopt.
source code
dict{str : str}
processOpts(self, opts=[])
Processes the options supplied on the command-line, to return a look-up table to obtain option values from their long names.
source code
 
remove(self, name)
Removes specified option from the list of supported options.
source code

Inherited from dict: __cmp__, __contains__, __delitem__, __eq__, __ge__, __getattribute__, __getitem__, __gt__, __iter__, __le__, __len__, __lt__, __ne__, __new__, __repr__, __setitem__, __sizeof__, clear, copy, fromkeys, get, has_key, items, iteritems, iterkeys, itervalues, keys, pop, popitem, setdefault, update, values, viewitems, viewkeys, viewvalues

Inherited from object: __delattr__, __format__, __reduce__, __reduce_ex__, __setattr__, __str__, __subclasshook__

Class Variables [hide private]

Inherited from dict: __hash__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, optList=[])
(Constructor)

source code 

Initialise with the list of option definitions for this program.

Parameters:
  • optList (list(CLI.Option)) - List of option definitions for this program.
Returns:
new empty dictionary

Overrides: object.__init__

append(self, option)

source code 

Add a single option.

Parameters:
  • option (CLI.Option) - Option to add to group of options.

getHelpStr(self)

source code 
Returns: str
The program option definitions for the --help mode.

getLongNames(self)

source code 
Returns: list(str)
Option long names in the format required by getopt.

getShortOpts(self)

source code 
Returns: str
Option short names in the format required by getopt.

processOpts(self, opts=[])

source code 

Processes the options supplied on the command-line, to return a look-up table to obtain option values from their long names.

Parameters:
  • opts (list(tuple(str, str))) - List of options in format (name, value), where name maybe short or long name. (e.g. from getopt)
Returns: dict{str : str}
Loop-up table for command-line option values.

remove(self, name)

source code 

Removes specified option from the list of supported options.

Parameters:
  • name (str) - Option long name.