asammdf
asammdf copied to clipboard
BufferedReader as input not currently working
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.
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
@CheMcKirgan please try the development branch code