|
TRUST 1.9.8
HPC thermohydraulic platform
|
Everything below is importable directly from trustify:
trustify.api.* and trustify.projects.* are the same symbols, but the only stable import path is the top-level trustify package. Sub-modules (trustify.core.*, trustify.cli.*, trustify.formatter, trustify.doc.*) are implementation details and can change without notice.
Generate (or reuse-cached) the TRUST schema for the given project set. Returns the directory containing the five generated files (TRAD2_trustify, source_locations.json, trustify_gen_pyd.py, trustify_gen.py, provenance.json).
Mirrors the trustify generate_schema CLI exactly.
Load a TRUST .data file and return it as a pydantic model rooted at the Dataset class of the appropriate schema. Two modes:
Returns the populated Dataset instance; raises TrustifyParseError on syntax / structural errors.
Parse data_file against the schema and verify the byte-identical round-trip. Returns a CheckResult (dataclass) with:
Does NOT raise on parse errors — they're captured in the returned result. This lets batch_check keep iterating after a single failure.
Run check on every entry in data_files. The schema is generated (or pulled from cache) ONCE before iteration.
Returns a BatchCheckResult with total, passed, failed, skipped, and results: list[CheckResult].
Write a .trustify.json template into directory. Raises FileExistsError if the file already exists and overwrite=False. Returns the path to the written file.
Emits the workspace block (frozen from the passed projects / trust_root) plus a placeholder lsp block. cache keys are not written — they default to their declared values (see the .trustify.json reference) and can be added by hand when needed.
Format TRUST .data text. Pure text manipulation — no schema needed. Pass any str: file content, a string built in memory, the result of a string.Template substitution.
start_context is an advanced hook for the LSP server (lets it format a partial document mid-edit). End users can ignore it.
Thin convenience wrapper that reads filename and returns the formatted text.
These are opt-in for programmatic callers. The API itself never walks the filesystem looking for configs or baltik markers — call these explicitly when you want CLI-style discovery in a script.
Walk up from start (file or directory; defaults to CWD) looking for a .trustify.json and return its parsed TrustifyConfig. Returns None when no config is found. Raises ConfigError on malformed content.
Walk up from start looking for a directory containing a project.cfg. Returns the absolute path of that directory, or None.
Recursively expand each project's [dependencies] from its project.cfg. Returns the full overlay-correct list in post-order (every dependency appears before the baltik that declares it). Validates that each declared dep exists and that its [description].name matches what the parent declared.
None / empty input returns unchanged.
Frozen dataclass returned by discover_config / TrustifyConfig.from_file. Fields:
Helper: to_api_kwargs() -> dict returns {"projects": ..., "trust_root": ...} ready to splat into generate_schema(**kwargs) / load_dataset(**kwargs) / etc.
See the .trustify.json reference for the on-disk schema.
Raised when a .trustify.json is malformed (wrong type for a known key, conflicting project.cfg + workspace.projects, missing dependency, etc.). Subclass of Exception.
Raised by the schema parser on syntactic / structural errors in a .data file. Carries file_name, line, col, end_line, end_col, token, attr_name, kind for callers that want to report editor-friendly diagnostics. check() catches this and folds it into the returned CheckResult.message.
Frozen 4-tuple (start_line, start_char, end_line, end_char) attached to parsed nodes by TRUSTStream. Used by the LSP to map pydantic model fields back to source positions.
These are the entry points the generated schema uses internally. Most callers don't need them — load_dataset and check are the right level of abstraction. Documented here because they're part of the public surface.
Root parser class. Every generated schema's Dataset class subclasses this. Dataset_Parser.ReadFromTokens(stream) is the entry-point parse call.
Tokenizer for TRUST .data text. parser.tokenize(text) populates its token lists; pair with TRUSTStream for parser-friendly consumption.
Wraps a TRUSTParser's token list with the bookkeeping the schema parsers expect (current position, source-range tracking, error context).