Package esys :: Package lsm :: Package util :: Module OptParse
[hide private]
[frames] | no frames]

Module OptParse

Defines OptionParser class which extends optparse.OptionParser class by adding 'string_list', 'int_list' and 'float_list' option types. Also defines LogOptionParser which extends OptionParser and adds support for esys.lsm.Logging options.

Classes [hide private]
  ListOption
Extends optparse.Option class by adding 'string_list', 'int_list' and 'float_list' types
  OptionParser
Command line option parser which extends optparse.OptionParser by adding "int_list", "float_list" and "string_list" types.
  LogOptionParser
Command line option parser which extends OptionParser by adding a default logging option.
Functions [hide private]
list
getListFromString(opt, str, mapCallable)
Parses a given string to extract a list.
 
checkIntList(option, opt, value)
Extracts a list of integers from a specified value.
 
checkFloatList(option, opt, value)
Extracts a list of floats from a specified value.
 
checkStringList(option, opt, value)
Extracts a list of strings from a specified value.
Function Details [hide private]

getListFromString(opt, str, mapCallable)

 

Parses a given string to extract a list. The expected format of the string is '[e1,e2,e3,...]'. Returns map(mapCallable, [e1,e2,e3,...]).

Parameters:
  • opt (string) - Command line option, only used for for creating messages when raising OptionValueException
  • str (string) - The option value string
  • mapCallable (callable) - Callable object which converts a string list element into another type, eg int, float, etc
Returns: list
list of converted-type elements.

checkIntList(option, opt, value)

 

Extracts a list of integers from a specified value.

Parameters:
  • option - The option.
  • opt (string) - The command line option string.
  • value (string) - The value passed to the option. @rtype list
Returns:
list of ints

checkFloatList(option, opt, value)

 

Extracts a list of floats from a specified value.

Parameters:
  • opt (string) - The command line option string.
  • value (string) - The value passed to the option. @rtype list
Returns:
list of floats

checkStringList(option, opt, value)

 

Extracts a list of strings from a specified value.

Parameters:
  • opt (string) - The command line option string.
  • value (string) - The value passed to the option. @rtype list
Returns:
list of floats