parse(self,
rawpars,
subcmds)
|
|
Parse the list of parameters collected from the command line.
If the command line had parameters specified as:
-sfoo -sbar:xyz -sbaz:10
then the function call should get the list:
rawpars=['foo', 'bar:xyz', 'baz:10']
Result of parsing will be a dictionary of objects by subcommand name,
where each object has attributes named like subcommand parameters. If
attribute name has not been explicitly defined for a parameter, its
parameter name will be used; if not a valid identifier by itself, it will
be normalized by replacing all troublesome characters with an underscore,
collapsing contiguous underscore sequences to a single underscore, and
prepending an 'x' if it does not start with a letter.
If a parameter is parsed which is not accepted by any of the given
subcommands, its name is added to list of non-accepted parameters, which
is the second element of the return tuple.
- Parameters:
rawpars (list of strings) - raw parameters
subcmds (list of strings) - names of issued subcommands
- Returns: dict of objects by subcommand name and list of strings
- objects with parameters as attributes, and list of parameter
names not accepted by any of subcommands
|