Mini Shell

Direktori : /opt/saltstack/salt/extras-3.10/rads/
Upload File :
Current File : //opt/saltstack/salt/extras-3.10/rads/compat.py

"""Decorator for 2.7 compat functions"""
import functools
import warnings

WARNED = []

class RadsDeprecation(DeprecationWarning):
    """Subclass of DeprecationWarning for Rads"""


def deprecated(new=None):
    """Decorator for 2.7 compat functions"""

    def _deprecated(func):
        @functools.wraps(func)
        def _deprecated_wrap(*args, **kwargs):
            name = f"{func.__module__}.{func.__name__}"
            if name not in WARNED:
                msg = f'{name} is deprecated'
                if new:
                    msg = '%s. See %s' % (msg, new)
                warnings.warn(msg, RadsDeprecation, 4)
                WARNED.append(name)
            return func(*args, **kwargs)

        return _deprecated_wrap

    return _deprecated

Zerion Mini Shell 1.0