SEPIO¶
- Author
Marcel Simader
- Date
01.04.2021
New in version v0.1.0.
Console Arguments¶
- exception SEPModules.SEPIO.ConsoleArgsError(msg, arguments)¶
Error class used to catch exceptions while parsing the
sys.argvinput forConsoleManager.
- class SEPModules.SEPIO.ConsoleArguments(argnames, kwargnames, *, no_load=False)¶
A console arguments manager that holds information about and offers API functionality for the console options and flags passed into the program. It immediately tries to read from
sys.argvif theno_loadoption is not set upon creation of an instance.- Parameters
argnames (Iterable[str]) – a list of single-letter strings defining the options, adding
:to the end of a letter indicates that a value must be passed to this flagkwargnames (Iterable[str]) – a list of multi-letter string defining long options, adding
=to the end of a string indicates that a value must be passed to this flagno_load (bool) – keyword-only argument, prohibits the console manager from automatically reading
sys.argvupon creation of the console arguments manager object
- Raises
ValueError – if any option or long option share the same name
ConsoleArgsError – if there was an error while parsing the
sys.argvinput
Size properties of
ConsoleArguments:set_total,set_args,set_kwargs,set_pars,required- property set_total: int¶
See other size_dict properties:
- Returns
the amount of set args, keyword args, and parameters.
- property set_args: int¶
See other size_dict properties:
- Returns
the amount of set args.
- property set_kwargs: int¶
See other size_dict properties:
- Returns
the amount of set keyword args.
- property set_pars: int¶
See other size_dict properties:
- Returns
the amount of set parameters.
- property required: int¶
See other size_dict properties:
- Returns
the amount of required args (e.g. a flag
a:).
- _load_arguments()¶
Load all arguments defined by the passed arg and kwarg names into
ConsoleArgumentsby reading from sys.argv.- Raises
ConsoleArgsError – if there was an error while parsing
- __contains__(options, *, _all=True)¶
- Parameters
_all (bool) – can be set to
Truefor checking against all values oftype(options) == list/setor toFalsefor only checking if any match- Returns
Trueif the options is found inargsorkwargs.- Return type
bool
- __getitem__(key)¶
Returns an argument/keyword argument if the supplied key is a
strobject. If the supplied key is of typeint, the corresponding parameter is returned.
- __iter__()¶
Iterate over
args, thenkwargs, and finally enumerate allparsentries.