diff --git a/requirements.txt b/requirements.txt index 9032044..fc8b6ca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,3 @@ cryptography >= 1.7.2 # Apache Software License requests >= 2.13.0 # Apache Software License +decorator >= 4.0.11 # New BSD License \ No newline at end of file diff --git a/src/main/python/covata/delta/utils.py b/src/main/python/covata/delta/utils.py index 5d342ec..c58b0c2 100644 --- a/src/main/python/covata/delta/utils.py +++ b/src/main/python/covata/delta/utils.py @@ -13,23 +13,21 @@ # limitations under the License. import inspect -import functools +from decorator import decorator def check_arguments(arguments, validation_function, fail_message): - def decorator(function): - @functools.wraps(function) - def _f(*args, **kwargs): - keys, _, _, _ = inspect.getargspec(function) - ins = dict(zip(keys, args)) - ins.update(kwargs) - generator = ((x, y) for x, y in ins.items() if x in arguments) - for arg, value in generator: - if not validation_function(value): - raise ValueError("{} {}".format(arg, fail_message)) - return function(*args, **kwargs) - return _f - return decorator + @decorator + def _f(function, *args, **kwargs): + keys, _, _, _ = inspect.getargspec(function) + ins = dict(zip(keys, args)) + ins.update(kwargs) + generator = ((x, y) for x, y in ins.items() if x in arguments) + for arg, value in generator: + if not validation_function(value): + raise ValueError("{} {}".format(arg, fail_message)) + return function(*args, **kwargs) + return _f def check_id(arguments):