Skip to content
Snippets Groups Projects
Commit 1c6947b5 authored by Jan David Mol's avatar Jan David Mol
Browse files

Fixed use of decorator with arguments

parent 121f067c
Branches
Tags
No related merge requests found
......@@ -4,12 +4,13 @@ import traceback
__all__ = ["only_in_states", "only_when_on", "fault_on_error"]
def only_in_states(func, allowed_states):
def only_in_states(allowed_states):
"""
Wrapper to call and return the wrapped function if the device is
in one of the given states. Otherwise None is returned and nothing
will be called.
"""
def wrapper(func):
@wraps(func)
def state_check_wrapper(self, *args, **kwargs):
if self.get_state() in allowed_states:
......@@ -19,6 +20,8 @@ def only_in_states(func, allowed_states):
return state_check_wrapper
return wrapper
def only_when_on(func):
"""
Wrapper to call and return the wrapped function if the device is
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment