def update(self): size = self.get_childs_size() sz = utils.py_int2dword(size, self.config.rifx) self.update_cpng() compr_sz = len(self.data['cpng']) compr_sz += 1 if compr_sz > (compr_sz // 2) * 2 else 0 compr_sz = utils.py_int2dword(compr_sz + 12, self.config.rifx) self.chunk = self.data['identifier'] + compr_sz + sz + self.chunk[12:20] self.chunk += self.data['cpng'] self.chunk += '\x00' if self.is_padding() else ''
def update_for_save(self): for child in self.childs: child.update_for_save() self.chunk = '' self.chunk += cpl_const.CPL12 self.chunk += cpl_const.CPL12_NHEADERS size = len(self.name) * 2 pos = [30, 31 + size, 31 + size + 2] for i in range(3): self.chunk += utils.py_int2dword(i) + utils.py_int2dword(pos[i]) self.chunk += utils.py_int2byte(len(self.name)) self.chunk += self.name.encode('utf_16_le') self.chunk += cpl_const.CPL12_PALTYPE self.chunk += utils.py_int2word(len(self.childs))
def parse_compressed_list(self, stream, identifier, blocksizes): rawsize = dword2py_int(stream.read(4)) list_identifier = stream.read(4) print list_identifier size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1: size += 1 offset = stream.tell() obj = model.RiffList(identifier + size_field + list_identifier) while stream.tell() <= offset + size - 8: ret = self.parse_comressed_stream(stream, blocksizes) if ret is None: stream.seek(offset) chunk = stream.read(size - 4) return model.RiffUnparsedList(identifier + size_field + \ list_identifier + chunk) else: obj.childs.append(ret) return obj
def parse_compressed_list(self, stream, identifier, blocksizes): rawsize = dword2py_int(stream.read(4)) list_identifier = stream.read(4) print list_identifier size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1:size += 1 offset = stream.tell() obj = model.RiffList(identifier + size_field + list_identifier) while stream.tell() <= offset + size - 8: ret = self.parse_comressed_stream(stream, blocksizes) if ret is None: stream.seek(offset) chunk = stream.read(size - 4) return model.RiffUnparsedList(identifier + size_field + \ list_identifier + chunk) else: obj.childs.append(ret) return obj
def update(self): rifx = self.config.rifx pos = self.get_offset() jump = self.data['jump'] = len(self.chunk) + pos data = self.chunk[8:] self.chunk = '\x08\x00\x6f\x00' self.chunk += utils.py_int2dword(jump, rifx) + data
def parse_compressed_object(self, stream, identifier, blocksizes): if not identifier[:3].isalnum(): return None rawsize = dword2py_int(stream.read(4)) size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1: size += 1 chunk = stream.read(size) return model.RiffObject(identifier + size_field + chunk)
def parse_compressed_object(self, stream, identifier, blocksizes): if not identifier[:3].isalnum(): return None rawsize = dword2py_int(stream.read(4)) size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1:size += 1 chunk = stream.read(size) return model.RiffObject(identifier + size_field + chunk)
def update(self): rifx = self.config.rifx self.chunk = self.data['identifier'] + 4 * '\x00' sz = len(self.data['records']) self.chunk += '\x01\x00\x18\x00' self.chunk += utils.py_int2word(sz, rifx) for rec_id, offset in self.data['records']: self.chunk += utils.py_int2word(rec_id, rifx) self.chunk += utils.py_int2dword(offset, rifx) CmxRiffElement.update(self)
def update(self): rifx = self.config.rifx self.chunk = self.data['identifier'] + 4 * '\x00' sz = len(self.data['layers']) self.chunk += utils.py_int2word(sz, rifx) self.chunk += utils.py_int2word(self.data['page'], rifx) for offset, name in self.data['layers']: self.chunk += utils.py_int2dword(offset, rifx) self.chunk += utils.py_int2word(len(name), rifx) self.chunk += name + 4 * '\xff' CmxRiffElement.update(self)
def parse_compressed_object(self, stream, identifier, blocksizes): if not identifier[:3].isalnum(): return None rawsize = dword2py_int(stream.read(4)) size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1: size += 1 chunk = stream.read(size) self.report_stream_position(stream.tell()) class_ = self.get_class(identifier) return class_(identifier + size_field + chunk)
def parse_compressed_object(self, stream, identifier, blocksizes): if not identifier[:3].isalnum(): return None rawsize = dword2py_int(stream.read(4)) size = blocksizes[rawsize] size_field = py_int2dword(size) if size & 1:size += 1 chunk = stream.read(size) self.report_stream_position(stream.tell()) class_ = self.get_class(identifier) return class_(identifier + size_field + chunk)
def update(self): rifx = self.config.rifx self.chunk = self.data['identifier'] + 4 * '\x00' padding_sz = 32 - len(self.data['file_id']) self.chunk += self.data['file_id'] + padding_sz * '\x00' padding_sz = 16 - len(self.data['os_type']) self.chunk += self.data['os_type'] + padding_sz * '\x00' self.chunk += self.data['byte_order'] self.chunk += self.data['coord_size'] self.chunk += self.data['major'] self.chunk += self.data['minor'] self.chunk += self.data['unit'] self.chunk += self.data['factor'] self.chunk += 12 * '\x00' self.chunk += utils.py_int2dword(self.data['IndexSection'], rifx) self.chunk += utils.py_int2dword(self.data['InfoSection'], rifx) self.chunk += utils.py_int2dword(self.data['Thumbnail'], rifx) sig = '>iiii' if rifx else '<iiii' self.chunk += struct.pack(sig, *self.data['bbox']) self.chunk += utils.py_int2dword(self.data['tally'], rifx) self.chunk += 64 * '\x00' CmxRiffElement.update(self)
def __init__(self, chunk=''): if not chunk: chunk = 'RIFF' + py_int2dword(4) + 'riff' RiffList.__init__(self, chunk) self.version = self.chunk_tag
def update(self): size = self.get_chunk_size() - 8 sz = utils.py_int2dword(size, self.config.rifx) self.chunk = self.data['identifier'] + sz + self.chunk[8:] if self.is_leaf() and self.is_padding(): self.chunk += '\x00'