Lightweight helpers for scanning Jones J-format text.
The mixin implements tolerant, file-level utilities used by
higher-level parsers and collections. It focuses on small,
dependency-free pieces such as path coercion, candidate file
discovery, banner and header probing, and quick content
reads.
The mixin does not keep state. Methods are small and
side-effect free so they can be reused by different classes
(e.g., JCoreParser, JCBBase,
JCollection).
Notes
Utilities are designed to be permissive. They handle odd
encodings, mixed line endings, and common filename patterns.
They also accept both pathlib.Path and strings.
The intent is to keep the heavy parsing in dedicated
readers, while providing robust file discovery and quick
checks here.
Core scanner for J files that extracts light metadata.
Extends JParseMixin with small, read-only probes
that inspect the top header and first data head triple.
This class can reveal the station code, presence of info
keys, encountered data kinds, and the declared row count of
the first block. It avoids loading the whole file.
The implementation aims to be fast and safe for directory
crawls, where many files are filtered before full parse.
Variables:
encoding (str, default 'utf-8') – Encoding used when reading text. Implementations may
choose a tolerant variant such as 'utf-8-sig' with
errors='replace'.
The class manages a list of parsed items (usually
JFile), keeps light metadata for
indexing and filtering, and offers a stable surface for
higher-level collection types. It is intentionally small so
projects can extend it without tight coupling.
Parameters:
verbose (int, default 0) – Verbosity for logs and warnings. Implementations are
free to ignore it or to pass it to child readers.
Subclasses are encouraged to keep the API stable while
augmenting with domain-specific helpers, like saving index
CSV files or computing per-site quality metrics.
The base class uses tolerant discovery, so it can be used on
mixed folders where some files are not Jones J-format.