| Conditions | 1 |
| Total Lines | 15 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | #!/usr/bin/python |
||
| 7 | def deprecated(func): |
||
| 8 | """This is a decorator which can be used to mark functions |
||
| 9 | as deprecated. It will result in a warning being emitted |
||
| 10 | when the function is used.""" |
||
| 11 | |||
| 12 | @functools.wraps(func) |
||
| 13 | def new_func(*args, **kwargs): |
||
| 14 | warnings.simplefilter('always', DeprecationWarning) # turn off filter |
||
| 15 | warnings.warn("Call to deprecated function {}.".format(func.__name__), |
||
| 16 | category=DeprecationWarning, |
||
| 17 | stacklevel=2) |
||
| 18 | warnings.simplefilter('default', DeprecationWarning) # reset filter |
||
| 19 | return func(*args, **kwargs) |
||
| 20 | |||
| 21 | return new_func |
||
| 22 |