[Numpy-svn] r4591 - branches/lib_for_io
numpy-svn at scipy.org
numpy-svn at scipy.org
Sat Dec 15 18:27:16 EST 2007
Author: chris.burns
Date: 2007-12-15 17:27:14 -0600 (Sat, 15 Dec 2007)
New Revision: 4591
Modified:
branches/lib_for_io/utils.py
Log:
Added docstrings to deprecate funcs
Modified: branches/lib_for_io/utils.py
===================================================================
--- branches/lib_for_io/utils.py 2007-12-15 22:29:10 UTC (rev 4590)
+++ branches/lib_for_io/utils.py 2007-12-15 23:27:14 UTC (rev 4591)
@@ -84,6 +84,15 @@
return func
def deprecate(func, oldname=None, newname=None):
+ """Deprecate old functions.
+ Issues a DeprecationWarning, adds warning to oldname's docstring,
+ rebinds oldname.__name__ and returns new function object.
+
+ Example:
+ oldfunc = deprecate(newfunc, 'oldfunc', 'newfunc')
+
+ """
+
import warnings
if oldname is None:
oldname = func.func_name
@@ -113,6 +122,17 @@
return newfunc
def deprecate_with_doc(somestr):
+ """Decorator to deprecate functions and provide detailed documentation
+ with 'somestr' that is added to the functions docstring.
+
+ Example:
+ depmsg = 'function numpy.lib.foo has been merged into numpy.lib.io.foobar'
+ @deprecate_with_doc(depmsg)
+ def foo():
+ pass
+
+ """
+
def _decorator(func):
newfunc = deprecate(func)
newfunc.__doc__ += "\n" + somestr
More information about the Numpy-svn
mailing list