ruml-parser 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ruml_parser/__init__.py +183 -0
- ruml_parser/internal/__init__.py +2 -0
- ruml_parser/internal/extension.py +91 -0
- ruml_parser/internal/mapping.py +731 -0
- ruml_parser/internal/ruml/__init__.py +237 -0
- ruml_parser/internal/ruml/actions/__init__.py +2 -0
- ruml_parser/internal/ruml/actions/actions_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/actions/actions_node_capability.py +40 -0
- ruml_parser/internal/ruml/ai_query/__init__.py +2 -0
- ruml_parser/internal/ruml/ai_query/ai_query_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/ai_query/ai_query_node_capability.py +66 -0
- ruml_parser/internal/ruml/aliases.py +93 -0
- ruml_parser/internal/ruml/capability/__init__.py +2 -0
- ruml_parser/internal/ruml/capability/abstract_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/capability/abstract_node_capability.py +14 -0
- ruml_parser/internal/ruml/capability/capability_declaration.py +52 -0
- ruml_parser/internal/ruml/capability/capability_declarations.py +199 -0
- ruml_parser/internal/ruml/capability/extension_node_capability.py +17 -0
- ruml_parser/internal/ruml/capability/node_capabilities.py +113 -0
- ruml_parser/internal/ruml/capability/other_node_capability.py +21 -0
- ruml_parser/internal/ruml/context/__init__.py +2 -0
- ruml_parser/internal/ruml/context/context.py +40 -0
- ruml_parser/internal/ruml/context/context_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/context/context_refs_node_capability.py +17 -0
- ruml_parser/internal/ruml/datapoints/__init__.py +2 -0
- ruml_parser/internal/ruml/datapoints/datapoint.py +101 -0
- ruml_parser/internal/ruml/datapoints/datapoint_set.py +20 -0
- ruml_parser/internal/ruml/datapoints/datapoints_capability_declaration.py +29 -0
- ruml_parser/internal/ruml/datapoints/option.py +11 -0
- ruml_parser/internal/ruml/expression/__init__.py +2 -0
- ruml_parser/internal/ruml/expression/expression_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/expression/expression_node_capability.py +20 -0
- ruml_parser/internal/ruml/metadata.py +83 -0
- ruml_parser/internal/ruml/nodes/__init__.py +2 -0
- ruml_parser/internal/ruml/nodes/abstract_node.py +29 -0
- ruml_parser/internal/ruml/nodes/branch_node.py +15 -0
- ruml_parser/internal/ruml/nodes/leaf_node.py +10 -0
- ruml_parser/internal/ruml/nodes/node.py +6 -0
- ruml_parser/internal/ruml/protocol/__init__.py +2 -0
- ruml_parser/internal/ruml/protocol/protocol_capability_declaration.py +29 -0
- ruml_parser/internal/ruml/query/__init__.py +2 -0
- ruml_parser/internal/ruml/query/query_capability_declaration.py +23 -0
- ruml_parser/internal/ruml/query/query_node_capability.py +17 -0
- ruml_parser/internal/ruml/ruml_document.py +45 -0
- ruml_parser/internal/ruml/text_reference/__init__.py +2 -0
- ruml_parser/internal/ruml/text_reference/text.py +69 -0
- ruml_parser/internal/ruml/text_reference/text_reference_capability_declaration.py +25 -0
- ruml_parser/internal/ruml/text_reference/text_refs_node_capability.py +32 -0
- ruml_parser/internal/ruml/tree/__init__.py +2 -0
- ruml_parser/internal/ruml/tree/tree_capability_declarations.py +30 -0
- ruml_parser/internal/validation/__init__.py +14 -0
- ruml_parser/internal/validation/capabilities.py +227 -0
- ruml_parser/internal/validation/contexts.py +51 -0
- ruml_parser/internal/validation/datapoint_sets.py +125 -0
- ruml_parser/internal/validation/modular.py +42 -0
- ruml_parser/internal/validation/recursion.py +197 -0
- ruml_parser/internal/validation/root.py +36 -0
- ruml_parser/internal/validation/texts.py +50 -0
- ruml_parser/model/__init__.py +2 -0
- ruml_parser/model/ruml.py +1156 -0
- ruml_parser/model/ruml_result.py +430 -0
- ruml_parser/node_result_status.py +19 -0
- ruml_parser/pydantic.py +96 -0
- ruml_parser/ruml_parser.py +75 -0
- ruml_parser/schema_files.py +23 -0
- ruml_parser/schema_validation.py +354 -0
- ruml_parser/structural_error.py +36 -0
- ruml_parser/text.py +220 -0
- ruml_parser-1.0.0.dist-info/METADATA +119 -0
- ruml_parser-1.0.0.dist-info/RECORD +72 -0
- ruml_parser-1.0.0.dist-info/WHEEL +4 -0
- ruml_parser-1.0.0.dist-info/licenses/LICENSE +73 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# SPDX-FileCopyrightText: 2026 Rulemapping Group GmbH
|
|
2
|
+
# SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
"""The spec's rules on ``ruml:text-reference`` and references to them."""
|
|
4
|
+
|
|
5
|
+
from collections.abc import Iterator
|
|
6
|
+
|
|
7
|
+
from ruml_parser.internal.ruml import (
|
|
8
|
+
AiQueryNodeCapability,
|
|
9
|
+
LexId,
|
|
10
|
+
RumlDocument,
|
|
11
|
+
TextId,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def reject_undeclared_text_inputs(document: RumlDocument) -> None:
|
|
16
|
+
"""Raise if an ai-query names a text id the root does not declare.
|
|
17
|
+
|
|
18
|
+
Every id in the ``inputs.texts`` of a node's ``ruml:ai-query`` must have an entry
|
|
19
|
+
in the root-level ``ruml:text-reference`` data (spec chapter 4.9). The schema
|
|
20
|
+
cannot relate a node's ids to the root's, so the rule is checked here. Consumers of
|
|
21
|
+
documents that passed this check may assume every named id resolves.
|
|
22
|
+
|
|
23
|
+
Raises:
|
|
24
|
+
ValueError: If one or more referenced texts are undeclared. Names every
|
|
25
|
+
offending node and its undeclared ids.
|
|
26
|
+
"""
|
|
27
|
+
text_reference = document.capabilities.text_reference
|
|
28
|
+
root_level_text_ids = (
|
|
29
|
+
text_reference.data.keys() if text_reference is not None else frozenset()
|
|
30
|
+
)
|
|
31
|
+
offences = [
|
|
32
|
+
f"node {lex_id!r} -> text_id {text_id!r}"
|
|
33
|
+
for lex_id, text_id in _text_inputs(document)
|
|
34
|
+
if text_id not in root_level_text_ids
|
|
35
|
+
]
|
|
36
|
+
if offences:
|
|
37
|
+
raise ValueError(
|
|
38
|
+
"Some nodes reference undeclared texts: "
|
|
39
|
+
+ "; ".join(offences)
|
|
40
|
+
+ " (spec chapter 4.9: text inputs name root-level text entries)"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _text_inputs(document: RumlDocument) -> Iterator[tuple[LexId, TextId]]:
|
|
45
|
+
"""Yield nodes' ai-query text inputs as ``(lex_id, text id)``, in document order."""
|
|
46
|
+
for lex_id, ai_query in document.all_node_capabilities_of_type(
|
|
47
|
+
AiQueryNodeCapability
|
|
48
|
+
):
|
|
49
|
+
for text_id in ai_query.inputs.texts:
|
|
50
|
+
yield lex_id, text_id
|