-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathutils.py
More file actions
36 lines (25 loc) · 954 Bytes
/
utils.py
File metadata and controls
36 lines (25 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from typing import List, Callable, Tuple, Dict
from functools import wraps
class defaultValueType():
def __init__(self):
pass
DEFAULT_VALUE = defaultValueType()
def isDefault(obj):
return isinstance(obj,defaultValueType)
def getParameterSet(name : str,parameterSet : Dict) -> Dict:
if name in parameterSet:
if isinstance(parameterSet[name], dict):
return parameterSet[name]
return {}
def MapKeywordArg(objectName,*argumentMaps):
def MapArg(method):
@wraps(method)
def wrapper(*args, **kwargs):
containerParams = getParameterSet(objectName,kwargs)
for argMap in argumentMaps:
if (argMap[0] in kwargs) and not(kwargs[argMap[0]] is None):
containerParams[argMap[1]] = kwargs[argMap[0]]
kwargs[objectName] = containerParams
return method(*args,**kwargs)
return wrapper
return MapArg