Open the file and initialize size limit.
(self)
| 320 | self.open() |
| 321 | |
| 322 | def open(self) -> None: |
| 323 | """Open the file and initialize size limit.""" |
| 324 | if self._file is not None: |
| 325 | return |
| 326 | try: |
| 327 | self._file = self._file_path.open('rb') |
| 328 | self._size_limit = min( |
| 329 | self._size_limit or float('inf'), |
| 330 | os.fstat(self._file.fileno()).st_size) |
| 331 | except OSError as e: |
| 332 | logger.error(f'Failed to open file {self._file_path}: {e}') |
| 333 | raise |
| 334 | |
| 335 | def close(self) -> None: |
| 336 | """Close the file if it's open.""" |
no outgoing calls