Proxy for renamed attributes (or methods) on classes.
Getting and setting values will be redirected to the provided name, and warnings will be issues every time.
E.g.:
>>> class Example(object):
...
... new_value = 'something'
... old_value = renamed_attr('new_value')
...
... def new_func(self, a, b):
... return a + b
...
... old_func = renamed_attr('new_func')
>>> e = Example()
>>> e.old_value = 'else'
# AttributeRenamedWarning: Example.old_value renamed to new_value
>>> e.old_func(1, 2)
# AttributeRenamedWarning: Example.old_func renamed to new_func
3
Proxy for renamed functions.
Parameters: | |
---|---|
Returns: | A function which calls the original, and omits a warning. |
E.g.:
>>> def new(a, b):
... return a + b
>>> old = renamed_func(new, 'old', __name__)
>>> old(1, 2)
# FunctionRenamedWarning: example.old renamed to example.new
3
Replace the current module with the one found at the given name.
Issues a ModuleRenamedWarning.
For example,
new.py:
>>> def func():
... print "Hello from %s!" % __name__
old.py:
>>> from metatools.deprecate import module_renamed
>>> module_renamed('new')
use.py:
>>> from old import func
# ModuleRenamedWarning: old was renamed to new
>>> func()
Hello from new!