コード例 #1
0
ファイル: components.py プロジェクト: UstadMobile/eXePUB
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
コード例 #2
0
ファイル: coil.py プロジェクト: katrinleinweber/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)
コード例 #3
0
ファイル: coil.py プロジェクト: 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)
コード例 #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)
コード例 #5
0
ファイル: components.py プロジェクト: UstadMobile/eXePUB
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)
コード例 #6
0
 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])
コード例 #7
0
ファイル: test_util.py プロジェクト: P13RR3/FrostCore
 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])
コード例 #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])