pyfcstm.utils
Utility helpers package for pyfcstm.
This package provides a consolidated import location for frequently used utility
functions, interfaces, and exceptions within pyfcstm. The exported
symbols cover binary detection, decoding utilities, documentation formatting,
Jinja2 environment configuration, JSON/YAML serialization interfaces, safe
string handling, text normalization, value parsing, and validation helpers.
The package exposes the following main components:
is_binary_file()- Detect whether a file is binary by inspecting its bytesauto_decode()- Decode bytes by trying multiple encodingsformat_multiline_comment()- Normalize multiline comments from parsersadd_builtins_to_env()- Register Python built-ins in a Jinja2 environmentadd_settings_for_env()- Apply common filters and globals to Jinja2IJsonOp- Interface for JSON/YAML serializationsequence_safe()- Build a safe underscore-separated identifiernormalize()- Normalize text to identifier-friendly formto_identifier()- Convert text to a valid identifier formatparse_value()- Parse string values to appropriate Python typesparse_key_value_pairs()- Parse multiple key=value pairs into a dictionaryValidationError- Base validation error exceptionModelValidationError- Aggregated validation error exceptionIValidatable- Interface for objects with validation rules
Note
This package re-exports utilities from internal modules to provide a unified
import path. The implementations reside in submodules such as
pyfcstm.utils.text and pyfcstm.utils.validate.
Example:
>>> from pyfcstm.utils import normalize, IJsonOp, parse_value
>>> normalize("Hello World!")
'Hello_World'
>>> parse_value('42')
42