calamari.io.base.LoaderRegistry#
- class calamari.io.base.LoaderRegistry#
Bases:
objectCentral registry of available content-sniffing loaders.
- classmethod register(loader)#
Register
loader; usable directly or as a class decorator.Returns the loader unchanged so it can be applied as
@LoaderRegistry.registerabove a loader class definition. Registration is idempotent (registering the same class twice is a no-op), which keeps re-imports from duplicating entries.- Return type:
- classmethod detect_lines(lines)#
Return the loader whose
BaseLoader.sniff()claimslines.The pure matching half of
detect(), split out so a caller that has already read the signature region (or that needs read errors to propagate rather than be swallowed – seeread_signature_lines()) does not have to read the file twice or re-implement the dispatch order.Loaders are offered the lines in registration order and the first match wins;
Nonemeans no registered loader recognises the content.- Return type:
type[BaseLoader] |None
- classmethod detect(path)#
Return the loader that claims
path, or None.Reads the first
_SIGNATURE_SCAN_LINESlines once and offers them todetect_lines(). Unreadable files (permission/encoding errors) yield None rather than raising, so this doubles as a safe “is this a supported file?” probe over a directory of mixed content – which is precisely whycalamari.io.load()does not use it: a caller loading one named file needs “could not read” and “not a magnetometry file” to be different outcomes.- Return type:
type[BaseLoader] |None
- classmethod loaders()#
Return the registered loaders in registration order (a copy).
- Return type:
- classmethod by_name(format_name)#
Return the registered loader whose
format_namematches (case-insensitively), or None. Used to honour an explicitfmt=override that bypasses sniffing.- Return type:
type[BaseLoader] |None