Ejemplo n.º 1
0
    def __init__(self, fh):
        (shema_type,
         reserved,
         self.file_position,
         file_part,  # reserved
         content_guid,
         content_file_type,
         name
         ) = struct.unpack('<2s10sqi16s8s80s', fh.read(128))

        if shema_type != b'A1':
            raise ValueError("not a AttachmentEntryA1")
        self.content_guid = uuid.UUID(bytes=content_guid)
        self.content_file_type = stripnull(content_file_type)
        self.name = unicode(stripnull(name), 'utf-8')
        self._fh = fh
Ejemplo n.º 2
0
 def __init__(self, fh):
     (size,
      self.time,
      self.event_type,
      description_size,
      ) = struct.unpack('<idii', fh.read(20))
     description = stripnull(fh.read(description_size))
     self.description = unicode(description, 'utf-8')
Ejemplo n.º 3
0
 def __init__(self, fh):
     (self.dimension,
      self.start,
      self.size,
      self.start_coordinate,
      stored_size
      ) = struct.unpack('<4siifi', fh.read(20))
     self.dimension = stripnull(self.dimension)
     self.stored_size = stored_size if stored_size else self.size
Ejemplo n.º 4
0
 def __init__(self, fh, fpos=None):
     """Read segment header from file."""
     if fpos is not None:
         fh.seek(fpos)
     try:
         (self.sid, self.allocated_size,
          self.used_size) = struct.unpack('<16sqq', fh.read(32))
     except struct.error:
         raise SegmentNotFoundError("can not read ZISRAW segment")
     self.sid = stripnull(self.sid)
     if self.sid not in SEGMENT_ID:
         if not self.sid.startswith(b'ZISRAW'):
             raise SegmentNotFoundError("not a ZISRAW segment")
         warnings.warn("unknown segment type %s" % self.sid)
     self.data_offset = fh.tell()
     self._fh = fh
Ejemplo n.º 5
0
def xml_reader(fh, filesize):
    """Read XML from file and return as xml.ElementTree root Element."""
    xml = unicode(stripnull(fh.read(filesize)), 'utf-8')
    return etree.fromstring(xml)
Ejemplo n.º 6
0
 def __init__(self, fh):
     size, identifier, number = struct.unpack('<i80si', fh.read(88))
     self.identifier = unicode(stripnull(identifier), 'utf-8')
     self.components = [ComponentEntry(fh) for _ in range(number)]