How to use the debtcollector._utils.get_qualified_name function in debtcollector

To help you get started, we’ve selected a few debtcollector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstack / debtcollector / debtcollector / removals.py View on Github external
def _check_it(cls):
        if not inspect.isclass(cls):
            _qual, type_name = _utils.get_qualified_name(type(cls))
            raise TypeError("Unexpected class type '%s' (expected"
                            " class type only)" % type_name)
github openstack / debtcollector / debtcollector / removals.py View on Github external
def wrapper(f, instance, args, kwargs):
        qualified, f_name = _utils.get_qualified_name(f)
        if qualified:
            if inspect.isclass(f):
                prefix_pre = "Using class"
                thing_post = ''
            else:
                prefix_pre = "Using function/method"
                thing_post = '()'
        if not qualified:
            prefix_pre = "Using function/method"
            base_name = None
            if instance is None:
                # Decorator was used on a class
                if inspect.isclass(f):
                    prefix_pre = "Using class"
                    thing_post = ''
                    module_name = _get_qualified_name(inspect.getmodule(f))
github openstack / debtcollector / debtcollector / removals.py View on Github external
def _get_qualified_name(obj):
    return _utils.get_qualified_name(obj)[1]
github openstack / debtcollector / debtcollector / moves.py View on Github external
def moved_class(new_class, old_class_name, old_module_name,
                message=None, version=None, removal_version=None,
                stacklevel=3, category=None):
    """Deprecates a class that was moved to another location.

    This creates a 'new-old' type that can be used for a
    deprecation period that can be inherited from. This will emit warnings
    when the old locations class is initialized, telling where the new and
    improved location for the old class now is.
    """

    if not inspect.isclass(new_class):
        _qual, type_name = _utils.get_qualified_name(type(new_class))
        raise TypeError("Unexpected class type '%s' (expected"
                        " class type only)" % type_name)

    old_name = ".".join((old_module_name, old_class_name))
    new_name = _utils.get_class_name(new_class)
    prefix = _CLASS_MOVED_PREFIX_TPL % (old_name, new_name)
    out_message = _utils.generate_message(
        prefix, message=message, version=version,
        removal_version=removal_version)

    def decorator(f):

        @six.wraps(f, assigned=_utils.get_assigned(f))
        def wrapper(self, *args, **kwargs):
            _utils.deprecation(out_message, stacklevel=stacklevel,
                               category=category)
github openstack / debtcollector / debtcollector / moves.py View on Github external
def decorator(f):
        fully_qualified, old_attribute_name = _utils.get_qualified_name(f)
        if attr_postfix:
            old_attribute_name += attr_postfix

        @wrapt.decorator
        def wrapper(wrapped, instance, args, kwargs):
            base_name = _utils.get_class_name(wrapped, fully_qualified=False)
            if fully_qualified:
                old_name = old_attribute_name
            else:
                old_name = ".".join((base_name, old_attribute_name))
            new_name = ".".join((base_name, new_attribute_name))
            prefix = _KIND_MOVED_PREFIX_TPL % (kind, old_name, new_name)
            out_message = _utils.generate_message(
                prefix, message=message,
                version=version, removal_version=removal_version)
            _utils.deprecation(out_message, stacklevel=stacklevel,