| |
- check_option_for_args(option, allowed_options)
- Check to see if the option is supposed to have arguments.
- check_options(option, allowed_options)
- Check the option to see if it is one of the allowed_options.
If so, then see if it has a value.
- spst_getopt(arg_list, allowed_options=[])
- This function will parse the input list of cli-type parameters/options
looking for allowed option/values as specified in the allowed_options
list. This is an adaptation of the Python 1.5.2 getopt.py library
routine.
Written by Merle Reinhart, 4-Dec-2000
ARGUMENTS:
arg_list -- (list) This is the input argument list to be
parsed without the reference to the
running program (ie. like sys.argv[1:]).
Parameters and options can occur in any
order. Options must be contain a leading
'-'. Options which have values should have
a trailing '=' followed by the value.
allowed_options -- (list)
This is a list that describes the allowed
options that the function may find in the
arg_list. Each option should be completely
specified without the leading '-'. If the
option allows a value, then it should
contain a trailing '='.
RETURNS:
options -- (dictionary)
This is a dictionary of all option/value
combinations that were found in the input
arg_list. The key is the option and the
value is the value of the option.
parms -- (list) This is a list of all the parameters that
were found in the input arg_list in the
order they occured.
RAISES:
GetoptError If an option is found in arg_list that
is not contained in allowed_options.
If an option contains a value but
allowed_options says no value is allowed.
If an option does not have a value but
allowed_options says it must have a value.
If an option in arg_list cannot be uniquely
mapped to an option in allowed_options.
|