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 formatto_c_identifier()- Convert text to a C/C++-safe identifierto_cpp_identifier()- Convert text to a C/C++-safe identifier viacppaliasto_python_identifier()- Convert text to a Python-safe identifierto_java_identifier()- Convert text to a Java-safe identifierto_ruby_identifier()- Convert text to a Ruby-safe identifierto_ts_identifier()- Convert text to a TypeScript-safe identifierto_js_identifier()- Convert text to a JavaScript-safe identifierto_rust_identifier()- Convert text to a Rust-safe identifierto_go_identifier()- Convert text to a Go-safe identifierparse_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
- pyfcstm.utils.binary
- pyfcstm.utils.decode
- pyfcstm.utils.doc
- pyfcstm.utils.fixed
- pyfcstm.utils.jinja2
- pyfcstm.utils.json
- pyfcstm.utils.logging
- pyfcstm.utils.parse
- pyfcstm.utils.safe
- pyfcstm.utils.text
- pyfcstm.utils.validate