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

Function read_magic_number_from_file

xarray/core/utils.py:769–777  ·  view source on GitHub ↗
(filename_or_obj, count=8)

Source from the content-addressed store, hash-verified

767
768
769def 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
780def try_read_magic_number_from_path(pathlike, count=8) -> bytes | None:

Callers 3

openMethod · 0.90

Calls 4

typeFunction · 0.85
tellMethod · 0.80
seekMethod · 0.80
readMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…