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