Package logilab-common-0 :: Package 39 :: Package 0 :: Module deprecation
[frames] | no frames]

Module deprecation

source code

Deprecation utilities.

:copyright: 2006-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
:license: General Public License version 2 - http://www.gnu.org/licenses

Classes
  deprecated
metaclass to print a warning on instantiation of a deprecated class
Functions
 
class_renamed(old_name, new_class, message=None)
automatically creates a class which fires a DeprecationWarning when instantiated.
source code
 
class_moved(new_class, old_name=None, message=None)
nice wrapper around class_renamed when a class has been moved into...
source code
 
deprecated_function(new_func, message=None)
Creates a function which fires a DeprecationWarning when used.
source code
 
moved(modpath, objname)
use to tell that a callable has been moved to a new module.
source code
 
obsolete(reason="This function is obsolete")
this function is an alternative to `deprecated_function`...
source code
Function Details

class_renamed(old_name, new_class, message=None)

source code 
automatically creates a class which fires a DeprecationWarning
when instantiated.

>>> Set = class_renamed('Set', set, 'Set is now replaced by set')
>>> s = Set()
sample.py:57: DeprecationWarning: Set is now replaced by set
  s = Set()
>>>

class_moved(new_class, old_name=None, message=None)

source code 
nice wrapper around class_renamed when a class has been moved into
another module

deprecated_function(new_func, message=None)

source code 
Creates a function which fires a DeprecationWarning when used.

For example, if <bar> is deprecated in favour of <foo>:

>>> bar = deprecated_function(foo, 'bar is deprecated')
>>> bar()
sample.py:57: DeprecationWarning: bar is deprecated
  bar()
>>>

moved(modpath, objname)

source code 
use to tell that a callable has been moved to a new module.

It returns a callable wrapper, so that when its called a warning is printed
telling where the object can be found, import is done (and not before) and
the actual object is called.

NOTE: the usage is somewhat limited on classes since it will fail if the
wrapper is use in a class ancestors list, use the `class_moved` function
instead (which has no lazy import feature though).

obsolete(reason="This function is obsolete")

source code 
this function is an alternative to `deprecated_function`
when there's no real replacement for the deprecated function