Exemplo n.º 1
0
def superInterfaces(interface):
    """DEPRECATED. Given an interface, return list of super-interfaces (including itself)."""
    warnings.warn("Please use zope.interface APIs", ComponentsDeprecationWarning, stacklevel=2)
    result = [interface]
    result.extend(reflect.allYourBase(interface, Interface))
    result = util.uniquify(result)
    if Interface in result:
        result.remove(Interface)
    return result
Exemplo n.º 2
0
def getAllBases(inClass):
    """Get all super-classes of a given class.

    Recursively determine the entire hierarchy above a certain class, and
    return it as a list.
    """
    classes = list(inClass.__bases__)
    for base in inClass.__bases__:
        classes.extend(getAllBases(base))
    return util.uniquify(classes)
Exemplo n.º 3
0
Arquivo: coil.py Projeto: lhl/songclub
def getAllBases(inClass):
    """Get all super-classes of a given class.

    Recursively determine the entire hierarchy above a certain class, and
    return it as a list.
    """
    classes = list(inClass.__bases__)
    for base in inClass.__bases__:
        classes.extend(getAllBases(base))
    return util.uniquify(classes)
Exemplo n.º 4
0
def getInterfaces(klass):
    """DEPRECATED. Return list of all interfaces the class implements. Or the object provides.
    This is horrible and stupid. Please use zope.interface.providedBy() or implementedBy().
    """
    warnings.warn("getInterfaces should not be used, use providedBy() or implementedBy()", ComponentsDeprecationWarning, stacklevel=2)
    if isinstance(klass, (type, types.ClassType)):
        fixClassImplements(klass)
        l = list(declarations.implementedBy(klass))
    else:
        fixClassImplements(klass.__class__)
        l = list(declarations.providedBy(klass))
    r = []
    for i in l:
        r.extend(superInterfaces(i))
    return util.uniquify(r)
Exemplo n.º 5
0
def getInterfaces(klass):
    """DEPRECATED. Return list of all interfaces the class implements. Or the object provides.

    This is horrible and stupid. Please use zope.interface.providedBy() or implementedBy().
    """
    warnings.warn("getInterfaces should not be used, use providedBy() or implementedBy()", ComponentsDeprecationWarning, stacklevel=2)
    # try to support both classes and instances, giving different behaviour
    # which is HORRIBLE :(
    if isinstance(klass, (type, types.ClassType)):
        fixClassImplements(klass)
        l = list(declarations.implementedBy(klass))
    else:
        fixClassImplements(klass.__class__)
        l = list(declarations.providedBy(klass))
    r = []
    for i in l:
        r.extend(superInterfaces(i))
    return util.uniquify(r)
 def testUniq(self):
     l = ["a", 1, "ab", "a", 3, 4, 1, 2, 2, 4, 6]
     self.assertEqual(util.uniquify(l), ["a", 1, "ab", 3, 4, 2, 6])
Exemplo n.º 7
0
 def testUniq(self):
     l = ["a", 1, "ab", "a", 3, 4, 1, 2, 2, 4, 6]
     self.assertEquals(util.uniquify(l), ["a", 1, "ab", 3, 4, 2, 6])
Exemplo n.º 8
0
 def testUniq(self):
     listWithDupes = ["a", 1, "ab", "a", 3, 4, 1, 2, 2, 4, 6]
     self.assertEqual(util.uniquify(listWithDupes),
                      ["a", 1, "ab", 3, 4, 2, 6])