Returns a dictionary representation of the structure.
(self)
| 1108 | return dump |
| 1109 | |
| 1110 | def dump_dict(self): |
| 1111 | """Returns a dictionary representation of the structure.""" |
| 1112 | |
| 1113 | dump_dict = {} |
| 1114 | |
| 1115 | dump_dict["Structure"] = self.name |
| 1116 | |
| 1117 | # Refer to the __set_format__ method for an explanation |
| 1118 | # of the following construct. |
| 1119 | for keys in self.__keys__: |
| 1120 | for key in keys: |
| 1121 | |
| 1122 | val = getattr(self, key) |
| 1123 | if isinstance(val, (int, long)): |
| 1124 | if key == "TimeDateStamp" or key == "dwTimeStamp": |
| 1125 | try: |
| 1126 | val = "0x%-8X [%s UTC]" % ( |
| 1127 | val, |
| 1128 | time.asctime(time.gmtime(val)), |
| 1129 | ) |
| 1130 | except ValueError: |
| 1131 | val = "0x%-8X [INVALID TIME]" % val |
| 1132 | else: |
| 1133 | val = "".join( |
| 1134 | chr(d) if chr(d) in string.printable else "\\x%02x" % d |
| 1135 | for d in [ord(c) if not isinstance(c, int) else c for c in val] |
| 1136 | ) |
| 1137 | |
| 1138 | dump_dict[key] = { |
| 1139 | "FileOffset": self.__field_offsets__[key] + self.__file_offset__, |
| 1140 | "Offset": self.__field_offsets__[key], |
| 1141 | "Value": val, |
| 1142 | } |
| 1143 | |
| 1144 | return dump_dict |
| 1145 | |
| 1146 | |
| 1147 | class SectionStructure(Structure): |
nothing calls this directly
no outgoing calls
no test coverage detected