Handles incrementally decoding bytes into text
| 304 | |
| 305 | |
| 306 | class TextDecoder: |
| 307 | """ |
| 308 | Handles incrementally decoding bytes into text |
| 309 | """ |
| 310 | |
| 311 | def __init__(self, encoding: str = "utf-8") -> None: |
| 312 | self.decoder = codecs.getincrementaldecoder(encoding)(errors="replace") |
| 313 | |
| 314 | def decode(self, data: bytes) -> str: |
| 315 | return self.decoder.decode(data) |
| 316 | |
| 317 | def flush(self) -> str: |
| 318 | return self.decoder.decode(b"", True) |
| 319 | |
| 320 | |
| 321 | class LineDecoder: |
no outgoing calls
no test coverage detected