MCPcopy Index your code
hub / github.com/pydata/xarray / try_read_magic_number_from_path

Function try_read_magic_number_from_path

xarray/core/utils.py:780–788  ·  view source on GitHub ↗
(pathlike, count=8)

Source from the content-addressed store, hash-verified

778
779
780def 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
791def try_read_magic_number_from_file_or_path(filename_or_obj, count=8) -> bytes | None:

Callers 2

guess_can_openMethod · 0.90

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…