This commit is contained in:
Dave G
2018-05-09 22:11:05 -04:00
parent aa32a3ddd2
commit 6345fa4142
7 changed files with 726 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
"""Iterate through all methods in a class and apply decorator."""
def decorate_all_methods(decorator, exclude=None):
if exclude is None:
exclude = []
def decorate(cls):
for attr in cls.__dict__:
if callable(getattr(cls, attr)) and attr not in exclude:
setattr(cls, attr, decorator(getattr(cls, attr)))
return cls
return decorate