Example #1
0
class RarWrapper(object):
    '''
    ArchiveWrapper for rarfiles
    '''

    ImplementsInterface(IArchiveWrapper)

    def __init__(self, filename):
        from ._rarfile import Rarfile
        self.wrapped = Rarfile().CreateRarFile(filename)

    def ListFilenames(self):
        from ben10.filesystem import StandardizePath

        return [
            StandardizePath(i) for i in self.wrapped.namelist()
            if not i.endswith('/')
        ]

    def ListDirs(self):
        result = []
        for i in self.ListFilenames():
            if self.wrapped.getinfo(i).isdir():
                result.append(i)
            else:
                result.append(os.path.dirname(i))
        return sorted(result)

    def ReadFile(self, filename):
        return self.wrapped.read(filename)
Example #2
0
class ZipWrapper(object):
    '''
    ArchiveWrapper for zipfiles
    '''

    ImplementsInterface(IArchiveWrapper)

    def __init__(self, filename):
        import zipfile
        self.wrapped = zipfile.ZipFile(filename)

    @Implements(IArchiveWrapper.ListFilenames)
    def ListFilenames(self):
        from ben10.filesystem import StandardizePath

        return [
            StandardizePath(i) for i in self.wrapped.namelist()
            if not i.endswith('/')
        ]

    @Implements(IArchiveWrapper.ListDirs)
    def ListDirs(self):
        result = set()
        for i in self.wrapped.namelist():
            if i.endswith('/'):
                result.add(i[:-1])
            else:
                result.add(os.path.dirname(i))
        return sorted(result)

    @Implements(IArchiveWrapper.ReadFile)
    def ReadFile(self, filename):
        return self.wrapped.read(filename)
Example #3
0
        class C(object):
            ImplementsInterface(_InterfM4)

            def m4(self):
                ''

            def m3(self, arg1, arg2):
                ''
Example #4
0
        class C(object):
            ImplementsInterface(I)

            def foo(self, a, b=None):
                ''

            def bar(self):
                ''
Example #5
0
        class My(object):
            ImplementsInterface(_InterfM1)

            def m1(self):
                return 'm1'

            def m2(self):
                ''
Example #6
0
        class A(object):
            ImplementsInterface(InterfSetItem)

            def __setitem__(self, id, subject):
                self.set = (id, subject)

            def __getitem__(self, id):
                return self.set
Example #7
0
        class Zoo(object):
            ImplementsInterface(IZoo)

            def __init__(self, value):
                self.zoo = value
Example #8
0
        class B(object):
            ImplementsInterface(_InterfM1)

            def m1(self):
                ''
Example #9
0
        class A(object):
            ImplementsInterface(IAdaptable)

            def GetAdapter(self, interface_class):
                if interface_class == _InterfM1:
                    return B()
Example #10
0
 class Zoo(object):
     ImplementsInterface(IZoo)
Example #11
0
        class C2B(object):
            ImplementsInterface(I2)

            def M2(self):
                ''
Example #12
0
        class My3(object):
            ImplementsInterface(_InterfM3)

            def m3(self, arg1, arg2):
                ''
Example #13
0
        class My2(object):
            ImplementsInterface(_InterfM2)

            def m2(self):
                ''
Example #14
0
 class NoCheck(object):
     ImplementsInterface(_InterfM1, no_init_check=True)
Example #15
0
 class Old2:
     ImplementsInterface(_InterfM1,
                         old_style=True)  # but do not really implements
Example #16
0
        class Old:
            ImplementsInterface(_InterfM1, old_style=True)

            def m1(self):
                ''
Example #17
0
        class FlawedZoo(object):
            ImplementsInterface(IZoo)

            def __init__(self, value):
                ''
Example #18
0
        class Bar(object):
            ImplementsInterface(IBar)

            def something(self, stuff):
                ''
Example #19
0
            class Foo(object):
                ImplementsInterface(I1)
                ImplementsInterface(I2)

                def Method2(self):
                    ''
Example #20
0
        class C(object):
            ImplementsInterface(I)

            def foo(self):
                ''
Example #21
0
        class Foo(object):
            ImplementsInterface(IFoo)

            def __call__(self, bar):
                ''
Example #22
0
        class D(C):
            ImplementsInterface(I2)

            def bar(self):
                ''
Example #23
0
 class C(object):
     ImplementsInterface(I)
Example #24
0
        class B(A):
            ImplementsInterface(_InterfM2)

            def m2(self):
                ''