more set_using_dict

This commit is contained in:
Erik Frojdh
2020-09-24 16:55:41 +02:00
parent 8483e05f4c
commit 671a2724ac
3 changed files with 72 additions and 27 deletions

View File

@ -189,4 +189,22 @@ def lhex(iterable):
def lpath(iterable):
return [Path(item) for item in iterable]
return [Path(item) for item in iterable]
def add_argument_before(a, args):
"""Add a before the other arguments. Also works with
dict that holds args to several modules. Always puts the
args in a dict to be compatible with set_using_dict"""
print(f'{args=}')
if isinstance(args, tuple):
return (a, *args)
elif isinstance(args, dict):
ret = {}
for key, value in args.items():
if isinstance(value, tuple):
ret[key] = (a, *value)
else:
ret[key] = (a, value)
return (ret,)
return a, args