Ejemplo n.º 1
0
def superInterfaces(interface):
    """Given an interface, return list of super-interfaces (including itself)."""
    result = [interface]
    result.extend(allYourBase(interface, Interface))
    result = uniquify(result)
    result.remove(Interface)
    return result
Ejemplo n.º 2
0
def superInterfaces(interface):
    """Given an interface, return list of super-interfaces (including itself)."""
    result = [interface]
    result.extend(allYourBase(interface, Interface))
    result = uniquify(result)
    result.remove(Interface)
    return result
Ejemplo n.º 3
0
def getInterfaces(obj, attr='__implements__'):
    """Return list of all interfaces an object implements, using a particular
    attribute name.  For example, if you wish to discover what interfaces a
    class implements directly, pass '__class_implements__' as the attribute
    name.
    """
    if getattr(obj, attr, None) is None:
        return []

    result = []
    L = getattr(obj, attr, ())
    if type(L) is not Flat:
        L = tupleTreeToList(L)
        setattr(obj, attr, L)
    for i in L:
        if i not in result:
            result.append(i)
        result.extend(allYourBase(i, Interface))
    if Interface in result:
        result.remove(Interface)
    return result
Ejemplo n.º 4
0
def getInterfaces(obj, attr='__implements__'):
    """Return list of all interfaces an object implements, using a particular
    attribute name.  For example, if you wish to discover what interfaces a
    class implements directly, pass '__class_implements__' as the attribute
    name.
    """
    if getattr(obj, attr, None) is None:
        return []

    result = []
    L = getattr(obj, attr, ())
    if type(L) is not Flat:
        L = tupleTreeToList(L)
        setattr(obj, attr, L)
    for i in L:
        if i not in result:
            result.append(i)
        result.extend(allYourBase(i, Interface))
    if Interface in result:
        result.remove(Interface)
    return result