Commit a93b21091c44b599da919d325f730d155ba8f843

Authored by Christian Herdtweck
1 parent faeb2aed

record_base: simplify bugfixing by offering more verbosity

Showing 1 changed file with 7 additions and 2 deletions
oletools/record_base.py
... ... @@ -74,6 +74,7 @@ except ImportError:
74 74 # Helpers
75 75 ###############################################################################
76 76  
  77 +OleFileIO = olefile.OleFileIO
77 78 STGTY_EMPTY = olefile.STGTY_EMPTY # 0
78 79 STGTY_STORAGE = olefile.STGTY_STORAGE # 1
79 80 STGTY_STREAM = olefile.STGTY_STREAM # 2
... ... @@ -92,6 +93,10 @@ ENTRY_TYPE2STR = {
92 93 STGTY_SUBSTREAM: 'substream'
93 94 }
94 95  
  96 +def enable_olefile_logging():
  97 + """ enable logging olefile e.g., to get debug info from OleFileIO """
  98 + olefile.enable_logging()
  99 +
95 100  
96 101 ###############################################################################
97 102 # Base Classes
... ... @@ -321,13 +326,13 @@ class OleRecordBase(object):
321 326  
322 327  
323 328 def test(filenames, ole_file_class=OleRecordFile,
324   - must_parse=None, do_per_record=None):
  329 + must_parse=None, do_per_record=None, verbose=False):
325 330 """ parse all given file names and print rough structure
326 331  
327 332 if an error occurs while parsing a stream of type in must_parse, the error
328 333 will be raised. Otherwise a message is printed
329 334 """
330   - logging.basicConfig(level=logging.INFO)
  335 + logging.basicConfig(level=logging.DEBUG if verbose else logging.INFO)
331 336 if do_per_record is None:
332 337 def do_per_record(record):
333 338 pass # do nothing
... ...