calamari.io.base.read_signature_lines#

calamari.io.base.read_signature_lines(path)#

Read exactly the leading lines a loader’s sniff inspects.

The counterpart to LoaderRegistry.detect(), which swallows read errors to stay usable as a directory-walk probe: this one lets them propagate, so a caller that must distinguish “unreadable file” from “readable but unrecognised file” can. calamari.io.load() is exactly that caller – it reads here (letting FileNotFoundError and friends through untouched) and only then asks LoaderRegistry.detect_lines() whether any loader claims the content.

Parameters:

path (Path | str) – File to read.

Return type:

list[str]

Returns:

list[str] – Up to _SIGNATURE_SCAN_LINES leading lines.

Raises:

OSError – If the file does not exist, is a directory, or cannot be read.