Exemple #1
0
def _default(mro, get_default):
    """Apply default rule to list of classes in mro.
    """
    error = None
    for base in mro:
        module_of_base = scan.resolve(base.__module__)
        try:
            if util.is_baseclass(base):
                break
            result = get_default(base, module_of_base)
        except UnknownError, e:
            # store error if this is the first UnknownError we ran into
            if error is None:
                error = e
            result = UNKNOWN
        if result is not UNKNOWN:
            return result
Exemple #2
0
    def grokkers(self, name, module):
        grokker = self._grokker
        # get any global grokkers
        for t in grokker.grokkers(name, module):
            yield t

        # try to grok everything in module
        for name in dir(module):
            if '.' in name:
                # This must be a module-level variable that couldn't
                # have been set by the developer.  It must have been a
                # module-level directive.
                continue
            obj = getattr(module, name)
            if not util.defined_locally(obj, module.__name__):
                continue
            if util.is_baseclass(obj):
                continue
            for t in grokker.grokkers(name, obj):
                yield t
Exemple #3
0
    def grokkers(self, name, module):
        grokker = self._grokker
        # get any global grokkers
        for t in grokker.grokkers(name, module):
            yield t

        # try to grok everything in module
        for name in dir(module):
            if '.' in name:
                # This must be a module-level variable that couldn't
                # have been set by the developer.  It must have been a
                # module-level directive.
                continue
            obj = getattr(module, name)
            if not util.defined_locally(obj, module.__name__):
                continue
            if util.is_baseclass(name, obj):
                continue
            for t in grokker.grokkers(name, obj):
                yield t
Exemple #4
0
def _default(mro, get_default):
    """Apply default rule to list of classes in mro.
    """
    error = None
    for base in mro:
        module_of_base = scan.resolve(base.__module__)
        try:
            if util.is_baseclass(base):
                break
            result = get_default(base, module_of_base)
        except UnknownError as e:
            # store error if this is the first UnknownError we ran into
            if error is None:
                error = e
            result = UNKNOWN
        if result is not UNKNOWN:
            return result
    # if we haven't found a result, raise the first error we had as
    # a GrokError
    if error is not None:
        raise GrokError(compat3.str(error), error.component)
    return UNKNOWN
Exemple #5
0
def _default(mro, get_default):
    """Apply default rule to list of classes in mro.
    """
    error = None
    for base in mro:
        module_of_base = scan.resolve(base.__module__)
        try:
            if util.is_baseclass(base):
                break
            result = get_default(base, module_of_base)
        except UnknownError as e:
            # store error if this is the first UnknownError we ran into
            if error is None:
                error = e
            result = UNKNOWN
        if result is not UNKNOWN:
            return result
    # if we haven't found a result, raise the first error we had as
    # a GrokError
    if error is not None:
        raise GrokError(compat3.str(error), error.component)
    return UNKNOWN