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 | 298 | if not self.data: |
| 299 | 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 | 304 | # create a stream from self.data and parse it like any other |
| 304 | 305 | data_stream = io.BytesIO(self.data) |
| ... | ... | @@ -306,8 +307,8 @@ class PptContainerRecord(PptRecord): |
| 306 | 307 | 'PptContainerRecordSubstream', |
| 307 | 308 | record_base.STGTY_SUBSTREAM) |
| 308 | 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 | 313 | def __str__(self): |
| 313 | 314 | text = super(PptContainerRecord, self).__str__() |
| ... | ... | @@ -471,7 +472,7 @@ class IterStream(io.RawIOBase): |
| 471 | 472 | super(IterStream, self).__init__() |
| 472 | 473 | self.iterable_creator = iterable_creator |
| 473 | 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 | 476 | self.reset() |
| 476 | 477 | |
| 477 | 478 | def reset(self): |
| ... | ... | @@ -492,37 +493,37 @@ class IterStream(io.RawIOBase): |
| 492 | 493 | |
| 493 | 494 | def readinto(self, target): |
| 494 | 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 | 497 | if self.at_end: |
| 497 | - logging.debug('IterStream: we are at (fake) end') | |
| 498 | + # logging.debug('IterStream: we are at (fake) end') | |
| 498 | 499 | return 0 |
| 499 | 500 | if self.iterable is None: |
| 500 | 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 | 504 | self.curr_pos = 0 |
| 504 | 505 | try: |
| 505 | 506 | target_len = len(target) # we should return at most this much |
| 506 | 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 | 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 | 512 | target[:len(output)] = output |
| 512 | 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 | 516 | return len(output) |
| 516 | 517 | except StopIteration: |
| 517 | - logging.debug('IterStream: source iterable exhausted') | |
| 518 | + # logging.debug('IterStream: source iterable exhausted') | |
| 518 | 519 | self.at_end = True |
| 519 | 520 | return 0 # indicate EOF |
| 520 | 521 | |
| 521 | 522 | def seek(self, offset, whence=io.SEEK_SET): |
| 522 | 523 | """ can seek to start, possibly end """ |
| 523 | 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 | 527 | if offset > self.curr_pos: |
| 527 | 528 | self.readinto(bytearray(offset - self.curr_pos)) |
| 528 | 529 | elif offset == self.curr_pos: |
| ... | ... | @@ -531,34 +532,35 @@ class IterStream(io.RawIOBase): |
| 531 | 532 | self.reset() |
| 532 | 533 | self.readinto(bytearray(offset)) |
| 533 | 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 | 537 | raise RuntimeError('programming error in IterStream.tell!') |
| 537 | 538 | return self.curr_pos |
| 538 | 539 | elif whence == io.SEEK_END: # seek to end |
| 539 | - logging.debug('IterStream: seek to end') | |
| 540 | + # logging.debug('IterStream: seek to end') | |
| 540 | 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 | 544 | raise IOError('size unknown, cannot seek to end') |
| 544 | 545 | self.at_end = True # fake jumping to the end |
| 545 | 546 | self.iterable = None # cannot safely be used any more |
| 546 | 547 | self.leftover = None |
| 547 | 548 | return self.size |
| 548 | 549 | elif whence == io.SEEK_SET: # seek to start |
| 549 | - logging.debug('IterStream: seek to start') | |
| 550 | + # logging.debug('IterStream: seek to start') | |
| 550 | 551 | self.reset() |
| 551 | 552 | return 0 |
| 552 | 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 | 555 | if self.at_end: |
| 555 | 556 | return self.size |
| 556 | 557 | return self.curr_pos |
| 557 | 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 | 561 | raise IOError('Illegal 2nd argument to seek(): {0}'.format(whence)) |
| 560 | 562 | else: |
| 561 | - logging.debug('not implemented: {0}, {1}'.format(offset, whence)) | |
| 563 | + # logging.debug('not implemented: {0}, {1}'.format(offset, whence)) | |
| 562 | 564 | raise NotImplementedError('seek only partially implemented. ' |
| 563 | 565 | 'Cannot yet seek to {0} from {1}' |
| 564 | 566 | .format(offset, whence)) | ... | ... |