Commit 1667805a6ddf56b4c2b9f761bfb6aa2062c678e9
1 parent
38a06ad5
ppt_record_parser: comment too much debug log
Showing
1 changed file
with
27 additions
and
25 deletions
oletools/ppt_record_parser.py
| @@ -298,7 +298,8 @@ class PptContainerRecord(PptRecord): | @@ -298,7 +298,8 @@ class PptContainerRecord(PptRecord): | ||
| 298 | if not self.data: | 298 | if not self.data: |
| 299 | return | 299 | return |
| 300 | 300 | ||
| 301 | - logging.debug('parsing contents of container record {0}'.format(self)) | 301 | + # logging.debug('parsing contents of container record {0}' |
| 302 | + # .format(self)) | ||
| 302 | 303 | ||
| 303 | # create a stream from self.data and parse it like any other | 304 | # create a stream from self.data and parse it like any other |
| 304 | data_stream = io.BytesIO(self.data) | 305 | data_stream = io.BytesIO(self.data) |
| @@ -306,8 +307,8 @@ class PptContainerRecord(PptRecord): | @@ -306,8 +307,8 @@ class PptContainerRecord(PptRecord): | ||
| 306 | 'PptContainerRecordSubstream', | 307 | 'PptContainerRecordSubstream', |
| 307 | record_base.STGTY_SUBSTREAM) | 308 | record_base.STGTY_SUBSTREAM) |
| 308 | self.records = list(record_stream.iter_records()) | 309 | self.records = list(record_stream.iter_records()) |
| 309 | - logging.debug('done parsing contents of container record {0}' | ||
| 310 | - .format(self)) | 310 | + # logging.debug('done parsing contents of container record {0}' |
| 311 | + # .format(self)) | ||
| 311 | 312 | ||
| 312 | def __str__(self): | 313 | def __str__(self): |
| 313 | text = super(PptContainerRecord, self).__str__() | 314 | text = super(PptContainerRecord, self).__str__() |
| @@ -471,7 +472,7 @@ class IterStream(io.RawIOBase): | @@ -471,7 +472,7 @@ class IterStream(io.RawIOBase): | ||
| 471 | super(IterStream, self).__init__() | 472 | super(IterStream, self).__init__() |
| 472 | self.iterable_creator = iterable_creator | 473 | self.iterable_creator = iterable_creator |
| 473 | self.size = size | 474 | self.size = size |
| 474 | - logging.debug('IterStream.size is {0}'.format(self.size)) | 475 | + # logging.debug('IterStream.size is {0}'.format(self.size)) |
| 475 | self.reset() | 476 | self.reset() |
| 476 | 477 | ||
| 477 | def reset(self): | 478 | def reset(self): |
| @@ -492,37 +493,37 @@ class IterStream(io.RawIOBase): | @@ -492,37 +493,37 @@ class IterStream(io.RawIOBase): | ||
| 492 | 493 | ||
| 493 | def readinto(self, target): | 494 | def readinto(self, target): |
| 494 | """ read as much data from iterable as necessary to fill target """ | 495 | """ read as much data from iterable as necessary to fill target """ |
| 495 | - logging.debug('IterStream.readinto size {0}'.format(len(target))) | 496 | + # logging.debug('IterStream.readinto size {0}'.format(len(target))) |
| 496 | if self.at_end: | 497 | if self.at_end: |
| 497 | - logging.debug('IterStream: we are at (fake) end') | 498 | + # logging.debug('IterStream: we are at (fake) end') |
| 498 | return 0 | 499 | return 0 |
| 499 | if self.iterable is None: | 500 | if self.iterable is None: |
| 500 | self.iterable = self.iterable_creator() | 501 | self.iterable = self.iterable_creator() |
| 501 | - logging.debug('IterStream: created iterable {0}' | ||
| 502 | - .format(self.iterable)) | 502 | + # logging.debug('IterStream: created iterable {0}' |
| 503 | + # .format(self.iterable)) | ||
| 503 | self.curr_pos = 0 | 504 | self.curr_pos = 0 |
| 504 | try: | 505 | try: |
| 505 | target_len = len(target) # we should return at most this much | 506 | target_len = len(target) # we should return at most this much |
| 506 | chunk = self.leftover or next(self.iterable) | 507 | chunk = self.leftover or next(self.iterable) |
| 507 | - logging.debug('IterStream: chunk is size {0}'.format(len(chunk))) | 508 | + # logging.debug('IterStream: chunk is size {0}'.format(len(chunk))) |
| 508 | output, self.leftover = chunk[:target_len], chunk[target_len:] | 509 | output, self.leftover = chunk[:target_len], chunk[target_len:] |
| 509 | - logging.debug('IterStream: output is size {0}, leftover is {1}' | ||
| 510 | - .format(len(output), len(self.leftover))) | 510 | + # logging.debug('IterStream: output is size {0}, leftover is {1}' |
| 511 | + # .format(len(output), len(self.leftover))) | ||
| 511 | target[:len(output)] = output | 512 | target[:len(output)] = output |
| 512 | self.curr_pos += len(output) | 513 | self.curr_pos += len(output) |
| 513 | - logging.debug('IterStream: pos updated to {0}' | ||
| 514 | - .format(self.curr_pos)) | 514 | + # logging.debug('IterStream: pos updated to {0}' |
| 515 | + # .format(self.curr_pos)) | ||
| 515 | return len(output) | 516 | return len(output) |
| 516 | except StopIteration: | 517 | except StopIteration: |
| 517 | - logging.debug('IterStream: source iterable exhausted') | 518 | + # logging.debug('IterStream: source iterable exhausted') |
| 518 | self.at_end = True | 519 | self.at_end = True |
| 519 | return 0 # indicate EOF | 520 | return 0 # indicate EOF |
| 520 | 521 | ||
| 521 | def seek(self, offset, whence=io.SEEK_SET): | 522 | def seek(self, offset, whence=io.SEEK_SET): |
| 522 | """ can seek to start, possibly end """ | 523 | """ can seek to start, possibly end """ |
| 523 | if offset != 0 and whence == io.SEEK_SET: | 524 | if offset != 0 and whence == io.SEEK_SET: |
| 524 | - logging.debug('IterStream: trying to seek to offset {0}.' | ||
| 525 | - .format(offset)) | 525 | + # logging.debug('IterStream: trying to seek to offset {0}.' |
| 526 | + # .format(offset)) | ||
| 526 | if offset > self.curr_pos: | 527 | if offset > self.curr_pos: |
| 527 | self.readinto(bytearray(offset - self.curr_pos)) | 528 | self.readinto(bytearray(offset - self.curr_pos)) |
| 528 | elif offset == self.curr_pos: | 529 | elif offset == self.curr_pos: |
| @@ -531,34 +532,35 @@ class IterStream(io.RawIOBase): | @@ -531,34 +532,35 @@ class IterStream(io.RawIOBase): | ||
| 531 | self.reset() | 532 | self.reset() |
| 532 | self.readinto(bytearray(offset)) | 533 | self.readinto(bytearray(offset)) |
| 533 | if self.curr_pos != offset: | 534 | if self.curr_pos != offset: |
| 534 | - logging.debug('IterStream: curr_pos {0} != offset {1}!' | ||
| 535 | - .format(self.curr_pos, offset)) | 535 | + # logging.debug('IterStream: curr_pos {0} != offset {1}!' |
| 536 | + # .format(self.curr_pos, offset)) | ||
| 536 | raise RuntimeError('programming error in IterStream.tell!') | 537 | raise RuntimeError('programming error in IterStream.tell!') |
| 537 | return self.curr_pos | 538 | return self.curr_pos |
| 538 | elif whence == io.SEEK_END: # seek to end | 539 | elif whence == io.SEEK_END: # seek to end |
| 539 | - logging.debug('IterStream: seek to end') | 540 | + # logging.debug('IterStream: seek to end') |
| 540 | if self.size is None: | 541 | if self.size is None: |
| 541 | - logging.debug('IterStream: trying to seek to end but size ' | ||
| 542 | - 'unknown --> raise IOError') | 542 | + # logging.debug('IterStream: trying to seek to end but size ' |
| 543 | + # 'unknown --> raise IOError') | ||
| 543 | raise IOError('size unknown, cannot seek to end') | 544 | raise IOError('size unknown, cannot seek to end') |
| 544 | self.at_end = True # fake jumping to the end | 545 | self.at_end = True # fake jumping to the end |
| 545 | self.iterable = None # cannot safely be used any more | 546 | self.iterable = None # cannot safely be used any more |
| 546 | self.leftover = None | 547 | self.leftover = None |
| 547 | return self.size | 548 | return self.size |
| 548 | elif whence == io.SEEK_SET: # seek to start | 549 | elif whence == io.SEEK_SET: # seek to start |
| 549 | - logging.debug('IterStream: seek to start') | 550 | + # logging.debug('IterStream: seek to start') |
| 550 | self.reset() | 551 | self.reset() |
| 551 | return 0 | 552 | return 0 |
| 552 | elif whence == io.SEEK_CUR: # e.g. called by tell() | 553 | elif whence == io.SEEK_CUR: # e.g. called by tell() |
| 553 | - logging.debug('IterStream: seek to curr pos') | 554 | + # logging.debug('IterStream: seek to curr pos') |
| 554 | if self.at_end: | 555 | if self.at_end: |
| 555 | return self.size | 556 | return self.size |
| 556 | return self.curr_pos | 557 | return self.curr_pos |
| 557 | elif whence not in (io.SEEK_SET, io.SEEK_CUR, io.SEEK_END): | 558 | elif whence not in (io.SEEK_SET, io.SEEK_CUR, io.SEEK_END): |
| 558 | - logging.debug('Illegal 2nd argument to seek(): {0}'.format(whence)) | 559 | + # logging.debug('Illegal 2nd argument to seek(): {0}' |
| 560 | + # .format(whence)) | ||
| 559 | raise IOError('Illegal 2nd argument to seek(): {0}'.format(whence)) | 561 | raise IOError('Illegal 2nd argument to seek(): {0}'.format(whence)) |
| 560 | else: | 562 | else: |
| 561 | - logging.debug('not implemented: {0}, {1}'.format(offset, whence)) | 563 | + # logging.debug('not implemented: {0}, {1}'.format(offset, whence)) |
| 562 | raise NotImplementedError('seek only partially implemented. ' | 564 | raise NotImplementedError('seek only partially implemented. ' |
| 563 | 'Cannot yet seek to {0} from {1}' | 565 | 'Cannot yet seek to {0} from {1}' |
| 564 | .format(offset, whence)) | 566 | .format(offset, whence)) |