fmu-manipulation-toolbox 1.9rc7__tar.gz → 1.9rc9__tar.gz
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.
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/PKG-INFO +1 -1
- fmu_manipulation_toolbox-1.9rc9/fmu_manipulation_toolbox/__version__.py +1 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/cli/fmucontainer.py +8 -6
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/cli/fmusplit.py +8 -5
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/cli/fmutool.py +6 -3
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/help.py +3 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/operations.py +91 -24
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/darwin64/container.dylib +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/linux32/client_sm.so +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/linux64/client_sm.so +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/linux64/container.so +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/win32/client_sm.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/win32/server_sm.exe +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/win64/client_sm.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/win64/container.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/win64/server_sm.exe +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/split.py +8 -3
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/PKG-INFO +1 -1
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/tests/test_suite.py +25 -1
- fmu_manipulation_toolbox-1.9rc7/fmu_manipulation_toolbox/__version__.py +0 -1
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/LICENSE.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/README.md +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/__init__.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/__main__.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/assembly.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/checker.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/cli/__init__.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/cli/utils.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/container.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/gui.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/gui_style.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/remoting.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-checked-disabled.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-checked-hover.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-checked.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-unchecked-disabled.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-unchecked-hover.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/checkbox-unchecked.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/container.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/drop_fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Annotation.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2AttributeGroups.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ModelDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ScalarVariable.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Type.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Unit.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2VariableDependency.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Annotation.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3AttributeGroups.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3BuildDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3InterfaceType.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3LayeredStandardManifest.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3ModelDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Terminal.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3TerminalsAndIcons.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Type.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Unit.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Variable.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3VariableDependency.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/fmu_manipulation_toolbox.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/help.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/icon-round.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/icon.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/icon_fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/license.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/linux32/server_sm +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/linux64/server_sm +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/mask.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/resources/model.png +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/version.py +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/SOURCES.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/dependency_links.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/entry_points.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/requires.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox.egg-info/top_level.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/setup.cfg +0 -0
- {fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/setup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmu_manipulation_toolbox
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9rc9
|
|
4
4
|
Summary: FMU Manipulation Toolbox is a python application for modifying Functional Mock-up Units (FMUs) without recompilation or bundling them into FMU Containers
|
|
5
5
|
Home-page: https://github.com/grouperenault/fmu_manipulation_toolbox/
|
|
6
6
|
Author: Nicolas.LAURENT@Renault.com
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'V1.9-rc9'
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import logging
|
|
3
|
+
import sys
|
|
3
4
|
|
|
5
|
+
from typing import *
|
|
4
6
|
from pathlib import Path
|
|
5
7
|
|
|
6
8
|
from .utils import setup_logger, make_wide
|
|
@@ -9,7 +11,7 @@ from ..container import FMUContainerError
|
|
|
9
11
|
from ..version import __version__ as version
|
|
10
12
|
|
|
11
13
|
|
|
12
|
-
def fmucontainer():
|
|
14
|
+
def fmucontainer(command_options: Sequence[str]):
|
|
13
15
|
logger = setup_logger()
|
|
14
16
|
|
|
15
17
|
logger.info(f"FMUContainer version {version}")
|
|
@@ -63,7 +65,7 @@ def fmucontainer():
|
|
|
63
65
|
parser.add_argument("-dump-json", action="store_true", dest="dump", default=False,
|
|
64
66
|
help="Dump a JSON file for each container.")
|
|
65
67
|
|
|
66
|
-
config = parser.parse_args()
|
|
68
|
+
config = parser.parse_args(command_options)
|
|
67
69
|
|
|
68
70
|
if config.debug:
|
|
69
71
|
logger.setLevel(logging.DEBUG)
|
|
@@ -88,16 +90,16 @@ def fmucontainer():
|
|
|
88
90
|
auto_parameter=config.auto_parameter)
|
|
89
91
|
except FileNotFoundError as e:
|
|
90
92
|
logger.fatal(f"Cannot read file: {e}")
|
|
91
|
-
|
|
93
|
+
sys.exit(-1)
|
|
92
94
|
except (FMUContainerError, AssemblyError) as e:
|
|
93
95
|
logger.fatal(f"{filename}: {e}")
|
|
94
|
-
|
|
96
|
+
sys.exit(-2)
|
|
95
97
|
|
|
96
98
|
try:
|
|
97
99
|
assembly.make_fmu(dump_json=config.dump, fmi_version=int(config.fmi_version))
|
|
98
100
|
except FMUContainerError as e:
|
|
99
101
|
logger.fatal(f"{filename}: {e}")
|
|
100
|
-
|
|
102
|
+
sys.exit(-3)
|
|
101
103
|
|
|
102
104
|
if __name__ == "__main__":
|
|
103
|
-
fmucontainer()
|
|
105
|
+
fmucontainer(sys.argv[1:])
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import logging
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
from typing import *
|
|
3
6
|
|
|
4
7
|
from .utils import setup_logger, make_wide
|
|
5
8
|
from ..split import FMUSplitter, FMUSplitterError
|
|
6
9
|
from ..version import __version__ as version
|
|
7
10
|
|
|
8
11
|
|
|
9
|
-
def fmusplit():
|
|
12
|
+
def fmusplit(command_options: Sequence[str]):
|
|
10
13
|
logger = setup_logger()
|
|
11
14
|
|
|
12
15
|
logger.info(f"FMUSplit version {version}")
|
|
@@ -24,7 +27,7 @@ def fmusplit():
|
|
|
24
27
|
metavar="filename.fmu", required=True,
|
|
25
28
|
help="Description of the FMU container to split.")
|
|
26
29
|
|
|
27
|
-
config = parser.parse_args()
|
|
30
|
+
config = parser.parse_args(command_options)
|
|
28
31
|
|
|
29
32
|
if config.debug:
|
|
30
33
|
logger.setLevel(logging.DEBUG)
|
|
@@ -35,11 +38,11 @@ def fmusplit():
|
|
|
35
38
|
splitter.split_fmu()
|
|
36
39
|
except FMUSplitterError as e:
|
|
37
40
|
logger.fatal(f"{fmu_filename}: {e}")
|
|
38
|
-
|
|
41
|
+
sys.exit(-1)
|
|
39
42
|
except FileNotFoundError as e:
|
|
40
43
|
logger.fatal(f"Cannot read file: {e}")
|
|
41
|
-
|
|
44
|
+
sys.exit(-2)
|
|
42
45
|
|
|
43
46
|
|
|
44
47
|
if __name__ == "__main__":
|
|
45
|
-
fmusplit()
|
|
48
|
+
fmusplit(sys.argv[1:])
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import argparse
|
|
2
2
|
import sys
|
|
3
3
|
|
|
4
|
+
from typing import *
|
|
5
|
+
|
|
4
6
|
from .utils import setup_logger, make_wide
|
|
5
7
|
from ..operations import (OperationSummary, OperationError, OperationRemoveRegexp,
|
|
6
8
|
OperationRemoveSources, OperationTrimUntil, OperationKeepOnlyRegexp, OperationMergeTopLevel,
|
|
@@ -12,7 +14,7 @@ from ..version import __version__ as version
|
|
|
12
14
|
from ..help import Help
|
|
13
15
|
|
|
14
16
|
|
|
15
|
-
def fmutool():
|
|
17
|
+
def fmutool(command_options: Sequence[str]):
|
|
16
18
|
logger = setup_logger()
|
|
17
19
|
|
|
18
20
|
logger.info(f"FMU Manipulation Toolbox version {version}")
|
|
@@ -64,11 +66,12 @@ def fmutool():
|
|
|
64
66
|
add_option('-only-parameters', action='append_const', dest='apply_on', const='parameter')
|
|
65
67
|
add_option('-only-inputs', action='append_const', dest='apply_on', const='input')
|
|
66
68
|
add_option('-only-outputs', action='append_const', dest='apply_on', const='output')
|
|
69
|
+
add_option('-only-locals', action='append_const', dest='apply_on', const='local')
|
|
67
70
|
# Checker
|
|
68
71
|
add_option('-summary', action='append_const', dest='operations_list', const=OperationSummary())
|
|
69
72
|
add_option('-check', action='append_const', dest='operations_list', const=[checker() for checker in checker_list])
|
|
70
73
|
|
|
71
|
-
cli_options = parser.parse_args()
|
|
74
|
+
cli_options = parser.parse_args(command_options)
|
|
72
75
|
# handle the "no operation" use case
|
|
73
76
|
if not cli_options.operations_list:
|
|
74
77
|
cli_options.operations_list = []
|
|
@@ -121,4 +124,4 @@ def fmutool():
|
|
|
121
124
|
logger.info(f"INFO Modified FMU is not saved. If necessary use '-output' option.")
|
|
122
125
|
|
|
123
126
|
if __name__ == "__main__":
|
|
124
|
-
fmutool()
|
|
127
|
+
fmutool(sys.argv[1:])
|
{fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/help.py
RENAMED
|
@@ -73,6 +73,9 @@ class Help:
|
|
|
73
73
|
'-only-outputs': "apply operation only on ports with causality = 'output'. This "
|
|
74
74
|
"option is available from version 1.3.",
|
|
75
75
|
|
|
76
|
+
'-only-locals': "apply operation only on ports with causality = 'local'. This "
|
|
77
|
+
"option is available from version 1.9.",
|
|
78
|
+
|
|
76
79
|
'-summary': "display useful information regarding the FMU.",
|
|
77
80
|
|
|
78
81
|
'-check': "performs some check of FMU and display Errors or Warnings. This is useful to avoid later "
|
|
@@ -112,6 +112,8 @@ class FMUError(Exception):
|
|
|
112
112
|
|
|
113
113
|
class Manipulation:
|
|
114
114
|
"""Parse modelDescription.xml file and create a modified version"""
|
|
115
|
+
TAGS_MODEL_STRUCTURE = ("InitialUnknowns", "Derivatives", "Outputs")
|
|
116
|
+
|
|
115
117
|
def __init__(self, operation, fmu):
|
|
116
118
|
self.output_filename = tempfile.mktemp()
|
|
117
119
|
self.out = None
|
|
@@ -120,7 +122,14 @@ class Manipulation:
|
|
|
120
122
|
self.parser.StartElementHandler = self.start_element
|
|
121
123
|
self.parser.EndElementHandler = self.end_element
|
|
122
124
|
self.parser.CharacterDataHandler = self.char_data
|
|
125
|
+
|
|
126
|
+
# used for filter
|
|
123
127
|
self.skip_until: Optional[str] = None
|
|
128
|
+
|
|
129
|
+
# used to remove empty sections
|
|
130
|
+
self.delayed_tag = None
|
|
131
|
+
self.delayed_tag_open = False
|
|
132
|
+
|
|
124
133
|
self.operation.set_fmu(fmu)
|
|
125
134
|
self.fmu = fmu
|
|
126
135
|
|
|
@@ -155,6 +164,7 @@ class Manipulation:
|
|
|
155
164
|
def start_element(self, name, attrs):
|
|
156
165
|
if self.skip_until:
|
|
157
166
|
return
|
|
167
|
+
|
|
158
168
|
try:
|
|
159
169
|
if name == 'ScalarVariable': # FMI 2.0 only
|
|
160
170
|
self.current_port = FMUPort()
|
|
@@ -176,7 +186,7 @@ class Manipulation:
|
|
|
176
186
|
self.operation.fmi_attrs(attrs)
|
|
177
187
|
elif name == 'Unknown': # FMI-2.0 only
|
|
178
188
|
self.unknown_attrs(attrs)
|
|
179
|
-
elif name == 'Output' or name == "ContinuousStateDerivative" or "InitialUnknown":
|
|
189
|
+
elif name == 'Output' or name == "ContinuousStateDerivative" or "InitialUnknown": # FMI-3.0 only
|
|
180
190
|
self.handle_structure(attrs)
|
|
181
191
|
|
|
182
192
|
except ManipulationSkipTag:
|
|
@@ -184,11 +194,19 @@ class Manipulation:
|
|
|
184
194
|
return
|
|
185
195
|
|
|
186
196
|
if self.current_port is None:
|
|
197
|
+
if self.delayed_tag and not self.delayed_tag_open:
|
|
198
|
+
print(f"<{self.delayed_tag}>", end='', file=self.out)
|
|
199
|
+
self.delayed_tag_open = True
|
|
200
|
+
|
|
187
201
|
if attrs:
|
|
188
202
|
attrs_list = [f'{key}="{self.escape(value)}"' for (key, value) in attrs.items()]
|
|
189
203
|
print(f"<{name}", " ".join(attrs_list), ">", end='', file=self.out)
|
|
190
204
|
else:
|
|
191
|
-
|
|
205
|
+
if name in self.TAGS_MODEL_STRUCTURE:
|
|
206
|
+
self.delayed_tag = name
|
|
207
|
+
self.delayed_tag_open = False
|
|
208
|
+
else:
|
|
209
|
+
print(f"<{name}>", end='', file=self.out)
|
|
192
210
|
|
|
193
211
|
def end_element(self, name):
|
|
194
212
|
if self.skip_until:
|
|
@@ -205,7 +223,14 @@ class Manipulation:
|
|
|
205
223
|
self.current_port = None
|
|
206
224
|
|
|
207
225
|
elif self.current_port is None:
|
|
208
|
-
|
|
226
|
+
if self.delayed_tag and name == self.delayed_tag:
|
|
227
|
+
if self.delayed_tag_open:
|
|
228
|
+
print(f"</{self.delayed_tag}>", end='', file=self.out)
|
|
229
|
+
else:
|
|
230
|
+
logger.debug(f"Remove tag <{self.delayed_tag}> from modelDescription.xml")
|
|
231
|
+
self.delayed_tag = None
|
|
232
|
+
else:
|
|
233
|
+
print(f"</{name}>", end='', file=self.out)
|
|
209
234
|
|
|
210
235
|
def char_data(self, data):
|
|
211
236
|
if not self.skip_until:
|
|
@@ -223,33 +248,71 @@ class Manipulation:
|
|
|
223
248
|
self.port_translation.append(self.current_port_number)
|
|
224
249
|
|
|
225
250
|
def unknown_attrs(self, attrs):
|
|
226
|
-
index = int(attrs['index'])
|
|
227
|
-
new_index = self.port_translation[index]
|
|
228
|
-
if new_index:
|
|
229
|
-
attrs['index'] =
|
|
251
|
+
index = int(attrs['index'])
|
|
252
|
+
new_index = self.port_translation[index-1]
|
|
253
|
+
if new_index is not None:
|
|
254
|
+
attrs['index'] = str(new_index)
|
|
255
|
+
if attrs.get('dependencies', ""):
|
|
256
|
+
if 'dependenciesKind' in attrs:
|
|
257
|
+
new_dependencies = []
|
|
258
|
+
new_kinds = []
|
|
259
|
+
for dependency, kind in zip(attrs['dependencies'].split(' '), attrs['dependenciesKind'].split(' ')):
|
|
260
|
+
new_dependency = self.port_translation[int(dependency)-1]
|
|
261
|
+
if new_dependency is not None:
|
|
262
|
+
new_dependencies.append(str(new_dependency))
|
|
263
|
+
new_kinds.append(kind)
|
|
264
|
+
if new_dependencies:
|
|
265
|
+
attrs['dependencies'] = " ".join(new_dependencies)
|
|
266
|
+
attrs['dependenciesKind'] = " ".join(new_kinds)
|
|
267
|
+
else:
|
|
268
|
+
attrs.pop('dependencies')
|
|
269
|
+
attrs.pop('dependenciesKind')
|
|
270
|
+
else:
|
|
271
|
+
new_dependencies = []
|
|
272
|
+
for dependency in attrs['dependencies'].split(' '):
|
|
273
|
+
new_dependency = self.port_translation[int(dependency)-1]
|
|
274
|
+
if new_dependency is not None:
|
|
275
|
+
new_dependencies.append(str(new_dependency))
|
|
276
|
+
if new_dependencies:
|
|
277
|
+
attrs['dependencies'] = " ".join(new_dependencies)
|
|
278
|
+
else:
|
|
279
|
+
attrs.pop('dependencies')
|
|
230
280
|
else:
|
|
231
|
-
logger.warning(f"Removed port '{self.port_names_list[index]}' is involved in dependencies tree.")
|
|
281
|
+
logger.warning(f"Removed port '{self.port_names_list[index-1]}' is involved in dependencies tree.")
|
|
232
282
|
raise ManipulationSkipTag
|
|
233
283
|
|
|
234
284
|
def handle_structure(self, attrs):
|
|
235
285
|
try:
|
|
236
286
|
vr = attrs['valueReference']
|
|
237
287
|
if vr in self.port_removed_vr:
|
|
288
|
+
logger.warning(f"Removed port vr={vr} is involved in dependencies tree.")
|
|
238
289
|
raise ManipulationSkipTag
|
|
239
290
|
except KeyError:
|
|
240
291
|
return
|
|
241
292
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
293
|
+
if attrs.get('dependencies', ""):
|
|
294
|
+
if 'dependenciesKind' in attrs:
|
|
295
|
+
new_dependencies = []
|
|
296
|
+
new_kinds = []
|
|
297
|
+
for dependency, kind in zip(attrs['dependencies'].split(' '), attrs['dependenciesKind'].split(' ')):
|
|
298
|
+
if dependency not in self.port_removed_vr:
|
|
299
|
+
new_dependencies.append(dependency)
|
|
300
|
+
new_kinds.append(kind)
|
|
301
|
+
if new_dependencies:
|
|
302
|
+
attrs['dependencies'] = " ".join(new_dependencies)
|
|
303
|
+
attrs['dependenciesKind'] = " ".join(new_kinds)
|
|
248
304
|
else:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
305
|
+
attrs.pop('dependencies')
|
|
306
|
+
attrs.pop('dependenciesKind')
|
|
307
|
+
else:
|
|
308
|
+
new_dependencies = []
|
|
309
|
+
for dependency in attrs['dependencies'].split(' '):
|
|
310
|
+
if dependency not in self.port_removed_vr:
|
|
311
|
+
new_dependencies.append(dependency)
|
|
312
|
+
if new_dependencies:
|
|
313
|
+
attrs['dependencies'] = " ".join(new_dependencies)
|
|
314
|
+
else:
|
|
315
|
+
attrs.pop('dependencies')
|
|
253
316
|
|
|
254
317
|
def manipulate(self, descriptor_filename, apply_on=None):
|
|
255
318
|
self.apply_on = apply_on
|
|
@@ -416,8 +479,8 @@ class OperationSummary(OperationAbstract):
|
|
|
416
479
|
hash_md5.update(chunk)
|
|
417
480
|
digest = hash_md5.hexdigest()
|
|
418
481
|
logger.info(f"| MD5Sum = {digest}")
|
|
419
|
-
|
|
420
|
-
logger.info(f"
|
|
482
|
+
logger.info(f"|")
|
|
483
|
+
logger.info(f"| FMI properties: ")
|
|
421
484
|
for (k, v) in attrs.items():
|
|
422
485
|
logger.info(f"| - {k} = {v}")
|
|
423
486
|
logger.info(f"|")
|
|
@@ -457,21 +520,25 @@ class OperationSummary(OperationAbstract):
|
|
|
457
520
|
|
|
458
521
|
resource_dir = os.path.join(self.fmu.tmp_directory, "resources")
|
|
459
522
|
if os.path.isdir(resource_dir):
|
|
460
|
-
logger.info("
|
|
523
|
+
logger.info("|")
|
|
524
|
+
logger.info("| Embedded resources:")
|
|
461
525
|
for resource in os.listdir(resource_dir):
|
|
462
526
|
logger.info(f"| - {resource}")
|
|
463
527
|
|
|
464
528
|
extra_dir = os.path.join(self.fmu.tmp_directory, "extra")
|
|
465
529
|
if os.path.isdir(extra_dir):
|
|
466
|
-
logger.info("
|
|
530
|
+
logger.info("|")
|
|
531
|
+
logger.info("| Additional (meta-)data:")
|
|
467
532
|
for extra in os.listdir(extra_dir):
|
|
468
533
|
logger.info(f"| - {extra}")
|
|
469
534
|
|
|
470
|
-
logger.info("
|
|
535
|
+
logger.info("|")
|
|
536
|
+
logger.info("| Number of ports")
|
|
471
537
|
for causality, nb_ports in self.nb_port_per_causality.items():
|
|
472
538
|
logger.info(f"| {causality} : {nb_ports}")
|
|
473
539
|
|
|
474
|
-
logger.info("
|
|
540
|
+
logger.info("|")
|
|
541
|
+
logger.info("| [End of report]")
|
|
475
542
|
|
|
476
543
|
|
|
477
544
|
class OperationRemoveSources(OperationAbstract):
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,6 +6,8 @@ import xml.parsers.expat
|
|
|
6
6
|
from typing import *
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
+
from .container import EmbeddedFMUPort
|
|
10
|
+
|
|
9
11
|
logger = logging.getLogger("fmu_manipulation_toolbox")
|
|
10
12
|
|
|
11
13
|
|
|
@@ -66,7 +68,7 @@ class FMUSplitter:
|
|
|
66
68
|
def split_fmu(self):
|
|
67
69
|
logger.info(f"Splitting...")
|
|
68
70
|
config = self._split_fmu(fmu_filename=str(self.fmu_filename), relative_path="")
|
|
69
|
-
config_filename = self.directory / self.fmu_filename.with_suffix(".json")
|
|
71
|
+
config_filename = self.directory / self.fmu_filename.with_suffix(".json").name
|
|
70
72
|
with open(config_filename, "w") as file:
|
|
71
73
|
json.dump(config, file, indent=2)
|
|
72
74
|
logger.info(f"Container definition saved to '{config_filename}'")
|
|
@@ -77,7 +79,7 @@ class FMUSplitter:
|
|
|
77
79
|
if txt_filename in self.filenames_list:
|
|
78
80
|
description = FMUSplitterDescription(self.zip)
|
|
79
81
|
config = description.parse_txt_file(txt_filename)
|
|
80
|
-
config["name"] = fmu_filename
|
|
82
|
+
config["name"] = Path(fmu_filename).name
|
|
81
83
|
for i, fmu_filename in enumerate(config["candidate_fmu"]):
|
|
82
84
|
directory = f"{relative_path}resources/{i:02x}/"
|
|
83
85
|
if directory not in self.dir_set:
|
|
@@ -134,6 +136,7 @@ class FMUSplitterDescription:
|
|
|
134
136
|
self.current_vr = None
|
|
135
137
|
self.current_name = None
|
|
136
138
|
self.current_causality = None
|
|
139
|
+
self.supported_fmi_types: Tuple[str] = ()
|
|
137
140
|
|
|
138
141
|
@staticmethod
|
|
139
142
|
def get_line(file):
|
|
@@ -182,10 +185,12 @@ class FMUSplitterDescription:
|
|
|
182
185
|
def parse_txt_file_header(self, file, txt_filename):
|
|
183
186
|
flags = self.get_line(file).split(" ")
|
|
184
187
|
if len(flags) == 1:
|
|
188
|
+
self.supported_fmi_types = ("Real", "Integer", "Boolean", "String")
|
|
185
189
|
self.config["mt"] = flags[0] == "1"
|
|
186
190
|
self.config["profiling"] = self.get_line(file) == "1"
|
|
187
191
|
self.config["sequential"] = False
|
|
188
192
|
elif len(flags) == 3:
|
|
193
|
+
self.supported_fmi_types = EmbeddedFMUPort.ALL_TYPES
|
|
189
194
|
self.config["mt"] = flags[0] == "1"
|
|
190
195
|
self.config["profiling"] = flags[1] == "1"
|
|
191
196
|
self.config["sequential"] = flags[2] == "1"
|
|
@@ -242,7 +247,7 @@ class FMUSplitterDescription:
|
|
|
242
247
|
logger.debug(f"Adding container port {causality}: {definition}")
|
|
243
248
|
|
|
244
249
|
def parse_txt_file_ports(self, file):
|
|
245
|
-
for fmi_type in
|
|
250
|
+
for fmi_type in self.supported_fmi_types:
|
|
246
251
|
nb_port_variables = self.get_line(file).split(" ")[0]
|
|
247
252
|
for i in range(int(nb_port_variables)):
|
|
248
253
|
tokens = self.get_line(file).split(" ")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmu_manipulation_toolbox
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9rc9
|
|
4
4
|
Summary: FMU Manipulation Toolbox is a python application for modifying Functional Mock-up Units (FMUs) without recompilation or bundling them into FMU Containers
|
|
5
5
|
Home-page: https://github.com/grouperenault/fmu_manipulation_toolbox/
|
|
6
6
|
Author: Nicolas.LAURENT@Renault.com
|
|
@@ -9,7 +9,9 @@ from fmu_manipulation_toolbox.operations import *
|
|
|
9
9
|
from fmu_manipulation_toolbox.remoting import *
|
|
10
10
|
from fmu_manipulation_toolbox.container import *
|
|
11
11
|
from fmu_manipulation_toolbox.assembly import *
|
|
12
|
-
|
|
12
|
+
from fmu_manipulation_toolbox.cli.fmutool import fmutool
|
|
13
|
+
from fmu_manipulation_toolbox.cli.fmusplit import fmusplit
|
|
14
|
+
from fmu_manipulation_toolbox.cli.fmucontainer import fmucontainer
|
|
13
15
|
|
|
14
16
|
class FMUManipulationToolboxTestSuite(unittest.TestCase):
|
|
15
17
|
def __init__(self, *args, **kwargs):
|
|
@@ -214,6 +216,28 @@ class FMUManipulationToolboxTestSuite(unittest.TestCase):
|
|
|
214
216
|
for link in links_fmu0a:
|
|
215
217
|
print(f"{link}")
|
|
216
218
|
|
|
219
|
+
def test_fmutool(self):
|
|
220
|
+
fmutool(['-input', 'operations/bouncing_ball.fmu', '-summary', '-check', '-dump-csv',
|
|
221
|
+
'operations/cli-bouncing_ball.csv'])
|
|
222
|
+
self.assert_identical_files("operations/cli-bouncing_ball.csv", "operations/REF-bouncing_ball.csv")
|
|
223
|
+
|
|
224
|
+
def test_fmucontainer_csv(self):
|
|
225
|
+
fmucontainer(['-container', 'cli-bouncing.csv', '-fmu-directory', 'containers/bouncing_ball', '-mt', '-debug'])
|
|
226
|
+
self.assert_identical_files("containers/bouncing_ball/REF-container.txt",
|
|
227
|
+
"containers/bouncing_ball/cli-bouncing/resources/container.txt")
|
|
228
|
+
|
|
229
|
+
def test_fmucontainer_json(self):
|
|
230
|
+
fmucontainer(['-fmu-directory', 'containers/arch', '-container', 'cli-flat.json', '-dump'])
|
|
231
|
+
self.assert_identical_files("containers/arch/REF-cli-flat-dump.json",
|
|
232
|
+
"containers/arch/cli-flat-dump.json")
|
|
233
|
+
|
|
234
|
+
def test_fmusplit(self):
|
|
235
|
+
fmusplit(["-fmu", "containers/ssp/bouncing.fmu"])
|
|
236
|
+
self.assertTrue(Path("containers/ssp/bouncing.dir/bb_position.fmu").exists())
|
|
237
|
+
self.assertTrue(Path("containers/ssp/bouncing.dir/bb_velocity.fmu").exists())
|
|
238
|
+
self.assert_identical_files("containers/ssp/REF-split-bouncing.json",
|
|
239
|
+
"containers/ssp/bouncing.dir/bouncing.json")
|
|
240
|
+
|
|
217
241
|
|
|
218
242
|
if __name__ == '__main__':
|
|
219
243
|
unittest.main()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'V1.9-rc7'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fmu_manipulation_toolbox-1.9rc7 → fmu_manipulation_toolbox-1.9rc9}/fmu_manipulation_toolbox/gui.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|