danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
611 stars 216 forks source link

BufferedReader as input not currently working #1000

Open CheMcKirgan opened 3 months ago

CheMcKirgan commented 3 months ago

Python version

3.11

asammdf version

7.4.2

Description

The type hinting for the init istates that MDF supports io.BufferedReader as an input type. https://github.com/danielhrisca/asammdf/blob/2d20ad23d3ef71ca7e307273ddd74ce08cce83b5/src/asammdf/types.py#L38

https://github.com/danielhrisca/asammdf/blob/c9d0e449000ed70f2ea1dd47df7c80f3e74471c5/src/asammdf/mdf.py#L236 This type checking block has broken that support in this commit. We've tested adding BufferedReader to this type check, if isinstance(name, (BytesIO, BufferedReader)):, and it seems that the type check is the only thing blocking this support.

CheMcKirgan commented 3 months ago

Further to documentation on the is file like check method. It would be very helpful to check that the input is a general 'BufferedIoBase', as BufferedIoBase meets your criteria for read and seek methods, after evaluating it is not any of the compressed file formats you support.

https://github.com/danielhrisca/asammdf/blob/c9d0e449000ed70f2ea1dd47df7c80f3e74471c5/src/asammdf/blocks/utils.py#L1079