Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, fh):
size, identifier, number = struct.unpack('
def __init__(self, fh):
(size,
self.time,
self.event_type,
description_size,
) = struct.unpack('
def __init__(self, fh):
size, identifier, number = struct.unpack('
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
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
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
def data_segment(self):
"""Read and return SubBlockSegment at file_position."""
# return Segment(self._fh, self.file_position).data()
fh = self._fh
with fh.lock:
fh.seek(self.file_position)
try:
sid, _, _ = struct.unpack('<16sqq', fh.read(32))
except struct.error:
raise SegmentNotFoundError("can not read ZISRAW segment")
sid = stripnull(sid)
if sid not in SEGMENT_ID:
raise SegmentNotFoundError("not a ZISRAW segment")
data_segment = SEGMENT_ID[sid](fh)
return data_segment
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
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)
def __init__(self, fh):
(size,
self.time,
self.event_type,
description_size,
) = struct.unpack('