def dump_dict(self):
"""Returns a dictionary representation of the structure."""
dump_dict = dict()
dump_dict['Structure'] = self.name
# Refer to the __set_format__ method for an explanation
# of the following construct.
for keys in self.__keys__:
for key in keys:
val = getattr(self, key)
if isinstance(val, (int, long)):
if key == 'TimeDateStamp' or key == 'dwTimeStamp':
try:
val = '0x%-8X [%s UTC]' % (val, time.asctime(time.gmtime(val)))
except exceptions.ValueError as e:
val = '0x%-8X [INVALID TIME]' % val
else:
val = b([b for b in val if b != 0])
dump_dict[key] = {'FileOffset': self.__field_offsets__[key] + self.__file_offset__,
'Offset': self.__field_offsets__[key],
'Value': val}
return dump_dict
评论列表
文章目录