(method)
return _check_name_wrapper
Decorator to verify that the module being requested matches the one the
    loader can handle.

    The first argument (self) must define _name which the second argument is
    compared against. If the comparison fails then ImportError is raised.
Decorator to verify that the module being requested matches the one the
    loader can handle.
Decorator to verify that the module being requested matches the one the loader can handle .
def _check_name(method):
    """Decorator to verify that the module being requested matches the one the
    loader can handle.

    The first argument (self) must define _name which the second argument is
    compared against. If the comparison fails then ImportError is raised.

    """
    def _check_name_wrapper(self, name=None, *args, **kwargs):
        if name is None:
            name = self.name
        elif self.name != name:
            raise ImportError('loader for %s cannot handle %s' %
                                (self.name, name), name=name)
        return method(self, name, *args, **kwargs)

    # FIXME: @_check_name is used to define class methods before the
    # _bootstrap module is set by _set_bootstrap_module().
    if _bootstrap is not None:
        _wrap = _bootstrap._wrap
    else:
        def _wrap(new, old):
            for replace in ['__module__', '__name__', '__qualname__', '__doc__']:
                if hasattr(old, replace):
                    setattr(new, replace, getattr(old, replace))
            new.__dict__.update(old.__dict__)

    _wrap(_check_name_wrapper, method)
    return _check_name_wrapper
def _check_name ( method ) : def _check_name_wrapper ( self , name = None , * args , * * kwargs ) : if name is None : name = self . name elif self . name != name : raise ImportError ( 'loader for %s cannot handle %s' % ( self . name , name ) , name = name ) return method ( self , name , * args , * * kwargs ) # FIXME: @_check_name is used to define class methods before the # _bootstrap module is set by _set_bootstrap_module(). if _bootstrap is not None : _wrap = _bootstrap . _wrap else : def _wrap ( new , old ) : for replace in [ '__module__' , '__name__' , '__qualname__' , '__doc__' ] : if hasattr ( old , replace ) : setattr ( new , replace , getattr ( old , replace ) ) new . __dict__ . update ( old . __dict__ ) _wrap ( _check_name_wrapper , method ) return _check_name_wrapper