def getHashInfo(self, intPath): ''' Get the info-dict for internal item `intPath` ''' if intPath not in self.hashedFiles: fp = self.open(intPath) cont = fp.read() ret = hf.getHashDict(intPath, cont) ret['cont'] = cont ret['type'] = fix_mime(magic.from_buffer(cont, mime=True)) self.hashedFiles[intPath] = ret return self.hashedFiles[intPath]
def getHashInfo(self, intPath): """ Get the info-dict for internal item `intPath` """ if intPath not in self.hashedFiles: fp = self.open(intPath) cont = fp.read() ret = hf.getHashDict(intPath, cont) ret["cont"] = cont ret["type"] = magic.from_buffer(cont) self.hashedFiles[intPath] = ret return self.hashedFiles[intPath]
def iterHashes(self): ''' Iterate over all the files in the archive, and yield 2-tuples containing the internal-path and the internal-item-data as a dict ''' items = list(self.getFileList()) items.sort() for item in items: if item not in self.hashedFiles: fp = self.open(item) cont = fp.read() ret = hf.getHashDict(item, cont) ret['cont'] = cont ret['type'] = fix_mime(magic.from_buffer(cont, mime=True)) self.hashedFiles[item] = ret yield item, self.hashedFiles[item]
def iterHashes(self): """ Iterate over all the files in the archive, and yield 2-tuples containing the internal-path and the internal-item-data as a dict """ items = list(self.getFileList()) items.sort() for item in items: if item not in self.hashedFiles: fp = self.open(item) cont = fp.read() ret = hf.getHashDict(item, cont) ret["cont"] = cont ret["type"] = magic.from_buffer(cont) self.hashedFiles[item] = ret yield item, self.hashedFiles[item]