def __init__(self, path, *args, **kwargs):
cls = self.__class__
super(cls, self).__init__(path, *args, **kwargs)
while True:
sess = PeektaggedSectionHeader(self.fh)
if sess.tag == 'pkts':
break
sess.payload = self.fh.read(sess.len)
if sess.tag == PEEKTAGGED_FILE_MAGIC:
root = ET.fromstring(sess.payload)
if root.tag != 'VersionInfo':
raise PeektaggedException("Corrupted version info")
for child in root:
setattr(self, child.tag, child.text)
elif sess.tag == 'sess':
root = ET.fromstring(sess.payload)
for child in root:
if child.tag == 'PacketCount':
setattr(self, 'total_packets', int(child.text))
break
评论列表
文章目录