desytech / kubot

Lendbot for Kucoin
GNU General Public License v3.0
2 stars 2 forks source link

Combine optional and property wrapper #7

Closed desytech closed 3 years ago

desytech commented 3 years ago

In config/config.py we have two decorators: optional and property wrapper. We could merge it into once.

def optional_wrapper(arg):
    def inner_decorator(f):
        def wrapped(*args, **kwargs):
            response = f(*args, **kwargs)
            return arg if response is None else response
        return wrapped
    return inner_decorator

def property_wrapper(func):
    def function_wrapper(x):
        try:
            return func(x)
        except Exception as e:
            print("Error reading configuration:", e)
            exit(2)
    return function_wrapper
desytech commented 3 years ago

Fixed with 4f6faa2