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 list_files(self, sub_path): if sub_path: return return self.zip.namelist() 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
def __init__(self, path): self.path = path self.zip = ZipFile(self.path, "r")