cognite-neat 0.90.2__py3-none-any.whl → 0.92.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.
Potentially problematic release.
This version of cognite-neat might be problematic. Click here for more details.
- cognite/neat/_version.py +1 -1
- cognite/neat/graph/extractors/__init__.py +5 -0
- cognite/neat/graph/extractors/_classic_cdf/_assets.py +8 -8
- cognite/neat/graph/extractors/_classic_cdf/_base.py +26 -1
- cognite/neat/graph/extractors/_classic_cdf/_classic.py +208 -0
- cognite/neat/graph/extractors/_classic_cdf/_data_sets.py +110 -0
- cognite/neat/graph/extractors/_classic_cdf/_events.py +30 -5
- cognite/neat/graph/extractors/_classic_cdf/_files.py +33 -8
- cognite/neat/graph/extractors/_classic_cdf/_labels.py +14 -6
- cognite/neat/graph/extractors/_classic_cdf/_relationships.py +38 -7
- cognite/neat/graph/extractors/_classic_cdf/_sequences.py +30 -5
- cognite/neat/graph/extractors/_classic_cdf/_timeseries.py +30 -5
- cognite/neat/graph/extractors/_dexpi.py +4 -4
- cognite/neat/graph/extractors/_iodd.py +160 -0
- cognite/neat/issues/_base.py +6 -2
- cognite/neat/rules/exporters/_rules2excel.py +3 -3
- cognite/neat/rules/exporters/_rules2yaml.py +5 -1
- cognite/neat/rules/models/__init__.py +2 -2
- cognite/neat/rules/models/_base_input.py +2 -2
- cognite/neat/rules/models/_base_rules.py +142 -142
- cognite/neat/rules/models/asset/_rules.py +1 -34
- cognite/neat/rules/models/dms/_rules.py +127 -46
- cognite/neat/rules/models/dms/_validation.py +2 -2
- cognite/neat/rules/models/domain.py +16 -19
- cognite/neat/rules/models/entities/_single_value.py +25 -11
- cognite/neat/rules/models/entities/_types.py +0 -10
- cognite/neat/rules/models/information/_rules.py +68 -43
- cognite/neat/rules/models/information/_validation.py +5 -5
- cognite/neat/rules/transformers/_converters.py +6 -8
- cognite/neat/rules/transformers/_pipelines.py +8 -4
- cognite/neat/store/_base.py +1 -1
- cognite/neat/utils/collection_.py +4 -3
- cognite/neat/utils/xml_.py +27 -12
- {cognite_neat-0.90.2.dist-info → cognite_neat-0.92.0.dist-info}/METADATA +1 -1
- {cognite_neat-0.90.2.dist-info → cognite_neat-0.92.0.dist-info}/RECORD +38 -38
- cognite/neat/rules/models/asset/_serializer.py +0 -73
- cognite/neat/rules/models/dms/_serializer.py +0 -157
- cognite/neat/rules/models/information/_serializer.py +0 -73
- {cognite_neat-0.90.2.dist-info → cognite_neat-0.92.0.dist-info}/LICENSE +0 -0
- {cognite_neat-0.90.2.dist-info → cognite_neat-0.92.0.dist-info}/WHEEL +0 -0
- {cognite_neat-0.90.2.dist-info → cognite_neat-0.92.0.dist-info}/entry_points.txt +0 -0
|
@@ -151,7 +151,7 @@ class InformationPostValidation:
|
|
|
151
151
|
def _class_parent_pairs(self) -> dict[ClassEntity, list[ClassEntity]]:
|
|
152
152
|
class_subclass_pairs: dict[ClassEntity, list[ClassEntity]] = {}
|
|
153
153
|
|
|
154
|
-
classes = self.rules.model_copy(deep=True).classes
|
|
154
|
+
classes = self.rules.model_copy(deep=True).classes
|
|
155
155
|
|
|
156
156
|
# USE CASE: Solution model being extended (user + last + reference = complete)
|
|
157
157
|
if (
|
|
@@ -159,8 +159,8 @@ class InformationPostValidation:
|
|
|
159
159
|
and self.metadata.data_model_type == DataModelType.solution
|
|
160
160
|
):
|
|
161
161
|
classes += (
|
|
162
|
-
cast(InformationRules, self.rules.last).model_copy(deep=True).classes
|
|
163
|
-
+ cast(InformationRules, self.rules.reference).model_copy(deep=True).classes
|
|
162
|
+
cast(InformationRules, self.rules.last).model_copy(deep=True).classes
|
|
163
|
+
+ cast(InformationRules, self.rules.reference).model_copy(deep=True).classes
|
|
164
164
|
)
|
|
165
165
|
|
|
166
166
|
# USE CASE: Solution model being created from scratch (user + reference = complete)
|
|
@@ -168,14 +168,14 @@ class InformationPostValidation:
|
|
|
168
168
|
self.metadata.schema_ == SchemaCompleteness.complete
|
|
169
169
|
and self.metadata.data_model_type == DataModelType.solution
|
|
170
170
|
):
|
|
171
|
-
classes += cast(InformationRules, self.rules.reference).model_copy(deep=True).classes
|
|
171
|
+
classes += cast(InformationRules, self.rules.reference).model_copy(deep=True).classes
|
|
172
172
|
|
|
173
173
|
# USE CASE: Enterprise model being extended (user + last = complete)
|
|
174
174
|
elif (
|
|
175
175
|
self.metadata.schema_ == SchemaCompleteness.extended
|
|
176
176
|
and self.metadata.data_model_type == DataModelType.enterprise
|
|
177
177
|
):
|
|
178
|
-
classes += cast(InformationRules, self.rules.last).model_copy(deep=True).classes
|
|
178
|
+
classes += cast(InformationRules, self.rules.last).model_copy(deep=True).classes
|
|
179
179
|
|
|
180
180
|
for class_ in classes:
|
|
181
181
|
class_subclass_pairs[class_.class_] = []
|
|
@@ -138,7 +138,7 @@ class _InformationRulesConverter:
|
|
|
138
138
|
from cognite.neat.rules.models.asset._rules import AssetClass, AssetMetadata, AssetProperty, AssetRules
|
|
139
139
|
|
|
140
140
|
classes: SheetList[AssetClass] = SheetList[AssetClass](
|
|
141
|
-
|
|
141
|
+
[AssetClass(**class_.model_dump()) for class_ in self.rules.classes]
|
|
142
142
|
)
|
|
143
143
|
properties: SheetList[AssetProperty] = SheetList[AssetProperty]()
|
|
144
144
|
for prop_ in self.rules.properties:
|
|
@@ -227,11 +227,9 @@ class _InformationRulesConverter:
|
|
|
227
227
|
|
|
228
228
|
return DMSRules(
|
|
229
229
|
metadata=metadata,
|
|
230
|
-
properties=SheetList[DMSProperty](
|
|
231
|
-
|
|
232
|
-
),
|
|
233
|
-
views=SheetList[DMSView](data=views),
|
|
234
|
-
containers=SheetList[DMSContainer](data=containers),
|
|
230
|
+
properties=SheetList[DMSProperty]([prop for prop_set in properties_by_class.values() for prop in prop_set]),
|
|
231
|
+
views=SheetList[DMSView](views),
|
|
232
|
+
containers=SheetList[DMSContainer](containers),
|
|
235
233
|
last=last_dms_rules,
|
|
236
234
|
reference=ref_dms_rules,
|
|
237
235
|
)
|
|
@@ -481,8 +479,8 @@ class _DMSRulesConverter:
|
|
|
481
479
|
|
|
482
480
|
return InformationRules(
|
|
483
481
|
metadata=metadata,
|
|
484
|
-
properties=SheetList[InformationProperty](
|
|
485
|
-
classes=SheetList[InformationClass](
|
|
482
|
+
properties=SheetList[InformationProperty](properties),
|
|
483
|
+
classes=SheetList[InformationClass](classes),
|
|
486
484
|
last=_DMSRulesConverter(self.dms.last).as_information_rules() if self.dms.last else None,
|
|
487
485
|
reference=_DMSRulesConverter(self.dms.reference).as_information_rules() if self.dms.reference else None,
|
|
488
486
|
)
|
|
@@ -55,7 +55,11 @@ class ImporterPipeline(RulesPipeline[InputRules, VerifiedRules]):
|
|
|
55
55
|
def execute(self) -> VerifiedRules:
|
|
56
56
|
"""Execute the pipeline from importer to rules."""
|
|
57
57
|
rules = self._importer.to_rules()
|
|
58
|
-
out = self.transform(rules)
|
|
59
|
-
if out is None:
|
|
60
|
-
raise
|
|
61
|
-
|
|
58
|
+
out = self.transform(rules)
|
|
59
|
+
if isinstance(out, MaybeRules) and out.rules is None:
|
|
60
|
+
raise out.issues.as_errors("Failed to convert rules")
|
|
61
|
+
|
|
62
|
+
rules = out.get_rules()
|
|
63
|
+
if rules is None:
|
|
64
|
+
raise NeatValueError("Rules is missing cannot convert")
|
|
65
|
+
return rules
|
cognite/neat/store/_base.py
CHANGED
|
@@ -182,7 +182,7 @@ class NeatGraphStore:
|
|
|
182
182
|
|
|
183
183
|
class_entity = ClassEntity(prefix=self.rules.metadata.prefix, suffix=class_)
|
|
184
184
|
|
|
185
|
-
if class_entity not in [definition.class_ for definition in self.rules.classes
|
|
185
|
+
if class_entity not in [definition.class_ for definition in self.rules.classes]:
|
|
186
186
|
warnings.warn("Desired type not found in graph!", stacklevel=2)
|
|
187
187
|
return None
|
|
188
188
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from collections import Counter
|
|
2
|
-
from collections.abc import Sequence
|
|
2
|
+
from collections.abc import Iterable, Sequence
|
|
3
3
|
from typing import TypeVar
|
|
4
4
|
|
|
5
5
|
T_Element = TypeVar("T_Element")
|
|
@@ -14,5 +14,6 @@ def most_occurring_element(list_of_elements: list[T_Element]) -> T_Element:
|
|
|
14
14
|
return counts.most_common(1)[0][0]
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def chunker(sequence: Sequence[T_Element], chunk_size: int) ->
|
|
18
|
-
|
|
17
|
+
def chunker(sequence: Sequence[T_Element], chunk_size: int) -> Iterable[Sequence[T_Element]]:
|
|
18
|
+
for i in range(0, len(sequence), chunk_size):
|
|
19
|
+
yield sequence[i : i + chunk_size]
|
cognite/neat/utils/xml_.py
CHANGED
|
@@ -2,7 +2,7 @@ from collections.abc import Generator
|
|
|
2
2
|
from xml.etree.ElementTree import Element
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
def iterate_tree(node: Element) -> Generator:
|
|
5
|
+
def iterate_tree(node: Element, skip_root: bool = False) -> Generator:
|
|
6
6
|
"""Iterate over all elements in an XML tree.
|
|
7
7
|
|
|
8
8
|
Args:
|
|
@@ -11,27 +11,42 @@ def iterate_tree(node: Element) -> Generator:
|
|
|
11
11
|
Returns:
|
|
12
12
|
Generator of XML elements.
|
|
13
13
|
"""
|
|
14
|
-
|
|
14
|
+
if not skip_root:
|
|
15
|
+
yield node
|
|
15
16
|
for child in node:
|
|
16
17
|
yield from iterate_tree(child)
|
|
17
18
|
|
|
18
19
|
|
|
19
|
-
def get_children(
|
|
20
|
-
|
|
20
|
+
def get_children(
|
|
21
|
+
element: Element,
|
|
22
|
+
child_tag: str,
|
|
23
|
+
include_nested_children: bool = False,
|
|
24
|
+
ignore_namespace: bool = False,
|
|
25
|
+
no_children: int = -1,
|
|
26
|
+
) -> Element | list[Element]:
|
|
27
|
+
"""Get direct children of an XML element.
|
|
21
28
|
|
|
22
29
|
Args:
|
|
23
30
|
element: XML element to get children from.
|
|
24
31
|
child_tag: Tag of the children to get.
|
|
32
|
+
include_nested_children: bool to decide if only direct child elements should be extracted, or if all child
|
|
33
|
+
elements (including nested ones) should be returned.
|
|
34
|
+
ignore_namespace: bool that decides if wildcard * should be used to ignore namespace of children elements tag
|
|
25
35
|
no_children: Max number of children to get. Defaults to -1 (all).
|
|
26
36
|
|
|
27
37
|
Returns:
|
|
28
38
|
List of XML elements if no_children > 1, otherwise XML element.
|
|
29
39
|
"""
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
search_string = ""
|
|
41
|
+
if ignore_namespace:
|
|
42
|
+
if include_nested_children:
|
|
43
|
+
search_string = f".//{{*}}{child_tag}"
|
|
44
|
+
else:
|
|
45
|
+
search_string = f".{{*}}{child_tag}"
|
|
46
|
+
elif not ignore_namespace:
|
|
47
|
+
if include_nested_children:
|
|
48
|
+
search_string = f".//{child_tag}"
|
|
49
|
+
else:
|
|
50
|
+
search_string = f".{child_tag}"
|
|
51
|
+
children = element.findall(search_string)
|
|
52
|
+
return children[:no_children] if no_children > 0 else children
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
cognite/neat/__init__.py,sha256=AiexNcHdAHFbrrbo9c65gtil1dqx_SGraDH1PSsXjKE,126
|
|
2
2
|
cognite/neat/_shared.py,sha256=RSaHm2eJceTlvb-hMMe4nHgoHdPYDfN3XcxDXo24k3A,1530
|
|
3
|
-
cognite/neat/_version.py,sha256=
|
|
3
|
+
cognite/neat/_version.py,sha256=4oQqdZ-jW338RGQfLxI7hoQNb8tTR6y4hzWoJRPdI3o,23
|
|
4
4
|
cognite/neat/app/api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
5
5
|
cognite/neat/app/api/asgi/metrics.py,sha256=nxFy7L5cChTI0a-zkCiJ59Aq8yLuIJp5c9Dg0wRXtV0,152
|
|
6
6
|
cognite/neat/app/api/configuration.py,sha256=L1DCtLZ1HZku8I2z-JWd5RDsXhIsboFsKwAMhkrm-bY,3600
|
|
@@ -49,19 +49,22 @@ cognite/neat/graph/examples/Knowledge-Graph-Nordic44-dirty.xml,sha256=ujJip6XBs5
|
|
|
49
49
|
cognite/neat/graph/examples/Knowledge-Graph-Nordic44.xml,sha256=U2Ns-M4LRjT1fBkhmRj63ur7jDzlRtHK9yOLf_npZ_g,1437996
|
|
50
50
|
cognite/neat/graph/examples/__init__.py,sha256=yAjHVY3b5jOjmbW-iLbhvu7BG014TpGi3K4igkDqW5I,368
|
|
51
51
|
cognite/neat/graph/examples/skos-capturing-sheet-wind-topics.xlsx,sha256=CV_yK5ZSbYS_ktfIZUPD8Sevs47zpswLXQUDFkGE4Gw,45798
|
|
52
|
-
cognite/neat/graph/extractors/__init__.py,sha256=
|
|
52
|
+
cognite/neat/graph/extractors/__init__.py,sha256=9A_AsBwdbnYDo-20c18wcu__S-h9PHCeQB_fGteK5mo,1858
|
|
53
53
|
cognite/neat/graph/extractors/_base.py,sha256=8IWygpkQTwo0UOmbbwWVI7540_klTVdUVX2JjVPFRIs,498
|
|
54
54
|
cognite/neat/graph/extractors/_classic_cdf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
55
|
-
cognite/neat/graph/extractors/_classic_cdf/_assets.py,sha256=
|
|
56
|
-
cognite/neat/graph/extractors/_classic_cdf/_base.py,sha256=
|
|
57
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
58
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
59
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
60
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
61
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
62
|
-
cognite/neat/graph/extractors/_classic_cdf/
|
|
63
|
-
cognite/neat/graph/extractors/
|
|
55
|
+
cognite/neat/graph/extractors/_classic_cdf/_assets.py,sha256=3zpwp4LIXf_dQgfXEQCmp0CNprBYGLC-VjNmhMXc-4k,6604
|
|
56
|
+
cognite/neat/graph/extractors/_classic_cdf/_base.py,sha256=5jCegqeqQr_Bxwskt0ns7aiivzz1KyEIxqD5Xojoa7Y,5071
|
|
57
|
+
cognite/neat/graph/extractors/_classic_cdf/_classic.py,sha256=Al4lO-vydyrqFjAt_OanmuIjd2fM4SS1TtukZj3YBM8,10186
|
|
58
|
+
cognite/neat/graph/extractors/_classic_cdf/_data_sets.py,sha256=_jn2YM_87flrJ2pdLUKApQ3I1M02zjnhDSGKhl0vdDU,4297
|
|
59
|
+
cognite/neat/graph/extractors/_classic_cdf/_events.py,sha256=08c1IavgRWdBem8YbSQnzXEYa41QYojmTilzZBbfAR0,6508
|
|
60
|
+
cognite/neat/graph/extractors/_classic_cdf/_files.py,sha256=hi5Zf_-JWbRN1wEoGc-JIT81YOcWGxWwPAh162Urs4s,7554
|
|
61
|
+
cognite/neat/graph/extractors/_classic_cdf/_labels.py,sha256=fNi_eqG2rfxMHyPUzAqRSARp_QRY3drYHH_WcoLzz0M,4766
|
|
62
|
+
cognite/neat/graph/extractors/_classic_cdf/_relationships.py,sha256=wSYQK1QiRD9aYnjOJWXOCjpEnpH6s0LqPcqi3gC9ckU,8792
|
|
63
|
+
cognite/neat/graph/extractors/_classic_cdf/_sequences.py,sha256=HMC-tmGE1Wgc7c1KeDyx0BlnYOxGbyhUHkoOHl1Yz60,6006
|
|
64
|
+
cognite/neat/graph/extractors/_classic_cdf/_timeseries.py,sha256=ZO7-dgIq7EavvmVfo0gAWHHM_WoNcfPJe7zRArt4W6w,7502
|
|
65
|
+
cognite/neat/graph/extractors/_dexpi.py,sha256=s3Ff3s3CMy0Xalixtfvnu-3yrEsCF26-9WVhIIZBZQI,9432
|
|
64
66
|
cognite/neat/graph/extractors/_dms.py,sha256=NbqY1nrisn-dJq8_qeCatpgJwm6-cKFsTISDR5afdbU,6688
|
|
67
|
+
cognite/neat/graph/extractors/_iodd.py,sha256=RiUxhVsV99YxrWjMxPQcLQzYG0xLYqZCEHduCoG6P8Q,6759
|
|
65
68
|
cognite/neat/graph/extractors/_mock_graph_generator.py,sha256=ES-7__o750BJFC9rNWt5HRO5M53iZuzv-8lBqLIXdC0,15365
|
|
66
69
|
cognite/neat/graph/extractors/_rdf_file.py,sha256=ialMCLv9WH5k6v1YMfozfcmAYhz8OVo9jVhsKMyQkDA,763
|
|
67
70
|
cognite/neat/graph/loaders/__init__.py,sha256=TbeJqifd16JLOglPVNOeb6pN_w060UYag50KquBM_r0,769
|
|
@@ -78,7 +81,7 @@ cognite/neat/graph/transformers/_base.py,sha256=b37Ek-9njuM5pTR_3XhnxCMrg_ip_2BM
|
|
|
78
81
|
cognite/neat/graph/transformers/_classic_cdf.py,sha256=6xX-OBSJT5DAQrTJ-nuhCfGNaSk5Iktxn-WIMfzEIqo,13189
|
|
79
82
|
cognite/neat/graph/transformers/_rdfpath.py,sha256=VLtGJvTPT5SWhV98fuGGt0pptTXfzOOQSNehypsPHug,1861
|
|
80
83
|
cognite/neat/issues/__init__.py,sha256=KkBEO-0Lg3vdvjrQtxKR6Wy2iV2mooc9utSO8-_9UuI,405
|
|
81
|
-
cognite/neat/issues/_base.py,sha256=
|
|
84
|
+
cognite/neat/issues/_base.py,sha256=_M2HTJpgAzoZXS6Ap-elyyzylQFXew0AKbKWvodQ_R8,15518
|
|
82
85
|
cognite/neat/issues/errors/__init__.py,sha256=t23ZnbWOZEhd77Ae_gpAxMPAIWOTbt7-wi6yeCmlGZE,2077
|
|
83
86
|
cognite/neat/issues/errors/_external.py,sha256=TUdihRyr5amdGSzSU49hWz7N7BSPCTVo7glKFNDrc5w,1583
|
|
84
87
|
cognite/neat/issues/errors/_general.py,sha256=Dtt4kEfNyj-CxpowsVVrq2eAwWEzx68JpPnS48QoY2U,787
|
|
@@ -105,9 +108,9 @@ cognite/neat/rules/examples/wind-energy.owl,sha256=NuomCA9FuuLF0JlSuG3OKqD4VBcHg
|
|
|
105
108
|
cognite/neat/rules/exporters/__init__.py,sha256=nRMUBUf7yr1QPjyITeX2rTLtLLawHv24hhRE39d2-e0,1109
|
|
106
109
|
cognite/neat/rules/exporters/_base.py,sha256=Er8G2DRNUtD1RbDOe9_c6H8cVwXbkTQzGfqof7J9OhA,1329
|
|
107
110
|
cognite/neat/rules/exporters/_rules2dms.py,sha256=UekIEl9m-ZHu7AjPr0yaDrAkE3AMJaTcL2dkYdE17Ko,14448
|
|
108
|
-
cognite/neat/rules/exporters/_rules2excel.py,sha256=
|
|
111
|
+
cognite/neat/rules/exporters/_rules2excel.py,sha256=BqXEDORmshvBZMMsDs8LXOPILl2gf5I0kyVmTodtanY,14223
|
|
109
112
|
cognite/neat/rules/exporters/_rules2ontology.py,sha256=qrSY8se-AUABaJt_7NOH46Htoq6mXAEMO4eN3dCzvG8,21705
|
|
110
|
-
cognite/neat/rules/exporters/_rules2yaml.py,sha256=
|
|
113
|
+
cognite/neat/rules/exporters/_rules2yaml.py,sha256=7N8Y5jXnt8I8TVGBP9pDtw838VCxWFeA3B-JZZou5GE,3195
|
|
111
114
|
cognite/neat/rules/exporters/_validation.py,sha256=A0kyrIEu51ZXl47CXmO4ZOT0whO5iKNwMY-BwMc2scA,680
|
|
112
115
|
cognite/neat/rules/importers/__init__.py,sha256=z682_ktGKDjr52DIL6cPvOercZS6-TYD_ZDo-MGqtck,1207
|
|
113
116
|
cognite/neat/rules/importers/_base.py,sha256=G9apdRztiAdnzX3LyZ-SNaavXagvtta2BQXFqEOQw_g,2851
|
|
@@ -132,45 +135,42 @@ cognite/neat/rules/importers/_rdf/_owl2rules/_owl2rules.py,sha256=nH_hJGIEG9LKAj
|
|
|
132
135
|
cognite/neat/rules/importers/_rdf/_shared.py,sha256=qZuJm2LiB_eScbRkoTOL7Qf6CJQ124Dv2Kxylo-Rzts,19771
|
|
133
136
|
cognite/neat/rules/importers/_spreadsheet2rules.py,sha256=2GhBLEq6jyu2TbnX6MTlSx4LaWOdSfz213Lo45nTaM4,11036
|
|
134
137
|
cognite/neat/rules/importers/_yaml2rules.py,sha256=aap5Nso_7EBNrHtG4pt8tT4jNzCYUQz4twHdmqrGya8,3139
|
|
135
|
-
cognite/neat/rules/models/__init__.py,sha256=
|
|
136
|
-
cognite/neat/rules/models/_base_input.py,sha256=
|
|
137
|
-
cognite/neat/rules/models/_base_rules.py,sha256=
|
|
138
|
+
cognite/neat/rules/models/__init__.py,sha256=ZqbSC2UhPtq31P1RUHoiXGO2q6FoPwqUvrTorpgLZTU,1524
|
|
139
|
+
cognite/neat/rules/models/_base_input.py,sha256=fw8v9PSZO6wgVwDHvfW9m39ipX4hXvxoSmpK51kbaMU,5869
|
|
140
|
+
cognite/neat/rules/models/_base_rules.py,sha256=QbcAg1cmsWzQtADyhqVEiX1PT_XsW-37YXVR1NIBtSw,12940
|
|
138
141
|
cognite/neat/rules/models/_rdfpath.py,sha256=oyMpmL_t0R5Uocdm3CA9iDLT2ZJVr2BIuz4cxaUlabM,11881
|
|
139
142
|
cognite/neat/rules/models/_types.py,sha256=VM40gfADOzw5UFy-olCBotComra0MsAafjyUlaIgFV8,2875
|
|
140
143
|
cognite/neat/rules/models/asset/__init__.py,sha256=Z2tQEABW-q66bmHNcxMuIxPmYQBcGdiSZt7fHGe01dQ,363
|
|
141
|
-
cognite/neat/rules/models/asset/_rules.py,sha256=
|
|
144
|
+
cognite/neat/rules/models/asset/_rules.py,sha256=XVwSnThm-C4FWafo4iD28JJVynQP9VhA2JQ1107g_jk,4003
|
|
142
145
|
cognite/neat/rules/models/asset/_rules_input.py,sha256=2Skh7OVk2X5k7L62O8uZvLmpogJfQeYD7lZbzejEZRw,3375
|
|
143
|
-
cognite/neat/rules/models/asset/_serializer.py,sha256=ixqRf9qEzvChgysRaDX4g_vHVDtRBCsPYC9sOn0-ShE,3365
|
|
144
146
|
cognite/neat/rules/models/asset/_validation.py,sha256=3goorodISq_mlyXroaivcMOZ-QV8sd27IK9-iGKnQ28,2014
|
|
145
147
|
cognite/neat/rules/models/data_types.py,sha256=jTYsWqQPuvwHytInRU0Y2TGF4aVBF83v0vp_SH9KgLA,9722
|
|
146
148
|
cognite/neat/rules/models/dms/__init__.py,sha256=CUqUlVjz4yZX_-61F-2ofSoV7N9MlSYx2N7vM-omp7E,640
|
|
147
149
|
cognite/neat/rules/models/dms/_exporter.py,sha256=4XiFCeXZOZuj5Ke1E-_rQJvPIcyRl7lIb2dHCfkYS4M,28126
|
|
148
|
-
cognite/neat/rules/models/dms/_rules.py,sha256=
|
|
150
|
+
cognite/neat/rules/models/dms/_rules.py,sha256=Tx36M7nc0ryLMYlwBMdrKpgdGSIBTLuKjE0vbuoApVQ,19184
|
|
149
151
|
cognite/neat/rules/models/dms/_rules_input.py,sha256=v5-zlb4VJi5Q610rnPLU1aHKzXmGwoUTrDzAkJFfEQY,10911
|
|
150
152
|
cognite/neat/rules/models/dms/_schema.py,sha256=lc6Q0EUchOAUSTRiJnWc6UPBz7LjCW5NEvIGwNakcSI,50724
|
|
151
|
-
cognite/neat/rules/models/dms/
|
|
152
|
-
cognite/neat/rules/models/
|
|
153
|
-
cognite/neat/rules/models/domain.py,sha256=YtVb3JIkZfcA9qrMA-RapHMv-_Q40JtxrY1oLVOFev0,4298
|
|
153
|
+
cognite/neat/rules/models/dms/_validation.py,sha256=EnupSDjeCi-Sqs6ube1wQ2FxL3DP5O8vUaSojWqT-I0,15790
|
|
154
|
+
cognite/neat/rules/models/domain.py,sha256=zAxXb9719XJEn-s_m9JMhE7RSDW9f6LY7CJ84KAjM1E,3950
|
|
154
155
|
cognite/neat/rules/models/entities/__init__.py,sha256=ORRN2bkgbotGKAzxU66ff5JrbWd9z6wCISjgICBpFdA,1501
|
|
155
156
|
cognite/neat/rules/models/entities/_constants.py,sha256=r_Knlqmmb6QFgiSS0Yb_9UrhwYnaSBCYy2Wt9gODLhw,2316
|
|
156
157
|
cognite/neat/rules/models/entities/_loaders.py,sha256=uzMRAULggTxrP3B27_78i6anui3br4Ck6o9vmctqxkk,2691
|
|
157
158
|
cognite/neat/rules/models/entities/_multi_value.py,sha256=3DejtsIWJOA96y9wZMhjDBP5lOxJH9l27YZUxr9JIEY,2060
|
|
158
|
-
cognite/neat/rules/models/entities/_single_value.py,sha256=
|
|
159
|
-
cognite/neat/rules/models/entities/_types.py,sha256=
|
|
159
|
+
cognite/neat/rules/models/entities/_single_value.py,sha256=lqz-3LY5qB6Q4nVIZQxpKHzppq7ZJC6FRKZMcBKDqVs,17078
|
|
160
|
+
cognite/neat/rules/models/entities/_types.py,sha256=df9rnXJJKciv2Bp-Ve2q4xdEJt6WWniq12Z0hW2d6sk,1917
|
|
160
161
|
cognite/neat/rules/models/entities/_wrapped.py,sha256=FxC8HztW_tUUtuArAOwxyFfkdJnSEB4bgZoNmmmfiPk,7137
|
|
161
162
|
cognite/neat/rules/models/information/__init__.py,sha256=fVvgXt-JuyZCP_mLgIVaeKD9pdAXe2BWUxU_BZs8e5g,480
|
|
162
|
-
cognite/neat/rules/models/information/_rules.py,sha256=
|
|
163
|
+
cognite/neat/rules/models/information/_rules.py,sha256=sPZdZ2ed7Wk0OEgi90niUXNii-tw3mf8yAw8-fRGnD4,14361
|
|
163
164
|
cognite/neat/rules/models/information/_rules_input.py,sha256=wKBISvbJ5IsPhl72hsF4hmOiza8nqN-4tTczl-Mif-w,5274
|
|
164
|
-
cognite/neat/rules/models/information/
|
|
165
|
-
cognite/neat/rules/models/information/_validation.py,sha256=Fa5S-rQozSCkIDpS4dPQn7U0lM71DOecAMCqL8K8Uag,9230
|
|
165
|
+
cognite/neat/rules/models/information/_validation.py,sha256=mOgtIUwkXn9VZIKkdbPidWn8uepPfh9pUfkldQCWB0c,9205
|
|
166
166
|
cognite/neat/rules/transformers/__init__.py,sha256=Iun5-3uDmzUzcO4IFneJ453PWAx6F_c-5LhkvrIrSc0,666
|
|
167
167
|
cognite/neat/rules/transformers/_base.py,sha256=FABG_8Xg_LUZPwVLQmKvxlcIDtI5phGLpEGpxNcJWNM,3269
|
|
168
|
-
cognite/neat/rules/transformers/_converters.py,sha256=
|
|
168
|
+
cognite/neat/rules/transformers/_converters.py,sha256=mFOAdERJZf_loCaCiAJLqMOh86E5cvUds6b-S-X3fJs,22703
|
|
169
169
|
cognite/neat/rules/transformers/_map_onto.py,sha256=eXPhontrcJdRm2ILopwkFoPcwfM8L-BNv-CapL30klg,4824
|
|
170
|
-
cognite/neat/rules/transformers/_pipelines.py,sha256=
|
|
170
|
+
cognite/neat/rules/transformers/_pipelines.py,sha256=O7hkHuuKiAgsjgJXnTQL8wweOXNjEUyNVj4i1hGwk_E,2599
|
|
171
171
|
cognite/neat/rules/transformers/_verification.py,sha256=rPSeDKkpe-hCJ0iiBx6yycvSANwnCS78PUFTDYgmNcA,4448
|
|
172
172
|
cognite/neat/store/__init__.py,sha256=G-VG_YwfRt1kuPao07PDJyZ3w_0-eguzLUM13n-Z_RA,64
|
|
173
|
-
cognite/neat/store/_base.py,sha256=
|
|
173
|
+
cognite/neat/store/_base.py,sha256=EGeG7lzmb-PdUk2q5CywAHrt37Yr6PVRd4HP2VOIDSE,12466
|
|
174
174
|
cognite/neat/store/_provenance.py,sha256=sniVJhLmvj0ulKhoUZzFLwjAsp7cQyRPxunZtLmMW4A,3902
|
|
175
175
|
cognite/neat/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
176
176
|
cognite/neat/utils/auth.py,sha256=k0sEfTpK_bamMjAkj7jN6n9yta8TaqHTFkZUjUgpwik,12770
|
|
@@ -181,14 +181,14 @@ cognite/neat/utils/cdf/loaders/__init__.py,sha256=s2aPR5XLo6WZ0ybstAJlcGFYkA7CyH
|
|
|
181
181
|
cognite/neat/utils/cdf/loaders/_base.py,sha256=ryNC_AMXIESWXuTVJ-02L-HSVSpD6V49XdLTRYeFg70,1764
|
|
182
182
|
cognite/neat/utils/cdf/loaders/_data_modeling.py,sha256=0jynnwZ7utnG2KIkVRJBNvDshUCzwX29LZuGSlm6qUM,13216
|
|
183
183
|
cognite/neat/utils/cdf/loaders/_ingestion.py,sha256=QbF4ntaGUum6yTRTq9WNg8n49TQpfzF1T7H-Bx740ws,6326
|
|
184
|
-
cognite/neat/utils/collection_.py,sha256=
|
|
184
|
+
cognite/neat/utils/collection_.py,sha256=m5pn78NRQ9vx8l-NdMTAdYDLCTB8CQLX-rqxAWt7vyg,602
|
|
185
185
|
cognite/neat/utils/rdf_.py,sha256=VXDBQUt86vRntiGhejK35PlsbvKCUkuQQa1cMYz4SIc,5656
|
|
186
186
|
cognite/neat/utils/regex_patterns.py,sha256=rXOBW9d-n_eAffm9zVRIPFB7ElLS8VDdsvFDsr01Q-M,2155
|
|
187
187
|
cognite/neat/utils/spreadsheet.py,sha256=LI0c7dlW0zXHkHw0NvB-gg6Df6cDcE3FbiaHBYLXdzQ,2714
|
|
188
188
|
cognite/neat/utils/text.py,sha256=PvTEsEjaTu8SE8yYaKUrce4msboMj933dK7-0Eey_rE,3652
|
|
189
189
|
cognite/neat/utils/time_.py,sha256=O30LUiDH9TdOYz8_a9pFqTtJdg8vEjC3qHCk8xZblG8,345
|
|
190
190
|
cognite/neat/utils/upload.py,sha256=7yQZZM1SFEC-Dhl12rQD_8gUoRKLwmWhNjsImVB18og,4015
|
|
191
|
-
cognite/neat/utils/xml_.py,sha256=
|
|
191
|
+
cognite/neat/utils/xml_.py,sha256=FQkq84u35MUsnKcL6nTMJ9ajtG9D5i1u4VBnhGqP2DQ,1710
|
|
192
192
|
cognite/neat/workflows/__init__.py,sha256=oiKub_U9f5cA0I1nKl5dFkR4BD8_6Be9eMzQ_50PwP0,396
|
|
193
193
|
cognite/neat/workflows/base.py,sha256=pWsUCtHVjdDe_N_pbQpmYLji-iN2U-H1G13aJbAXy7M,26829
|
|
194
194
|
cognite/neat/workflows/cdf_store.py,sha256=Ao6YnZ5wnZtP1wdnDQM7Hj2G7NqtLzBOKn4LJQS-8AU,18047
|
|
@@ -216,8 +216,8 @@ cognite/neat/workflows/steps_registry.py,sha256=FjMsFBlFFy82ABUzDnWoFidYODV3pp3c
|
|
|
216
216
|
cognite/neat/workflows/tasks.py,sha256=dqlJwKAb0jlkl7abbY8RRz3m7MT4SK8-7cntMWkOYjw,788
|
|
217
217
|
cognite/neat/workflows/triggers.py,sha256=_BLNplzoz0iic367u1mhHMHiUrCwP-SLK6_CZzfODX0,7071
|
|
218
218
|
cognite/neat/workflows/utils.py,sha256=gKdy3RLG7ctRhbCRwaDIWpL9Mi98zm56-d4jfHDqP1E,453
|
|
219
|
-
cognite_neat-0.
|
|
220
|
-
cognite_neat-0.
|
|
221
|
-
cognite_neat-0.
|
|
222
|
-
cognite_neat-0.
|
|
223
|
-
cognite_neat-0.
|
|
219
|
+
cognite_neat-0.92.0.dist-info/LICENSE,sha256=W8VmvFia4WHa3Gqxq1Ygrq85McUNqIGDVgtdvzT-XqA,11351
|
|
220
|
+
cognite_neat-0.92.0.dist-info/METADATA,sha256=8OGqjdL0GxN24BpF4M5sd-MVbIUCxh62V8iN_NMnz00,9441
|
|
221
|
+
cognite_neat-0.92.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
|
222
|
+
cognite_neat-0.92.0.dist-info/entry_points.txt,sha256=61FPqiWb25vbqB0KI7znG8nsg_ibLHBvTjYnkPvNFso,50
|
|
223
|
+
cognite_neat-0.92.0.dist-info/RECORD,,
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
from typing import Any, ClassVar
|
|
2
|
-
|
|
3
|
-
from cognite.neat.rules.models.entities import ClassEntity, ReferenceEntity
|
|
4
|
-
|
|
5
|
-
from ._rules import AssetClass, AssetProperty, AssetRules
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class _AssetRulesSerializer:
|
|
9
|
-
# These are the fields that need to be cleaned from the default space and version
|
|
10
|
-
PROPERTIES_FIELDS: ClassVar[list[str]] = ["class_", "value_type"]
|
|
11
|
-
CLASSES_FIELDS: ClassVar[list[str]] = ["class_"]
|
|
12
|
-
|
|
13
|
-
def __init__(self, by_alias: bool, default_prefix: str) -> None:
|
|
14
|
-
self.default_prefix = f"{default_prefix}:"
|
|
15
|
-
|
|
16
|
-
self.properties_fields = self.PROPERTIES_FIELDS
|
|
17
|
-
self.classes_fields = self.CLASSES_FIELDS
|
|
18
|
-
|
|
19
|
-
self.prop_name = "properties"
|
|
20
|
-
self.class_name = "classes"
|
|
21
|
-
self.metadata_name = "metadata"
|
|
22
|
-
self.class_parent = "parent"
|
|
23
|
-
|
|
24
|
-
self.prop_property = "property_"
|
|
25
|
-
self.prop_class = "class_"
|
|
26
|
-
|
|
27
|
-
self.reference = "Reference" if by_alias else "reference"
|
|
28
|
-
if by_alias:
|
|
29
|
-
self.properties_fields = [
|
|
30
|
-
AssetProperty.model_fields[field].alias or field for field in self.properties_fields
|
|
31
|
-
]
|
|
32
|
-
self.classes_fields = [AssetClass.model_fields[field].alias or field for field in self.classes_fields]
|
|
33
|
-
self.prop_name = AssetRules.model_fields[self.prop_name].alias or self.prop_name
|
|
34
|
-
self.class_name = AssetRules.model_fields[self.class_name].alias or self.class_name
|
|
35
|
-
self.class_parent = AssetClass.model_fields[self.class_parent].alias or self.class_parent
|
|
36
|
-
self.metadata_name = AssetRules.model_fields[self.metadata_name].alias or self.metadata_name
|
|
37
|
-
|
|
38
|
-
self.prop_property = AssetProperty.model_fields[self.prop_property].alias or self.prop_property
|
|
39
|
-
self.prop_class = AssetProperty.model_fields[self.prop_class].alias or self.prop_class
|
|
40
|
-
|
|
41
|
-
def clean(self, dumped: dict[str, Any], as_reference: bool) -> dict[str, Any]:
|
|
42
|
-
# Sorting to get a deterministic order
|
|
43
|
-
dumped[self.prop_name] = sorted(
|
|
44
|
-
dumped[self.prop_name]["data"], key=lambda p: (p[self.prop_class], p[self.prop_property])
|
|
45
|
-
)
|
|
46
|
-
dumped[self.class_name] = sorted(dumped[self.class_name]["data"], key=lambda v: v[self.prop_class])
|
|
47
|
-
|
|
48
|
-
for prop in dumped[self.prop_name]:
|
|
49
|
-
if as_reference:
|
|
50
|
-
class_entity = ClassEntity.load(prop[self.prop_class])
|
|
51
|
-
prop[self.reference] = str(
|
|
52
|
-
ReferenceEntity(
|
|
53
|
-
prefix=str(class_entity.prefix), suffix=class_entity.suffix, property=prop[self.prop_property]
|
|
54
|
-
)
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
for field_name in self.properties_fields:
|
|
58
|
-
if value := prop.get(field_name):
|
|
59
|
-
prop[field_name] = value.removeprefix(self.default_prefix)
|
|
60
|
-
|
|
61
|
-
for class_ in dumped[self.class_name]:
|
|
62
|
-
if as_reference:
|
|
63
|
-
class_[self.reference] = class_[self.prop_class]
|
|
64
|
-
for field_name in self.classes_fields:
|
|
65
|
-
if value := class_.get(field_name):
|
|
66
|
-
class_[field_name] = value.removeprefix(self.default_prefix)
|
|
67
|
-
|
|
68
|
-
if value := class_.get(self.class_parent):
|
|
69
|
-
class_[self.class_parent] = ",".join(
|
|
70
|
-
parent.strip().removeprefix(self.default_prefix) for parent in value.split(",")
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
return dumped
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
from typing import Any, ClassVar, cast
|
|
2
|
-
|
|
3
|
-
from cognite.neat.rules.models import DMSRules
|
|
4
|
-
from cognite.neat.rules.models.dms import DMSContainer, DMSEnum, DMSNode, DMSProperty, DMSView
|
|
5
|
-
from cognite.neat.rules.models.entities import ReferenceEntity, ViewEntity
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
class _DMSRulesSerializer:
|
|
9
|
-
# These are the fields that need to be cleaned from the default space and version
|
|
10
|
-
PROPERTIES_FIELDS: ClassVar[list[str]] = ["class_", "view", "value_type", "container"]
|
|
11
|
-
VIEWS_FIELDS: ClassVar[list[str]] = ["class_", "view", "implements"]
|
|
12
|
-
CONTAINERS_FIELDS: ClassVar[list[str]] = ["class_", "container"]
|
|
13
|
-
|
|
14
|
-
def __init__(self, by_alias: bool, default_space: str, default_version: str) -> None:
|
|
15
|
-
self.default_space = f"{default_space}:"
|
|
16
|
-
self.default_version = f"version={default_version}"
|
|
17
|
-
self.default_version_wrapped = f"({self.default_version})"
|
|
18
|
-
|
|
19
|
-
self.properties_fields = self.PROPERTIES_FIELDS
|
|
20
|
-
self.views_fields = self.VIEWS_FIELDS
|
|
21
|
-
self.containers_fields = self.CONTAINERS_FIELDS
|
|
22
|
-
self.prop_name = "properties"
|
|
23
|
-
self.view_name = "views"
|
|
24
|
-
self.container_name = "containers"
|
|
25
|
-
self.metadata_name = "metadata"
|
|
26
|
-
self.enum_name = "enum"
|
|
27
|
-
self.nodes_name = "nodes"
|
|
28
|
-
self.prop_view = "view"
|
|
29
|
-
self.prop_container = "container"
|
|
30
|
-
self.prop_view_property = "view_property"
|
|
31
|
-
self.prop_value_type = "value_type"
|
|
32
|
-
self.prop_connection = "connection"
|
|
33
|
-
self.view_view = "view"
|
|
34
|
-
self.view_implements = "implements"
|
|
35
|
-
self.container_container = "container"
|
|
36
|
-
self.container_constraint = "constraint"
|
|
37
|
-
self.nodes_node = "node"
|
|
38
|
-
self.enum_collection = "collection"
|
|
39
|
-
self.reference = "Reference" if by_alias else "reference"
|
|
40
|
-
|
|
41
|
-
if by_alias:
|
|
42
|
-
self.properties_fields = [
|
|
43
|
-
DMSProperty.model_fields[field].alias or field for field in self.properties_fields
|
|
44
|
-
]
|
|
45
|
-
self.views_fields = [DMSView.model_fields[field].alias or field for field in self.views_fields]
|
|
46
|
-
self.containers_fields = [
|
|
47
|
-
DMSContainer.model_fields[field].alias or field for field in self.containers_fields
|
|
48
|
-
]
|
|
49
|
-
self.prop_view = DMSProperty.model_fields[self.prop_view].alias or self.prop_view
|
|
50
|
-
self.prop_container = DMSProperty.model_fields[self.prop_container].alias or self.prop_container
|
|
51
|
-
self.prop_view_property = DMSProperty.model_fields[self.prop_view_property].alias or self.prop_view_property
|
|
52
|
-
self.prop_value_type = DMSProperty.model_fields[self.prop_value_type].alias or self.prop_value_type
|
|
53
|
-
self.prop_connection = DMSProperty.model_fields[self.prop_connection].alias or self.prop_connection
|
|
54
|
-
self.view_view = DMSView.model_fields[self.view_view].alias or self.view_view
|
|
55
|
-
self.view_implements = DMSView.model_fields[self.view_implements].alias or self.view_implements
|
|
56
|
-
self.container_container = (
|
|
57
|
-
DMSContainer.model_fields[self.container_container].alias or self.container_container
|
|
58
|
-
)
|
|
59
|
-
self.container_constraint = (
|
|
60
|
-
DMSContainer.model_fields[self.container_constraint].alias or self.container_constraint
|
|
61
|
-
)
|
|
62
|
-
self.nodes_node = DMSNode.model_fields[self.nodes_node].alias or self.nodes_node
|
|
63
|
-
|
|
64
|
-
self.prop_name = DMSRules.model_fields[self.prop_name].alias or self.prop_name
|
|
65
|
-
self.view_name = DMSRules.model_fields[self.view_name].alias or self.view_name
|
|
66
|
-
self.container_name = DMSRules.model_fields[self.container_name].alias or self.container_name
|
|
67
|
-
self.metadata_name = DMSRules.model_fields[self.metadata_name].alias or self.metadata_name
|
|
68
|
-
self.nodes_name = DMSRules.model_fields[self.nodes_name].alias or self.nodes_name
|
|
69
|
-
self.enum_name = DMSRules.model_fields[self.enum_name].alias or self.enum_name
|
|
70
|
-
self.enum_collection = DMSEnum.model_fields[self.enum_collection].alias or self.enum_collection
|
|
71
|
-
|
|
72
|
-
def clean(self, dumped: dict[str, Any], as_reference: bool) -> dict[str, Any]:
|
|
73
|
-
# Sorting to get a deterministic order
|
|
74
|
-
dumped[self.prop_name] = sorted(
|
|
75
|
-
dumped[self.prop_name]["data"], key=lambda p: (p[self.prop_view], p[self.prop_view_property])
|
|
76
|
-
)
|
|
77
|
-
dumped[self.view_name] = sorted(dumped[self.view_name]["data"], key=lambda v: v[self.view_view])
|
|
78
|
-
if container_data := dumped.get(self.container_name):
|
|
79
|
-
dumped[self.container_name] = sorted(container_data["data"], key=lambda c: c[self.container_container])
|
|
80
|
-
else:
|
|
81
|
-
dumped.pop(self.container_name, None)
|
|
82
|
-
|
|
83
|
-
if enum_data := dumped.get(self.enum_name):
|
|
84
|
-
dumped[self.enum_name] = sorted(enum_data["data"], key=lambda e: e[self.enum_collection])
|
|
85
|
-
else:
|
|
86
|
-
dumped.pop(self.enum_name, None)
|
|
87
|
-
|
|
88
|
-
if node_types_data := dumped.get(self.nodes_name):
|
|
89
|
-
dumped[self.nodes_name] = sorted(node_types_data["data"], key=lambda n: n[self.nodes_node])
|
|
90
|
-
else:
|
|
91
|
-
dumped.pop(self.nodes_name, None)
|
|
92
|
-
|
|
93
|
-
for prop in dumped[self.prop_name]:
|
|
94
|
-
if as_reference:
|
|
95
|
-
view_entity = cast(ViewEntity, ViewEntity.load(prop[self.prop_view]))
|
|
96
|
-
prop[self.reference] = str(
|
|
97
|
-
ReferenceEntity(
|
|
98
|
-
prefix=view_entity.prefix,
|
|
99
|
-
suffix=view_entity.suffix,
|
|
100
|
-
version=view_entity.version,
|
|
101
|
-
property=prop[self.prop_view_property],
|
|
102
|
-
)
|
|
103
|
-
)
|
|
104
|
-
for field_name in self.properties_fields:
|
|
105
|
-
if as_reference and field_name == self.prop_container:
|
|
106
|
-
# When dumping as reference, the container should keep the default space for easy copying
|
|
107
|
-
# over to user sheets.
|
|
108
|
-
continue
|
|
109
|
-
if value := prop.get(field_name):
|
|
110
|
-
prop[field_name] = value.removeprefix(self.default_space).removesuffix(self.default_version_wrapped)
|
|
111
|
-
if isinstance(prop.get(self.prop_connection), str):
|
|
112
|
-
# Remove default values from connection (type, direction, properties)
|
|
113
|
-
default_type = f"type={self.default_space}{prop[self.view_view]}.{prop[self.prop_view_property]}"
|
|
114
|
-
default_type_space = f"type={self.default_space}"
|
|
115
|
-
default_properties = f"properties={self.default_space}"
|
|
116
|
-
default_direction = "direction=outwards"
|
|
117
|
-
prop[self.prop_connection] = (
|
|
118
|
-
prop[self.prop_connection]
|
|
119
|
-
.replace(self.default_version, "")
|
|
120
|
-
.replace(default_type, "")
|
|
121
|
-
.replace(default_type_space, "type=")
|
|
122
|
-
.replace(default_properties, "properties=")
|
|
123
|
-
.replace(default_direction, "")
|
|
124
|
-
.replace("()", "")
|
|
125
|
-
.replace("(,)", "")
|
|
126
|
-
.replace("(,,)", "")
|
|
127
|
-
.replace("(,", "(")
|
|
128
|
-
.replace(",)", ")")
|
|
129
|
-
)
|
|
130
|
-
|
|
131
|
-
for view in dumped[self.view_name]:
|
|
132
|
-
if as_reference:
|
|
133
|
-
view[self.reference] = view[self.view_view]
|
|
134
|
-
for field_name in self.views_fields:
|
|
135
|
-
if value := view.get(field_name):
|
|
136
|
-
view[field_name] = value.removeprefix(self.default_space).removesuffix(self.default_version_wrapped)
|
|
137
|
-
if value := view.get(self.view_implements):
|
|
138
|
-
view[self.view_implements] = ",".join(
|
|
139
|
-
parent.strip().removeprefix(self.default_space).removesuffix(self.default_version_wrapped)
|
|
140
|
-
for parent in value.split(",")
|
|
141
|
-
)
|
|
142
|
-
|
|
143
|
-
for container in dumped.get(self.container_name, []):
|
|
144
|
-
if as_reference:
|
|
145
|
-
container[self.reference] = container[self.container_container]
|
|
146
|
-
for field_name in self.containers_fields:
|
|
147
|
-
if value := container.get(field_name):
|
|
148
|
-
container[field_name] = value.removeprefix(self.default_space)
|
|
149
|
-
|
|
150
|
-
if value := container.get(self.container_constraint):
|
|
151
|
-
container[self.container_constraint] = ",".join(
|
|
152
|
-
constraint.strip().removeprefix(self.default_space) for constraint in value.split(",")
|
|
153
|
-
)
|
|
154
|
-
|
|
155
|
-
for node in dumped.get(self.nodes_name, []):
|
|
156
|
-
node[self.nodes_node] = node[self.nodes_node].removeprefix(self.default_space)
|
|
157
|
-
return dumped
|