read and drop all CR and LF characters
(self, size)
| 46 | __next__ = next # Python 3 compatibility |
| 47 | |
| 48 | def read(self, size): |
| 49 | ''' read and drop all CR and LF characters ''' |
| 50 | # TODO: this is inneficient but works, patches accepted! |
| 51 | # NOTE: our fixtures include files which have no linebreaks, |
| 52 | # files with CR-LF linebreaks and files with LF linebreaks |
| 53 | chunks = [] |
| 54 | count = 0 |
| 55 | while count < size: |
| 56 | chunk = self.file.read(size-count) |
| 57 | if len(chunk) == 0: |
| 58 | break |
| 59 | chunk = chunk.replace(CR+LF,'') |
| 60 | if CR in chunk: |
| 61 | chunk = chunk.replace(CR,'') |
| 62 | if LF in chunk: |
| 63 | chunk = chunk.replace(LF,'') |
| 64 | count += len(chunk) |
| 65 | chunks.append(chunk) |
| 66 | return ''.join(chunks) |
| 67 | |
| 68 | def close(self): |
| 69 | self.file.close() |
no test coverage detected