(pathlike, count=8)
| 778 | |
| 779 | |
| 780 | def try_read_magic_number_from_path(pathlike, count=8) -> bytes | None: |
| 781 | if isinstance(pathlike, str) or hasattr(pathlike, "__fspath__"): |
| 782 | path = os.fspath(pathlike) |
| 783 | try: |
| 784 | with open(path, "rb") as f: |
| 785 | return read_magic_number_from_file(f, count) |
| 786 | except (FileNotFoundError, IsADirectoryError, TypeError): |
| 787 | pass |
| 788 | return None |
| 789 | |
| 790 | |
| 791 | def try_read_magic_number_from_file_or_path(filename_or_obj, count=8) -> bytes | None: |
no test coverage detected
searching dependent graphs…