allpy
changeset 1108:0736e1bbd186
Reverted draft changes to allpy/util.py accidentally added to commit [bc1a7595d9d1]
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Thu, 14 Jun 2012 20:24:26 +0400 |
parents | bc1a7595d9d1 |
children | 7bc44212ca15 349316a4e941 |
files | allpy/util.py |
diffstat | 1 files changed, 1 insertions(+), 36 deletions(-) [+] |
line diff
1.1 --- a/allpy/util.py Thu Jun 14 19:05:28 2012 +0400 1.2 +++ b/allpy/util.py Thu Jun 14 20:24:26 2012 +0400 1.3 @@ -3,8 +3,6 @@ 1.4 import sys 1.5 import warnings 1.6 import os 1.7 -import inspect 1.8 -import functools 1.9 from tempfile import mkstemp 1.10 from StringIO import StringIO 1.11 1.12 @@ -45,43 +43,10 @@ 1.13 """Clone of str that user may add attributes to.""" 1.14 pass 1.15 1.16 -def deprecated(message=None, what=None, in_favor=None, removed_in=None): 1.17 +def deprecated(message): 1.18 """Warn about function being deprecated.""" 1.19 - if not message: 1.20 - if what is None: 1.21 - frame = inspect.currentframe().f_back 1.22 - caller = [] 1.23 - if inspect.getmodule(frame): 1.24 - caller.append(inspect.getmodule(frame).__name__) 1.25 - if 'self' in frame.f_locals: 1.26 - caller.append(frame.f_locals['self'].__class__.__name__) 1.27 - elif 'cls' in frame.f_locals: 1.28 - caller.append(frame.f_locals['cls'].__name__) 1.29 - caller.append(frame.f_code.co_name) 1.30 - what = ".".join(caller) + "(...)" 1.31 - message = "{0} is deprecated".format(what) 1.32 - if in_favor: 1.33 - message = "{0} in favor of {1}".format(message, in_favor) 1.34 - if removed_in: 1.35 - message = "{0}; will be removed in allpy version {1}".format(message, removed_in) 1.36 warnings.warn(message, DeprecationWarning, stacklevel=2) 1.37 1.38 -def Deprecated(message=None, in_favor=None, removed_in=None): 1.39 - def decorator(function): 1.40 - @functools.wraps(function) 1.41 - def decorated(*args, **kws): 1.42 - text = "{0} is deprecated".format(function) 1.43 - if in_favor: 1.44 - text = "{0} in favor of {1}".format(text, in_favor) 1.45 - if removed_in: 1.46 - text = "{0}\n\nWill be removed in allpy version {1}.".format(text, removed_in) 1.47 - if message: 1.48 - text = "{0}\n\n{1}".format(text, message) 1.49 - warnings.warn(text, DeprecationWarning, stacklevel=2) 1.50 - return function(*args, **kws) 1.51 - return decorated 1.52 - return decorator 1.53 - 1.54 class Silence(object): 1.55 """Context manager for use with `with`. 1.56