(filename_or_obj, count=8)
| 767 | |
| 768 | |
| 769 | def read_magic_number_from_file(filename_or_obj, count=8) -> bytes: |
| 770 | # check byte header to determine file type |
| 771 | if not isinstance(filename_or_obj, io.IOBase): |
| 772 | raise TypeError(f"cannot read the magic number from {type(filename_or_obj)}") |
| 773 | if filename_or_obj.tell() != 0: |
| 774 | filename_or_obj.seek(0) |
| 775 | magic_number = filename_or_obj.read(count) |
| 776 | filename_or_obj.seek(0) |
| 777 | return magic_number |
| 778 | |
| 779 | |
| 780 | def try_read_magic_number_from_path(pathlike, count=8) -> bytes | None: |
no test coverage detected
searching dependent graphs…