Commit 38418c290e3655ed70cc9bb5ad56a96cf446d114

Authored by Christian Herdtweck
1 parent e90e0e5a

record_base: rename parse --> finish_constructing, more docu

Showing 1 changed file with 13 additions and 3 deletions
oletools/record_base.py
... ... @@ -258,15 +258,25 @@ class OleRecordBase(object):
258 258 self.size = size
259 259 self.pos = pos
260 260 self.data = data
261   - self.parse(more_data)
  261 + self.finish_constructing(more_data)
262 262  
263   - def parse(self, more_data):
  263 + def finish_constructing(self, more_data):
264 264 """ finish constructing this record
265 265  
266 266 Can save more_data from OleRecordStream.read_record_head and/or parse
267 267 data (if it was read).
268 268  
269 269 Base implementation, does nothing. To be overwritten in subclasses.
  270 +
  271 + Implementations should take into account that self.data may be None.
  272 + Should create the same attributes, whether data is present or not. Eg::
  273 +
  274 + def finish_constructing(self, more_data):
  275 + self.more = more_data
  276 + self.attr1 = None
  277 + self.attr2 = None
  278 + if self.data:
  279 + self.attr1, self.attr2 = struct.unpack('<HH', self.data)
270 280 """
271 281 pass
272 282  
... ... @@ -324,7 +334,7 @@ def test(filenames, ole_file_class=OleRecordFile,
324 334 logging.info(' parse ' + str(stream))
325 335 try:
326 336 for record in stream.iter_records():
327   - logging.info(' found ' + str(record))
  337 + logging.info(' ' + str(record))
328 338 do_per_record(record)
329 339 except Exception:
330 340 if not must_parse:
... ...