armodel 1.7.7__py3-none-any.whl → 1.7.9__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.
- armodel/cli/arxml_dump_cli.py +33 -22
- armodel/cli/arxml_format_cli.py +25 -13
- armodel/models/M2/AUTOSARTemplates/AutosarTopLevelStructure.py +84 -28
- armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswBehavior.py +410 -61
- armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswInterfaces.py +80 -9
- armodel/models/M2/AUTOSARTemplates/BswModuleTemplate/BswOverview.py +141 -35
- armodel/models/M2/AUTOSARTemplates/CommonStructure/Implementation.py +10 -8
- armodel/models/M2/AUTOSARTemplates/CommonStructure/InternalBehavior.py +17 -6
- armodel/models/M2/AUTOSARTemplates/CommonStructure/ModeDeclaration.py +38 -3
- armodel/models/M2/AUTOSARTemplates/CommonStructure/ServiceNeeds.py +91 -18
- armodel/models/M2/AUTOSARTemplates/CommonStructure/StandardizationTemplate/BlueprintDedicated/PortPrototypeBlueprint.py +73 -0
- armodel/models/M2/AUTOSARTemplates/CommonStructure/StandardizationTemplate/BlueprintDedicated/__init__.py +0 -0
- armodel/models/M2/AUTOSARTemplates/CommonStructure/StandardizationTemplate/Keyword.py +45 -0
- armodel/models/M2/AUTOSARTemplates/CommonStructure/StandardizationTemplate/__init__.py +0 -0
- armodel/models/M2/AUTOSARTemplates/CommonStructure/TriggerDeclaration.py +45 -2
- armodel/models/M2/AUTOSARTemplates/ECUCDescriptionTemplate.py +20 -19
- armodel/models/M2/AUTOSARTemplates/EcuResourceTemplate/HwElementCategory.py +59 -0
- armodel/models/M2/AUTOSARTemplates/EcuResourceTemplate/__init__.py +145 -0
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/ARPackage.py +243 -156
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/ElementCollection.py +73 -0
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/Identifiable.py +60 -32
- armodel/models/M2/AUTOSARTemplates/GenericStructure/GeneralTemplateClasses/PrimitiveTypes.py +35 -14
- armodel/models/M2/AUTOSARTemplates/GenericStructure/LifeCycles.py +151 -1
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Components/__init__.py +66 -42
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/Composition/__init__.py +1 -0
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/EndToEndProtection.py +13 -6
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/PortInterface/__init__.py +166 -50
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SoftwareComponentDocumentation.py +80 -0
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/AccessCount.py +9 -1
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/ModeDeclarationGroup.py +5 -4
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/RTEEvents.py +11 -1
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/ServiceMapping.py +16 -2
- armodel/models/M2/AUTOSARTemplates/SWComponentTemplate/SwcInternalBehavior/__init__.py +9 -1
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/DataMapping.py +167 -5
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/{ECUResourceMapping.py → EcuResourceMapping.py} +4 -3
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Can/CanTopology.py +31 -21
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/EthernetFrame.py +5 -3
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Ethernet/EthernetTopology.py +18 -6
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/FlexrayCommunication.py +76 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/FlexrayTopology.py +654 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/Fibex4Flexray/__init__.py +0 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreCommunication.py +64 -31
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/CoreTopology.py +158 -40
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Fibex/FibexCore/EcuInstance.py +19 -6
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/InstanceRefs.py +2 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/Transformer/__init__.py +524 -0
- armodel/models/M2/AUTOSARTemplates/SystemTemplate/__init__.py +15 -13
- armodel/models/M2/MSR/DataDictionary/DataDefProperties.py +10 -1
- armodel/models/M2/MSR/Documentation/BlockElements/Figure.py +163 -0
- armodel/models/M2/MSR/Documentation/BlockElements/__init__.py +0 -0
- armodel/models/M2/MSR/Documentation/TextModel/BlockElements/ListElements.py +5 -3
- armodel/models/M2/MSR/Documentation/TextModel/BlockElements/PaginationAndView.py +22 -1
- armodel/models/M2/MSR/Documentation/TextModel/BlockElements/__init__.py +94 -9
- armodel/models/__init__.py +7 -1
- armodel/parser/abstract_arxml_parser.py +39 -32
- armodel/parser/arxml_parser.py +1439 -551
- armodel/parser/file_parser.py +5 -3
- armodel/tests/test_armodel/models/test_ar_package.py +6 -11
- armodel/tests/test_armodel/models/test_port_interface.py +116 -117
- armodel/tests/test_armodel/parser/test_bsw_module_descriiption.py +109 -109
- armodel/tests/test_armodel/parser/test_sw_components.py +301 -28
- armodel/tests/test_armodel/parser/test_system.py +2 -8
- armodel/transformer/__init__.py +0 -0
- armodel/transformer/abstract.py +6 -0
- armodel/transformer/admin_data.py +31 -0
- armodel/writer/abstract_arxml_writer.py +22 -29
- armodel/writer/arxml_writer.py +1500 -526
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/METADATA +61 -1
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/RECORD +73 -57
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/LICENSE +0 -0
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/WHEEL +0 -0
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/entry_points.txt +0 -0
- {armodel-1.7.7.dist-info → armodel-1.7.9.dist-info}/top_level.txt +0 -0
|
@@ -7,6 +7,7 @@ from ....writer.arxml_writer import ARXMLWriter
|
|
|
7
7
|
from ....parser.arxml_parser import ARXMLParser
|
|
8
8
|
from ....models.M2.AUTOSARTemplates.AutosarTopLevelStructure import AUTOSAR
|
|
9
9
|
|
|
10
|
+
|
|
10
11
|
class TestSWComponents:
|
|
11
12
|
def setup_method(self):
|
|
12
13
|
document = AUTOSAR.getInstance()
|
|
@@ -16,63 +17,63 @@ class TestSWComponents:
|
|
|
16
17
|
|
|
17
18
|
def test_ar_packages(self):
|
|
18
19
|
document = AUTOSAR.getInstance()
|
|
19
|
-
root_pkgs = sorted(document.getARPackages(), key
|
|
20
|
+
root_pkgs = sorted(document.getARPackages(), key=lambda pkg: pkg.getShortName())
|
|
20
21
|
|
|
21
|
-
assert(len(root_pkgs) == 1)
|
|
22
|
-
assert("DemoApplication" == root_pkgs[0].getShortName())
|
|
22
|
+
assert (len(root_pkgs) == 1)
|
|
23
|
+
assert ("DemoApplication" == root_pkgs[0].getShortName())
|
|
23
24
|
|
|
24
25
|
def test_sw_component(self):
|
|
25
26
|
document = AUTOSAR.getInstance()
|
|
26
27
|
sw_component = document.find("/DemoApplication/SwComponentTypes/SWC_CyclicCounter")
|
|
27
|
-
assert(sw_component.getShortName() == 'SWC_CyclicCounter')
|
|
28
|
-
assert(isinstance(sw_component, AtomicSwComponentType))
|
|
28
|
+
assert (sw_component.getShortName() == 'SWC_CyclicCounter')
|
|
29
|
+
assert (isinstance(sw_component, AtomicSwComponentType))
|
|
29
30
|
|
|
30
31
|
def test_get_implementation(self):
|
|
31
32
|
document = AUTOSAR.getInstance()
|
|
32
33
|
impl = document.getImplementation("/DemoApplication/SwComponentTypes/SWC_CyclicCounter/IB_SWC_CyclicCounter")
|
|
33
|
-
assert(impl.getFullName() == "/DemoApplication/SwcImplementations/Impl_SWC_CyclicCounter")
|
|
34
|
-
assert(isinstance(impl, SwcImplementation))
|
|
34
|
+
assert (impl.getFullName() == "/DemoApplication/SwcImplementations/Impl_SWC_CyclicCounter")
|
|
35
|
+
assert (isinstance(impl, SwcImplementation))
|
|
35
36
|
|
|
36
37
|
def test_get_behavior(self):
|
|
37
38
|
document = AUTOSAR.getInstance()
|
|
38
39
|
behavior = document.getBehavior("/DemoApplication/SwcImplementations/Impl_SWC_CyclicCounter")
|
|
39
|
-
assert(behavior.getFullName() == "/DemoApplication/SwComponentTypes/SWC_CyclicCounter/IB_SWC_CyclicCounter")
|
|
40
|
-
assert(isinstance(behavior, InternalBehavior))
|
|
40
|
+
assert (behavior.getFullName() == "/DemoApplication/SwComponentTypes/SWC_CyclicCounter/IB_SWC_CyclicCounter")
|
|
41
|
+
assert (isinstance(behavior, InternalBehavior))
|
|
41
42
|
|
|
42
43
|
def test_composition_sw_component_types(self):
|
|
43
44
|
document = AUTOSAR.getInstance()
|
|
44
|
-
sw_component = document.find("/DemoApplication/SwComponentTypes/TopLevelComposition")
|
|
45
|
-
assert(sw_component.short_name == "TopLevelComposition")
|
|
46
|
-
assert(isinstance(sw_component, CompositionSwComponentType))
|
|
47
|
-
|
|
48
|
-
assert(len(
|
|
45
|
+
sw_component = document.find("/DemoApplication/SwComponentTypes/TopLevelComposition")
|
|
46
|
+
assert (sw_component.short_name == "TopLevelComposition")
|
|
47
|
+
assert (isinstance(sw_component, CompositionSwComponentType))
|
|
48
|
+
ports = sw_component.getPorts()
|
|
49
|
+
assert (len(ports) == 2)
|
|
49
50
|
|
|
50
51
|
def test_composition_sw_component_types_sw_connectors(self):
|
|
51
52
|
document = AUTOSAR.getInstance()
|
|
52
|
-
sw_component = document.find("/DemoApplication/SwComponentTypes/TopLevelComposition")
|
|
53
|
-
assert(isinstance(sw_component, CompositionSwComponentType))
|
|
54
|
-
assert(len(sw_component.getSwConnectors()) == 6)
|
|
55
|
-
assert(len(sw_component.getAssemblySwConnectors()) == 3)
|
|
56
|
-
assert(len(sw_component.getDelegationSwConnectors()) == 3)
|
|
53
|
+
sw_component = document.find("/DemoApplication/SwComponentTypes/TopLevelComposition")
|
|
54
|
+
assert (isinstance(sw_component, CompositionSwComponentType))
|
|
55
|
+
assert (len(sw_component.getSwConnectors()) == 6)
|
|
56
|
+
assert (len(sw_component.getAssemblySwConnectors()) == 3)
|
|
57
|
+
assert (len(sw_component.getDelegationSwConnectors()) == 3)
|
|
57
58
|
|
|
58
59
|
connector_name_list = set()
|
|
59
60
|
for sw_connector in sw_component.getAssemblySwConnectors():
|
|
60
61
|
connector_name_list.add(sw_connector.short_name)
|
|
61
62
|
|
|
62
|
-
assert(connector_name_list == set(['a6a18805580c94537a4c82f6c289a4d', 'ac681652833fb4b12b920adab33a73b', 'ac681652833fb4b12b920adab33a73c']))
|
|
63
|
+
assert (connector_name_list == set(['a6a18805580c94537a4c82f6c289a4d', 'ac681652833fb4b12b920adab33a73b', 'ac681652833fb4b12b920adab33a73c']))
|
|
63
64
|
|
|
64
65
|
sw_component.removeElement("a6a18805580c94537a4c82f6c289a4d")
|
|
65
|
-
assert(len(sw_component.getAssemblySwConnectors()) == 2)
|
|
66
|
+
assert (len(sw_component.getAssemblySwConnectors()) == 2)
|
|
66
67
|
|
|
67
68
|
# remove all the AssemblySwConnector
|
|
68
69
|
sw_component.removeAllAssemblySwConnector()
|
|
69
|
-
assert(len(sw_component.getAssemblySwConnectors()) == 0)
|
|
70
|
-
assert(len(sw_component.getDelegationSwConnectors()) == 3)
|
|
70
|
+
assert (len(sw_component.getAssemblySwConnectors()) == 0)
|
|
71
|
+
assert (len(sw_component.getDelegationSwConnectors()) == 3)
|
|
71
72
|
|
|
72
73
|
# remove all the DelegationSwConnector
|
|
73
74
|
sw_component.removeAllDelegationSwConnector()
|
|
74
|
-
assert(len(sw_component.getAssemblySwConnectors()) == 0)
|
|
75
|
-
assert(len(sw_component.getDelegationSwConnectors()) == 0)
|
|
75
|
+
assert (len(sw_component.getAssemblySwConnectors()) == 0)
|
|
76
|
+
assert (len(sw_component.getDelegationSwConnectors()) == 0)
|
|
76
77
|
|
|
77
78
|
def test_bswm_mode_arxml_loading_and_saving(self):
|
|
78
79
|
document = AUTOSAR.getInstance()
|
|
@@ -83,9 +84,20 @@ class TestSWComponents:
|
|
|
83
84
|
writer = ARXMLWriter()
|
|
84
85
|
writer.save("data/generated_AUTOSAR_Datatypes.arxml", document)
|
|
85
86
|
|
|
86
|
-
assert(filecmp.cmp("src/armodel/tests/test_files/BswMMode.arxml", "data/generated_AUTOSAR_Datatypes.arxml", shallow
|
|
87
|
+
assert (filecmp.cmp("src/armodel/tests/test_files/BswMMode.arxml", "data/generated_AUTOSAR_Datatypes.arxml", shallow=False) is True)
|
|
87
88
|
|
|
88
|
-
def
|
|
89
|
+
def test_sw_record_demo_arxml_loading_and_saving(self):
|
|
90
|
+
document = AUTOSAR.getInstance()
|
|
91
|
+
document.clear()
|
|
92
|
+
parser = ARXMLParser()
|
|
93
|
+
parser.load("src/armodel/tests/test_files/SwRecordDemo.arxml", document)
|
|
94
|
+
|
|
95
|
+
writer = ARXMLWriter()
|
|
96
|
+
writer.save("data/generated_SwRecordDemo.arxml", document)
|
|
97
|
+
|
|
98
|
+
assert (filecmp.cmp("src/armodel/tests/test_files/SwRecordDemo.arxml", "data/generated_SwRecordDemo.arxml", shallow=False) is True)
|
|
99
|
+
|
|
100
|
+
def test_application_data_type_blueprint_arxml_loading_and_saving(self):
|
|
89
101
|
document = AUTOSAR.getInstance()
|
|
90
102
|
document.clear()
|
|
91
103
|
parser = ARXMLParser()
|
|
@@ -94,8 +106,269 @@ class TestSWComponents:
|
|
|
94
106
|
writer = ARXMLWriter()
|
|
95
107
|
writer.save("data/generated_AUTOSAR_MOD_AISpecification_ApplicationDataType_Blueprint.arxml", document)
|
|
96
108
|
|
|
97
|
-
|
|
109
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_ApplicationDataType_Blueprint.arxml",
|
|
110
|
+
"data/generated_AUTOSAR_MOD_AISpecification_ApplicationDataType_Blueprint.arxml", shallow=False) is True)
|
|
111
|
+
|
|
112
|
+
def test_application_data_type_life_cycle_standard_arxml_loading_and_saving(self):
|
|
113
|
+
document = AUTOSAR.getInstance()
|
|
114
|
+
document.clear()
|
|
115
|
+
parser = ARXMLParser()
|
|
116
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_ApplicationDataType_LifeCycle_Standard.arxml", document)
|
|
117
|
+
|
|
118
|
+
writer = ARXMLWriter()
|
|
119
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_ApplicationDataType_LifeCycle_Standard.arxml", document)
|
|
120
|
+
|
|
121
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_ApplicationDataType_LifeCycle_Standard.arxml",
|
|
122
|
+
"data/generated_AUTOSAR_MOD_AISpecification_ApplicationDataType_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
123
|
+
|
|
124
|
+
def test_autosar_mod_ai_specification_basetypes_standard_arxml_loading_and_saving(self):
|
|
125
|
+
document = AUTOSAR.getInstance()
|
|
126
|
+
document.clear()
|
|
127
|
+
parser = ARXMLParser()
|
|
128
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_BaseTypes_Standard.arxml", document)
|
|
129
|
+
|
|
130
|
+
writer = ARXMLWriter()
|
|
131
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_BaseTypes_Standard.arxml", document)
|
|
132
|
+
|
|
133
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_BaseTypes_Standard.arxml",
|
|
134
|
+
"data/generated_AUTOSAR_MOD_AISpecification_BaseTypes_Standard.arxml", shallow=False) is True)
|
|
135
|
+
|
|
136
|
+
def test_autosar_mod_ai_specification_collection_body_blueprint_arxml_loading_and_saving(self):
|
|
137
|
+
document = AUTOSAR.getInstance()
|
|
138
|
+
document.clear()
|
|
139
|
+
parser = ARXMLParser()
|
|
140
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Collection_Body_Blueprint.arxml", document)
|
|
141
|
+
|
|
142
|
+
writer = ARXMLWriter()
|
|
143
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Collection_Body_Blueprint.arxml", document)
|
|
144
|
+
|
|
145
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Collection_Body_Blueprint.arxml",
|
|
146
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Collection_Body_Blueprint.arxml", shallow=False) is True)
|
|
147
|
+
|
|
148
|
+
def test_autosar_mod_ai_specification_collection_chassis_blueprint_arxml_loading_and_saving(self):
|
|
149
|
+
document = AUTOSAR.getInstance()
|
|
150
|
+
document.clear()
|
|
151
|
+
parser = ARXMLParser()
|
|
152
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Collection_Chassis_Blueprint.arxml", document)
|
|
153
|
+
|
|
154
|
+
writer = ARXMLWriter()
|
|
155
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Collection_Chassis_Blueprint.arxml", document)
|
|
156
|
+
|
|
157
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Collection_Chassis_Blueprint.arxml",
|
|
158
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Collection_Chassis_Blueprint.arxml", shallow=False) is True)
|
|
159
|
+
|
|
160
|
+
def test_autosar_mod_ai_specification_collection_mmedtelmhmi_blueprint_arxml_loading_and_saving(self):
|
|
161
|
+
document = AUTOSAR.getInstance()
|
|
162
|
+
document.clear()
|
|
163
|
+
parser = ARXMLParser()
|
|
164
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Collection_MmedTelmHmi_Blueprint.arxml", document)
|
|
165
|
+
|
|
166
|
+
writer = ARXMLWriter()
|
|
167
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Collection_MmedTelmHmi_Blueprint.arxml", document)
|
|
168
|
+
|
|
169
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Collection_MmedTelmHmi_Blueprint.arxml",
|
|
170
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Collection_MmedTelmHmi_Blueprint.arxml", shallow=False) is True)
|
|
171
|
+
|
|
172
|
+
def test_autosar_mod_ai_specification_collection_occptpedsfty_blueprint_arxml_loading_and_saving(self):
|
|
173
|
+
document = AUTOSAR.getInstance()
|
|
174
|
+
document.clear()
|
|
175
|
+
parser = ARXMLParser()
|
|
176
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Collection_OccptPedSfty_Blueprint.arxml", document)
|
|
177
|
+
|
|
178
|
+
writer = ARXMLWriter()
|
|
179
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Collection_OccptPedSfty_Blueprint.arxml", document)
|
|
180
|
+
|
|
181
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Collection_OccptPedSfty_Blueprint.arxml",
|
|
182
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Collection_OccptPedSfty_Blueprint.arxml", shallow=False) is True)
|
|
183
|
+
|
|
184
|
+
def test_autosar_mod_ai_specification_collection_pt_blueprint_arxml_loading_and_saving(self):
|
|
185
|
+
document = AUTOSAR.getInstance()
|
|
186
|
+
document.clear()
|
|
187
|
+
parser = ARXMLParser()
|
|
188
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Collection_Pt_Blueprint.arxml", document)
|
|
189
|
+
|
|
190
|
+
writer = ARXMLWriter()
|
|
191
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Collection_Pt_Blueprint.arxml", document)
|
|
192
|
+
|
|
193
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Collection_Pt_Blueprint.arxml",
|
|
194
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Collection_Pt_Blueprint.arxml", shallow=False) is True)
|
|
195
|
+
|
|
196
|
+
def test_autosar_mod_ai_specification_compumethod_blueprint_arxml_loading_and_saving(self):
|
|
197
|
+
document = AUTOSAR.getInstance()
|
|
198
|
+
document.clear()
|
|
199
|
+
parser = ARXMLParser()
|
|
200
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_CompuMethod_Blueprint.arxml", document)
|
|
201
|
+
|
|
202
|
+
writer = ARXMLWriter()
|
|
203
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_CompuMethod_Blueprint.arxml", document)
|
|
204
|
+
|
|
205
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_CompuMethod_Blueprint.arxml",
|
|
206
|
+
"data/generated_AUTOSAR_MOD_AISpecification_CompuMethod_Blueprint.arxml", shallow=False) is True)
|
|
207
|
+
|
|
208
|
+
def test_AUTOSAR_MOD_AISpecification_DataConstr_Blueprint_arxml_loading_and_saving(self):
|
|
209
|
+
document = AUTOSAR.getInstance()
|
|
210
|
+
document.clear()
|
|
211
|
+
parser = ARXMLParser()
|
|
212
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_DataConstr_Blueprint.arxml", document)
|
|
213
|
+
|
|
214
|
+
writer = ARXMLWriter()
|
|
215
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_DataConstr_Blueprint.arxml", document)
|
|
98
216
|
|
|
217
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_DataConstr_Blueprint.arxml",
|
|
218
|
+
"data/generated_AUTOSAR_MOD_AISpecification_DataConstr_Blueprint.arxml", shallow=False) is True)
|
|
99
219
|
|
|
220
|
+
def test_AUTOSAR_MOD_AISpecification_CompuMethod_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
221
|
+
document = AUTOSAR.getInstance()
|
|
222
|
+
document.clear()
|
|
223
|
+
parser = ARXMLParser()
|
|
224
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_CompuMethod_LifeCycle_Standard.arxml", document)
|
|
225
|
+
|
|
226
|
+
writer = ARXMLWriter()
|
|
227
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_CompuMethod_LifeCycle_Standard.arxml", document)
|
|
228
|
+
|
|
229
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_CompuMethod_LifeCycle_Standard.arxml",
|
|
230
|
+
"data/generated_AUTOSAR_MOD_AISpecification_CompuMethod_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
100
231
|
|
|
232
|
+
def test_AUTOSAR_MOD_AISpecification_Keyword_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
233
|
+
document = AUTOSAR.getInstance()
|
|
234
|
+
document.clear()
|
|
235
|
+
parser = ARXMLParser()
|
|
236
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Keyword_LifeCycle_Standard.arxml", document)
|
|
237
|
+
|
|
238
|
+
writer = ARXMLWriter()
|
|
239
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Keyword_LifeCycle_Standard.arxml", document)
|
|
240
|
+
|
|
241
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Keyword_LifeCycle_Standard.arxml",
|
|
242
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Keyword_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
243
|
+
|
|
244
|
+
def test_AUTOSAR_MOD_AISpecification_KeywordSet_Blueprint_arxml_loading_and_saving(self):
|
|
245
|
+
document = AUTOSAR.getInstance()
|
|
246
|
+
document.clear()
|
|
247
|
+
parser = ARXMLParser()
|
|
248
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_KeywordSet_Blueprint.arxml", document)
|
|
249
|
+
|
|
250
|
+
writer = ARXMLWriter()
|
|
251
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_KeywordSet_Blueprint.arxml", document)
|
|
252
|
+
|
|
253
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_KeywordSet_Blueprint.arxml",
|
|
254
|
+
"data/generated_AUTOSAR_MOD_AISpecification_KeywordSet_Blueprint.arxml", shallow=False) is True)
|
|
255
|
+
|
|
256
|
+
def test_AUTOSAR_MOD_AISpecification_PhysicalDimension_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
257
|
+
document = AUTOSAR.getInstance()
|
|
258
|
+
document.clear()
|
|
259
|
+
parser = ARXMLParser()
|
|
260
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PhysicalDimension_LifeCycle_Standard.arxml", document)
|
|
261
|
+
|
|
262
|
+
writer = ARXMLWriter()
|
|
263
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PhysicalDimension_LifeCycle_Standard.arxml", document)
|
|
264
|
+
|
|
265
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PhysicalDimension_LifeCycle_Standard.arxml",
|
|
266
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PhysicalDimension_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
101
267
|
|
|
268
|
+
def test_AUTOSAR_MOD_AISpecification_PhysicalDimension_Standard_arxml_loading_and_saving(self):
|
|
269
|
+
document = AUTOSAR.getInstance()
|
|
270
|
+
document.clear()
|
|
271
|
+
parser = ARXMLParser()
|
|
272
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PhysicalDimension_Standard.arxml", document)
|
|
273
|
+
|
|
274
|
+
writer = ARXMLWriter()
|
|
275
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PhysicalDimension_Standard.arxml", document)
|
|
276
|
+
|
|
277
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PhysicalDimension_Standard.arxml",
|
|
278
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PhysicalDimension_Standard.arxml", shallow=False) is True)
|
|
279
|
+
|
|
280
|
+
def test_AUTOSAR_MOD_AISpecification_PortInterface_Blueprint_arxml_loading_and_saving(self):
|
|
281
|
+
document = AUTOSAR.getInstance()
|
|
282
|
+
document.clear()
|
|
283
|
+
parser = ARXMLParser()
|
|
284
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PortInterface_Blueprint.arxml", document)
|
|
285
|
+
|
|
286
|
+
writer = ARXMLWriter()
|
|
287
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PortInterface_Blueprint.arxml", document)
|
|
288
|
+
|
|
289
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PortInterface_Blueprint.arxml",
|
|
290
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PortInterface_Blueprint.arxml", shallow=False) is True)
|
|
291
|
+
|
|
292
|
+
def test_AUTOSAR_MOD_AISpecification_PortInterface_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
293
|
+
document = AUTOSAR.getInstance()
|
|
294
|
+
document.clear()
|
|
295
|
+
parser = ARXMLParser()
|
|
296
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PortInterface_LifeCycle_Standard.arxml", document)
|
|
297
|
+
|
|
298
|
+
writer = ARXMLWriter()
|
|
299
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PortInterface_LifeCycle_Standard.arxml", document)
|
|
300
|
+
|
|
301
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PortInterface_LifeCycle_Standard.arxml",
|
|
302
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PortInterface_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
303
|
+
|
|
304
|
+
def test_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_Blueprint_arxml_loading_and_saving(self):
|
|
305
|
+
document = AUTOSAR.getInstance()
|
|
306
|
+
document.clear()
|
|
307
|
+
parser = ARXMLParser()
|
|
308
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_Blueprint.arxml", document)
|
|
309
|
+
|
|
310
|
+
writer = ARXMLWriter()
|
|
311
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_Blueprint.arxml", document)
|
|
312
|
+
|
|
313
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_Blueprint.arxml",
|
|
314
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_Blueprint.arxml", shallow=False) is True)
|
|
315
|
+
|
|
316
|
+
def test_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
317
|
+
document = AUTOSAR.getInstance()
|
|
318
|
+
document.clear()
|
|
319
|
+
parser = ARXMLParser()
|
|
320
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_LifeCycle_Standard.arxml", document)
|
|
321
|
+
|
|
322
|
+
writer = ARXMLWriter()
|
|
323
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_LifeCycle_Standard.arxml", document)
|
|
324
|
+
|
|
325
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_LifeCycle_Standard.arxml",
|
|
326
|
+
"data/generated_AUTOSAR_MOD_AISpecification_PortPrototypeBlueprint_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
327
|
+
|
|
328
|
+
def test_AUTOSAR_MOD_AISpecification_SwComponentTypes_Blueprint_arxml_loading_and_saving(self):
|
|
329
|
+
document = AUTOSAR.getInstance()
|
|
330
|
+
document.clear()
|
|
331
|
+
parser = ARXMLParser()
|
|
332
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_SwComponentTypes_Blueprint.arxml", document)
|
|
333
|
+
|
|
334
|
+
writer = ARXMLWriter()
|
|
335
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_SwComponentTypes_Blueprint.arxml", document)
|
|
336
|
+
|
|
337
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_SwComponentTypes_Blueprint.arxml",
|
|
338
|
+
"data/generated_AUTOSAR_MOD_AISpecification_SwComponentTypes_Blueprint.arxml", shallow=False) is True)
|
|
339
|
+
|
|
340
|
+
def test_AUTOSAR_MOD_AISpecification_Unit_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
341
|
+
document = AUTOSAR.getInstance()
|
|
342
|
+
document.clear()
|
|
343
|
+
parser = ARXMLParser()
|
|
344
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Unit_LifeCycle_Standard.arxml", document)
|
|
345
|
+
|
|
346
|
+
writer = ARXMLWriter()
|
|
347
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Unit_LifeCycle_Standard.arxml", document)
|
|
348
|
+
|
|
349
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Unit_LifeCycle_Standard.arxml",
|
|
350
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Unit_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
351
|
+
|
|
352
|
+
def test_AUTOSAR_MOD_AISpecification_Unit_Standard_arxml_loading_and_saving(self):
|
|
353
|
+
document = AUTOSAR.getInstance()
|
|
354
|
+
document.clear()
|
|
355
|
+
parser = ARXMLParser()
|
|
356
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_Unit_Standard.arxml", document)
|
|
357
|
+
|
|
358
|
+
writer = ARXMLWriter()
|
|
359
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_Unit_Standard.arxml", document)
|
|
360
|
+
|
|
361
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_Unit_Standard.arxml",
|
|
362
|
+
"data/generated_AUTOSAR_MOD_AISpecification_Unit_Standard.arxml", shallow=False) is True)
|
|
363
|
+
|
|
364
|
+
def test_AUTOSAR_MOD_AISpecification_DataConstr_LifeCycle_Standard_arxml_loading_and_saving(self):
|
|
365
|
+
document = AUTOSAR.getInstance()
|
|
366
|
+
document.clear()
|
|
367
|
+
parser = ARXMLParser()
|
|
368
|
+
parser.load("test_files/AUTOSAR_MOD_AISpecification_DataConstr_LifeCycle_Standard.arxml", document)
|
|
369
|
+
|
|
370
|
+
writer = ARXMLWriter()
|
|
371
|
+
writer.save("data/generated_AUTOSAR_MOD_AISpecification_DataConstr_LifeCycle_Standard.arxml", document)
|
|
372
|
+
|
|
373
|
+
assert (filecmp.cmp("test_files/AUTOSAR_MOD_AISpecification_DataConstr_LifeCycle_Standard.arxml",
|
|
374
|
+
"data/generated_AUTOSAR_MOD_AISpecification_DataConstr_LifeCycle_Standard.arxml", shallow=False) is True)
|
|
@@ -3,13 +3,13 @@ from ....writer.arxml_writer import ARXMLWriter
|
|
|
3
3
|
from ....parser.arxml_parser import ARXMLParser
|
|
4
4
|
from ....models.M2.AUTOSARTemplates.AutosarTopLevelStructure import AUTOSAR
|
|
5
5
|
|
|
6
|
+
|
|
6
7
|
class TestSystemTemplate:
|
|
7
8
|
def setup_method(self):
|
|
8
9
|
document = AUTOSAR.getInstance()
|
|
9
10
|
document.clear()
|
|
10
11
|
parser = ARXMLParser()
|
|
11
12
|
parser.load("src/armodel/tests/test_files/CanSystem.arxml", document)
|
|
12
|
-
|
|
13
13
|
|
|
14
14
|
def test_can_system_arxml_loading_and_saving(self):
|
|
15
15
|
document = AUTOSAR.getInstance()
|
|
@@ -20,10 +20,4 @@ class TestSystemTemplate:
|
|
|
20
20
|
writer = ARXMLWriter()
|
|
21
21
|
writer.save("data/generated_CanSystem.arxml", document)
|
|
22
22
|
|
|
23
|
-
assert(filecmp.cmp("src/armodel/tests/test_files/CanSystem.arxml", "data/generated_CanSystem.arxml", shallow
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
assert (filecmp.cmp("src/armodel/tests/test_files/CanSystem.arxml", "data/generated_CanSystem.arxml", shallow=False) is True)
|
|
File without changes
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.ARPackage import ARPackage
|
|
3
|
+
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.Identifiable import Describable, Identifiable
|
|
4
|
+
from ..models.M2.AUTOSARTemplates.AutosarTopLevelStructure import AUTOSAR
|
|
5
|
+
from ..transformer.abstract import AbstractTransformer
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AdminDataTransformer(AbstractTransformer):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
super().__init__()
|
|
11
|
+
self.logger = logging.getLogger()
|
|
12
|
+
|
|
13
|
+
def process_pkg(self, pkg: ARPackage):
|
|
14
|
+
for sub_package in pkg.getARPackages():
|
|
15
|
+
self.process_pkg(sub_package)
|
|
16
|
+
|
|
17
|
+
self.logger.debug("Remove AdminData of <%s>", pkg.getShortName())
|
|
18
|
+
pkg.removeAdminData()
|
|
19
|
+
|
|
20
|
+
for element in pkg.getElements():
|
|
21
|
+
if isinstance(element, Describable):
|
|
22
|
+
self.logger.debug("Remove AdminData of <%s>", element.getShortName())
|
|
23
|
+
element.removeAdminData()
|
|
24
|
+
elif isinstance(element, Identifiable):
|
|
25
|
+
self.logger.debug("Remove AdminData of <%s>", element.getShortName())
|
|
26
|
+
element.removeAdminData()
|
|
27
|
+
|
|
28
|
+
def remove(self, root: AUTOSAR):
|
|
29
|
+
root.removeAdminData()
|
|
30
|
+
for pkg in root.getARPackages():
|
|
31
|
+
self.process_pkg(pkg)
|
|
@@ -8,13 +8,15 @@ import logging
|
|
|
8
8
|
import xml.etree.cElementTree as ET
|
|
9
9
|
|
|
10
10
|
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.ArObject import ARObject
|
|
11
|
-
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.PrimitiveTypes import ARFloat, ARLiteral, ARNumerical, Integer, TimeValue
|
|
11
|
+
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.PrimitiveTypes import ARFloat, ARLiteral, ARNumerical, Integer, TimeValue
|
|
12
|
+
from ..models.M2.AUTOSARTemplates.GenericStructure.GeneralTemplateClasses.PrimitiveTypes import RefType, ARBoolean
|
|
13
|
+
|
|
12
14
|
|
|
13
15
|
class AbstractARXMLWriter:
|
|
14
16
|
__metaclass__ = ABCMeta
|
|
15
17
|
|
|
16
|
-
def __init__(self, options
|
|
17
|
-
if type(self)
|
|
18
|
+
def __init__(self, options=None) -> None:
|
|
19
|
+
if type(self) is AbstractARXMLWriter:
|
|
18
20
|
raise NotImplementedError("AbstractARXMLWriter is an abstract class.")
|
|
19
21
|
|
|
20
22
|
self.options = {}
|
|
@@ -25,7 +27,7 @@ class AbstractARXMLWriter:
|
|
|
25
27
|
self._processOptions(options=options)
|
|
26
28
|
|
|
27
29
|
self.nsmap = {
|
|
28
|
-
"xmlns": "http://autosar.org/schema/r4.0",
|
|
30
|
+
"xmlns": "http://autosar.org/schema/r4.0",
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
def _processOptions(self, options):
|
|
@@ -34,23 +36,23 @@ class AbstractARXMLWriter:
|
|
|
34
36
|
self.options['warning'] = options['warning']
|
|
35
37
|
|
|
36
38
|
def _raiseError(self, error_msg):
|
|
37
|
-
if (self.options['warning']
|
|
39
|
+
if (self.options['warning'] is True):
|
|
38
40
|
self.logger.error(Fore.RED + error_msg + Fore.WHITE)
|
|
39
41
|
else:
|
|
40
42
|
raise ValueError(error_msg)
|
|
41
43
|
|
|
42
44
|
def notImplemented(self, error_msg):
|
|
43
|
-
if (self.options['warning']
|
|
45
|
+
if (self.options['warning'] is True):
|
|
44
46
|
self.logger.error(Fore.RED + error_msg + Fore.WHITE)
|
|
45
47
|
else:
|
|
46
48
|
raise NotImplementedError(error_msg)
|
|
47
49
|
|
|
48
50
|
def writeARObjectAttributes(self, element: ET.Element, ar_obj: ARObject):
|
|
49
51
|
if ar_obj.timestamp is not None:
|
|
50
|
-
self.logger.debug("Timestamp: %s" % ar_obj.timestamp)
|
|
52
|
+
# self.logger.debug("Timestamp: %s" % ar_obj.timestamp)
|
|
51
53
|
element.attrib['T'] = ar_obj.timestamp
|
|
52
54
|
if ar_obj.uuid is not None:
|
|
53
|
-
self.logger.debug("UUID: %s" % ar_obj.uuid)
|
|
55
|
+
# self.logger.debug("UUID: %s" % ar_obj.uuid)
|
|
54
56
|
element.attrib['UUID'] = ar_obj.uuid
|
|
55
57
|
|
|
56
58
|
'''
|
|
@@ -78,14 +80,7 @@ class AbstractARXMLWriter:
|
|
|
78
80
|
|
|
79
81
|
def setChildElementOptionalPositiveInteger(self, element: ET.Element, key: str, value: Integer):
|
|
80
82
|
self.setChildElementOptionalNumericalValue(element, key, value)
|
|
81
|
-
|
|
82
|
-
def setChildElementOptionalLiteral(self, element: ET.Element, key: str, literal: ARLiteral):
|
|
83
|
-
if literal is not None:
|
|
84
|
-
child_element = ET.SubElement(element, key)
|
|
85
|
-
self.writeARObjectAttributes(child_element, literal)
|
|
86
|
-
if literal._value is not None:
|
|
87
|
-
child_element.text = str(literal._value)
|
|
88
|
-
|
|
83
|
+
|
|
89
84
|
def setChildElementOptionalRevisionLabelString(self, element: ET.Element, key: str, literal: ARLiteral):
|
|
90
85
|
self.setChildElementOptionalLiteral(element, key, literal)
|
|
91
86
|
|
|
@@ -111,7 +106,6 @@ class AbstractARXMLWriter:
|
|
|
111
106
|
self.setChildElementOptionalFloatValue(element, key, value)
|
|
112
107
|
|
|
113
108
|
def setChildElementOptionalBooleanValue(self, element: ET.Element, key: str, value: ARBoolean) -> ET.Element:
|
|
114
|
-
child_element = None
|
|
115
109
|
if value is not None:
|
|
116
110
|
child_element = ET.SubElement(element, key)
|
|
117
111
|
self.writeARObjectAttributes(child_element, value)
|
|
@@ -119,30 +113,29 @@ class AbstractARXMLWriter:
|
|
|
119
113
|
return element
|
|
120
114
|
|
|
121
115
|
def setChildElementOptionalLiteral(self, element: ET.Element, key: str, value: ARLiteral) -> ET.Element:
|
|
122
|
-
child_element = None
|
|
123
116
|
if value is not None:
|
|
124
117
|
child_element = ET.SubElement(element, key)
|
|
125
118
|
self.writeARObjectAttributes(child_element, value)
|
|
126
119
|
child_element.text = value.getText()
|
|
127
|
-
return element
|
|
128
|
-
|
|
120
|
+
return element
|
|
121
|
+
|
|
129
122
|
def patch_xml(self, xml: str) -> str:
|
|
130
|
-
xml = re.sub(r"\<([\w-]+)\/\>",r"<\1></\1>", xml)
|
|
131
|
-
xml = re.sub(r"<(
|
|
132
|
-
xml = re.sub(r""", '"', xml)
|
|
123
|
+
xml = re.sub(r"\<([\w-]+)\/\>", r"<\1></\1>", xml)
|
|
124
|
+
# xml = re.sub(r"<([\w-]+)\s+(\w+)=(\"[\w-]+\")\/>", r"<\1 \2=\3></\1>", xml)
|
|
125
|
+
# xml = re.sub(r""", '"', xml)
|
|
133
126
|
return xml
|
|
134
127
|
|
|
135
128
|
def saveToFile(self, filename, root: ET.Element):
|
|
136
|
-
if sys.version_info <= (3,9):
|
|
137
|
-
xml = ET.tostring(root, encoding
|
|
129
|
+
if sys.version_info <= (3, 9):
|
|
130
|
+
xml = ET.tostring(root, encoding="UTF-8", short_empty_elements=False)
|
|
138
131
|
else:
|
|
139
|
-
xml = ET.tostring(root, encoding
|
|
132
|
+
xml = ET.tostring(root, encoding="UTF-8", xml_declaration=True, short_empty_elements=False)
|
|
140
133
|
|
|
141
134
|
dom = minidom.parseString(xml.decode())
|
|
142
|
-
xml = dom.toprettyxml(indent
|
|
135
|
+
xml = dom.toprettyxml(indent=" ", encoding="UTF-8")
|
|
143
136
|
|
|
144
137
|
text = self.patch_xml(xml.decode())
|
|
145
138
|
|
|
146
139
|
with open(filename, "w", encoding="utf-8") as f_out:
|
|
147
|
-
#f_out.write(xml.decode())
|
|
148
|
-
f_out.write(text)
|
|
140
|
+
# f_out.write(xml.decode())
|
|
141
|
+
f_out.write(text)
|