Esempio n. 1
0
class ZipHandler(object):
    def __init__(self, path):
        self.path = path
        self.zip = ZipFile(self.path, "r")

    def list_files(self, sub_path):
        if sub_path:
            return
        return self.zip.namelist()
        # for name in self.zip.namelist():
        #     #if name.endswith(str("/")):
        #     #if name.endswith("/"):
        #     #    continue
        #     #yield self.decode_name(name)
        #     yield name

    def open(self, name):
        return self.zip.open(name)

    def exists(self, name):
        try:
            self.zip.getinfo(name)
        except KeyError:
            return False
        else:
            return True
class ZipHandler(object):
    def __init__(self, path):
        self.path = path
        self.zip = ZipFile(self.path, "r")

    def exists(self, name):
        try:
            self.zip.getinfo(name)
        except KeyError:
            return False
        else:
            return True

    def getinfo(self, name):
        # Needs tests!!
        return self.zip.getinfo(name)

    def infolist(self):
        return self.zip.infolist()

    def list_files(self, sub_path):
        if sub_path:
            return
        return self.zip.namelist()

    def open(self, name):
        return self.zip.open(name)
Esempio n. 3
0
class ZipHandler(object):
    def __init__(self, path):
        self.path = path
        self.zip = ZipFile(self.path, "r")

    def list_files(self, sub_path):
        if sub_path:
            return
        return self.zip.namelist()
        # for name in self.zip.namelist():
        #     #if name.endswith(str("/")):
        #     #if name.endswith("/"):
        #     #    continue
        #     #yield self.decode_name(name)
        #     yield name

    def open(self, name):
        return self.zip.open(name)

    def exists(self, name):
        try:
            self.zip.getinfo(name)
        except KeyError:
            return False
        else:
            return True