sysargv module¶
SysArgv class¶
- class tatogalib.util.sysargv.SysArgv¶
Class for parsing commandline arguments. All arguments must be an option string with or without a value. All arguments after the special marker
--are treated as extra arguments.myapp –cli –infilename myinfile –outfilename “my out file” – –extrabool –extra1 firstExtraArg
args = SysArgs() # creates the object and parses all arguments from sys.argv args.get("cli") # returns True args.get("infilename") # returns "myinfile" args.get("outfilename") # returns "my out file" args.get("whatever") # returns None args.get_extras() # returns {"extrabool":True, "extra1":"firstExtraArg"}
- get(option_name)¶
Get a commandline argument identified by its option name. Returns None if the option name does not exist.
- Parameters:
option_name (str) – The name of the option string
- Returns:
The value of the option string or None
- Return type:
str or None
- get_all()¶
Get all commandline arguments (without extras)
- Returns:
The dictionary with the option names and their values
- Return type:
dict
- get_extras()¶
Get the extra arguments
- Returns:
The dictionary with the extra arguments
- Return type:
dict
- length()¶
Gets the number of parsed arguments (without extras)
- Returns:
number of arguments
- Return type:
int