def __init__(self, f, cacheSize, schema, offset=0, offsetToFooter=0): FSD_Index.__init__(self, f, cacheSize, schema, offset, offsetToFooter) f.seek(offset + self.fileSize - self.footerSize) attributeLookupTableSize = _uint32(f.read(4)) f.seek(-(4 + attributeLookupTableSize), os.SEEK_CUR) attributeLookupTable = f.read(attributeLookupTableSize) # create the subindices subindices = {} for index, offsetAndSize in load( attributeLookupTable, 0, schema['subIndexOffsetLookup']).iteritems(): f.seek(offset + 4 + offsetAndSize.offset) offsetTable = pyFSD.FsdUnsignedIntegerKeyMap() offsetTable.Initialize(f.read(offsetAndSize.size), 0, True, False, offset + 8) subindices[index] = _subindex( f, offsetTable, schema['indexableSchemas'][index]['valueTypes']) # assign either indexgroup or subindex to relevant attributes. for indexName, indices in schema['indexNameToIds'].iteritems(): index = _indexgroup( map(subindices.__getitem__, indices)) if len(indices) > 1 else subindices[indices[0]] setattr(self, indexName, index) self._indices = schema['indexNameToIds'].keys()
def __init__(self, f, cacheSize, schema, offset=0, offsetToFooter=0): self.file = f self.cacheSize = cacheSize self.offset = offset = offset + 4 if offset else 0 self.index = {} self.header = schema['header'] # read the footer blob and put it in an appropriate container f.seek(offset) self.fileSize = _uint32(f.read(4)) f.seek(offset + self.fileSize) footerSize = self.footerSize = _uint32(f.read(4)) f.seek(-(4 + footerSize), os.SEEK_CUR) if schema['keyTypes']['type'] == 'int': self.footer = pyFSD.FsdUnsignedIntegerKeyMap() self.footer.Initialize(f.read(footerSize)) else: self.footer = _DictFooter(f.read(footerSize), 0, schema['keyFooter']) self.cache = collections.OrderedDict() s = self.valueSchema = schema['valueTypes'] self._load = s['loader'] if (s.get('buildIndex', False)) and (s['type'] == 'dict'): self._getitem = self.__GetIndex__ else: self._getitem = self.__GetItem__
def CreateDictFooter(schema, binaryFooterData, path, extraState): keyType = schema['keyTypes']['type'] if hasPyFSD and keyType == 'int': keyMap = pyFSD.FsdUnsignedIntegerKeyMap() keyMap.Initialize(binaryFooterData) return CppFsdIntegerKeyMapWrapper(keyMap) else: return CreatePythonDictOffset(schema, binaryFooterData, path, extraState)
def __init__(self, data, offset, schema): self.data = data self.offset = offset + 4 endOfFooter = offset + _uint32(data, offset) footerOffset = endOfFooter - _uint32(data, endOfFooter) self.schema = schema if schema['keyTypes']['type'] in 'int': hassize = ('size' in schema['keyFooter']['itemTypes']['attributes'] ) if ('keyFooter' in schema) else True self.footer = pyFSD.FsdUnsignedIntegerKeyMap() self.footer.Initialize(data, footerOffset, hassize, True) else: self.footer = _DictFooter(data, footerOffset, schema['keyFooter']) self.valueSchema = schema['valueTypes'] self.loader = self.valueSchema['loader'] self.header = schema['header'] self.index = {}
def FsdUnsignedIntegerKeyMapLoadData(): keyMap = pyFSD.FsdUnsignedIntegerKeyMap() keyMap.Initialize(offsetTableString) return dictLoader.CppFsdIntegerKeyMapWrapper(keyMap)