Package logilab :: Package common :: Module deprecation :: Class DeprecationManager

[frames] | no frames]

# Class DeprecationManager

source code

    object --+
             |
            DeprecationManager

    Manage the deprecation message handling. Messages are dropped for
    versions more recent than the 'compatible' version. Example::

        deprecator = deprecation.DeprecationManager("module_name")
        deprecator.compatibility('1.3')

        deprecator.warn('1.2', "message.")

        @deprecator.deprecated('1.2', 'Message')
        def any_func():
            pass

        class AnyClass(object):
            __metaclass__ = deprecator.class_deprecated('1.2')

Instance Methods

__init__(self, module_name=None) | source code

compatibility(self, compatible_version) Set the compatible version. | source code

deprecated(self, version=None, reason=None, stacklevel=2, name=None, doc=None) Display a deprecation message only if the version is older than the compatible version. | source code

class_deprecated(self, version=None) | source code

moved(self, version, modpath, objname) use to tell that a callable has been moved to a new module. | source code

class_renamed(self, version, old_name, new_class, message=None) | source code

class_moved(self, version, new_class, old_name=None, message=None) nice wrapper around class_renamed when a class has been moved into... | source code

warn(self, version=None, reason="", stacklevel=2) Display a deprecation message only if the version is older than the compatible version. | source code

Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__repr__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, module_name=None)
(Constructor)

source code

Overrides: object.__init__

### moved(self, version, 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).

### class_moved(self, version, new_class, old_name=None, message=None)

source code

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