diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-12-24 20:54:35 +0100 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-12-24 20:54:35 +0100 |
commit | 1b2cf476894dd7e63729debea4e87af6fc4a65aa (patch) | |
tree | 59019bfd63376c496672a6788bd950fc316211e0 /psutil/_common.py | |
parent | 80638f11d3540bb5085f0f41f5546404613f6161 (diff) | |
download | psutil-1b2cf476894dd7e63729debea4e87af6fc4a65aa.tar.gz |
big renaming of all Process.get_* methods producing a DeprecationWarning
Diffstat (limited to 'psutil/_common.py')
-rw-r--r-- | psutil/_common.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/psutil/_common.py b/psutil/_common.py index 0356b829..abeaf796 100644 --- a/psutil/_common.py +++ b/psutil/_common.py @@ -132,6 +132,24 @@ def deprecated(replacement=None): return outer +def deprecated_method(replacement): + """A decorator which can be used to mark a method as deprecated + 'replcement' is the method name which will be called instead. + """ + def outer(fun): + msg = "%s() is deprecated; use %s() instead" % ( + fun.__name__, replacement) + if fun.__doc__ is None: + fun.__doc__ = msg + + @wraps(fun) + def inner(self, *args, **kwargs): + warnings.warn(msg, category=DeprecationWarning, stacklevel=2) + return getattr(self, replacement)(*args, **kwargs) + return inner + return outer + + def isfile_strict(path): """Same as os.path.isfile() but does not swallow EACCES / EPERM exceptions, see: |