You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
660 B
29 lines
660 B
5 months ago
|
import functools
|
||
|
import logging
|
||
|
|
||
|
|
||
|
try:
|
||
|
from decorator import decorator
|
||
|
except ImportError:
|
||
|
def decorator(caller):
|
||
|
""" Turns caller into a decorator.
|
||
|
Unlike decorator module, function signature is not preserved.
|
||
|
|
||
|
:param caller: caller(f, *args, **kwargs)
|
||
|
"""
|
||
|
def decor(f):
|
||
|
@functools.wraps(f)
|
||
|
def wrapper(*args, **kwargs):
|
||
|
return caller(f, *args, **kwargs)
|
||
|
return wrapper
|
||
|
return decor
|
||
|
|
||
|
|
||
|
try: # Python 2.7+
|
||
|
from logging import NullHandler
|
||
|
except ImportError:
|
||
|
class NullHandler(logging.Handler):
|
||
|
|
||
|
def emit(self, record):
|
||
|
pass
|