|
17 | 17 | import datetime |
18 | 18 | import time |
19 | 19 | import logging |
20 | | -from typing import List, BinaryIO, Generator, Union, Tuple, Optional, cast |
| 20 | +from typing import List, BinaryIO, Generator, Union, Tuple, Optional, cast, Any |
21 | 21 |
|
22 | 22 | from ..message import Message |
23 | 23 | from ..util import len2dlc, dlc2len, channel2int |
@@ -370,6 +370,8 @@ def __init__( |
370 | 370 | append: bool = False, |
371 | 371 | channel: int = 1, |
372 | 372 | compression_level: int = -1, |
| 373 | + *args: Any, |
| 374 | + **kwargs: Any |
373 | 375 | ) -> None: |
374 | 376 | """ |
375 | 377 | :param file: a path-like object or as file-like object to write to |
@@ -400,6 +402,9 @@ def __init__( |
400 | 402 | self.compression_level = compression_level |
401 | 403 | self._buffer: List[bytes] = [] |
402 | 404 | self._buffer_size = 0 |
| 405 | + # If max container size is located in kwargs, then update the instance |
| 406 | + if kwargs.get("max_container_size", False): |
| 407 | + self.max_container_size = kwargs["max_container_size"] |
403 | 408 | if append: |
404 | 409 | # Parse file header |
405 | 410 | data = self.file.read(FILE_HEADER_STRUCT.size) |
@@ -566,6 +571,10 @@ def _flush(self): |
566 | 571 | self.uncompressed_size += LOG_CONTAINER_STRUCT.size |
567 | 572 | self.uncompressed_size += len(uncompressed_data) |
568 | 573 |
|
| 574 | + def file_size(self) -> int: |
| 575 | + """Return an estimate of the current file size in bytes.""" |
| 576 | + return self.file.tell() + self._buffer_size |
| 577 | + |
569 | 578 | def stop(self): |
570 | 579 | """Stops logging and closes the file.""" |
571 | 580 | self._flush() |
|
0 commit comments