rdm-parser 0.1.0
Reusable parsing library for time series data standardization
Loading...
Searching...
No Matches
rdm_parser.parsers.base Namespace Reference

Classes

class  BaseParser
 
class  DescriptiveMetadata
 
class  ParseError
 
class  ParseResult
 

Functions

logging.Logger get_logger (str name)
 
str read_text_with_fallback (Path path, str|None encoding=None)
 
str|None normalize_metadata_timestamp (object value)
 
DescriptiveMetadata build_metadata (*str source_format, dict[str, Any] source_metadata, object format_version=None, object station_id=None, object test_name=None, object experiment_type=None, object sample_name=None, object started_at=None, object operator_name=None, object location=None, int|float|None active_area_cm2=None, object source_record_id=None)
 

Detailed Description

Shared parser interface and helpers.

Lightweight base for testbench parsers. Each concrete parser returns the same
standard ``ParseResult`` shape so downstream code can be format-agnostic.

The interface is intentionally minimal — just enough to (a) document the
contract and (b) host shared helpers (encoding fallback, logger). Concrete
parsers are exposed as both classes and module-level functions for
backward compatibility.

Function Documentation

◆ build_metadata()

DescriptiveMetadata rdm_parser.parsers.base.build_metadata ( *str  source_format,
dict[str, Any]  source_metadata,
object   format_version = None,
object   station_id = None,
object   test_name = None,
object   experiment_type = None,
object   sample_name = None,
object   started_at = None,
object   operator_name = None,
object   location = None,
int | float | None   active_area_cm2 = None,
object   source_record_id = None 
)
Build the shared descriptive metadata envelope for parser results.

◆ get_logger()

logging.Logger rdm_parser.parsers.base.get_logger ( str  name)
Return a logger that is silent by default.

The library does not configure handlers; applications opt in by adding
their own. A NullHandler is attached so ``logging`` does not emit
"No handlers could be found" warnings.

◆ normalize_metadata_timestamp()

str | None rdm_parser.parsers.base.normalize_metadata_timestamp ( object  value)
Return a normalized metadata timestamp string when possible.

◆ read_text_with_fallback()

str rdm_parser.parsers.base.read_text_with_fallback ( Path  path,
str | None   encoding = None 
)
Read a text file, falling back to latin-1 on UnicodeDecodeError.

If ``encoding`` is given, only that encoding is tried. If ``None``, the
function tries utf-8 first then latin-1 — covers most testbench files
where stray bytes (e.g. ``cm²``) appear in otherwise-ASCII output.