mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-python
synced 2026-01-15 01:52:56 +01:00
ArgsContainer.specified_args: Add property
ArgsContainer.specified_args is a list of arguments that were explicitly specified, i.e. not defaults, in the order they were specified in. Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
d35a5588cd
commit
862a5dbc95
1 changed files with 6 additions and 0 deletions
|
|
@ -11,6 +11,7 @@ class ArgsContainer: # export
|
|||
__args = OrderedDict()
|
||||
__kwargs = OrderedDict()
|
||||
__values = {}
|
||||
__specified_args = list()
|
||||
|
||||
def __getattr__(self, name):
|
||||
values = self.__values
|
||||
|
|
@ -27,6 +28,7 @@ class ArgsContainer: # export
|
|||
if not name in self.__kwargs.keys():
|
||||
raise Exception(f'No argument "{name}" defined')
|
||||
self.__values[name] = value
|
||||
self.__specified_args.append(name)
|
||||
|
||||
def add_argument(self, *args, **kwargs):
|
||||
for arg in args:
|
||||
|
|
@ -63,6 +65,10 @@ class ArgsContainer: # export
|
|||
pass
|
||||
slog(prio, f'{name}: {val}', caller=caller)
|
||||
|
||||
@property
|
||||
def specified_args(self):
|
||||
return self.__specified_args
|
||||
|
||||
def add_argument(p: argparse.ArgumentParser|ArgsContainer, name: str, *args, **kwargs): # export
|
||||
|
||||
key = name.strip('--').replace('-', '_')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue