calamari.io.base#

Loader abstract base class and content-sniffing registry.

Unlike the extension-keyed registry in the asymmetry toolkit (from which this design is adapted), calamari dispatches by file content, not file extension. Quantum Design instruments write everything as .dat regardless of dialect, instrument, or even whether the file is a measurement at all (log/environment files share the extension too), so an extension-based registry cannot distinguish MPMS3 from an unrelated .dat. Instead every loader implements a cheap BaseLoader.sniff() over the first few dozen header lines, and LoaderRegistry.detect() reads those lines once and offers them to each registered loader in turn.

This keeps the door open for other vendors: a new instrument format is added by writing a loader with its own sniff and registering it; no existing code changes.

Functions

read_signature_lines

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

Classes

BaseLoader

Interface every file-format loader must implement.

LoaderRegistry

Central registry of available content-sniffing loaders.