fmu-manipulation-toolbox 1.9rc4__tar.gz → 1.9rc6__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.9rc4 → fmu_manipulation_toolbox-1.9rc6}/PKG-INFO +1 -1
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/__version__.py +1 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/cli/__init__.py +0 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/cli/fmucontainer.py +103 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/cli/fmusplit.py +45 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/cli/fmutool.py +115 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/cli/utils.py +36 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/container.py +10 -8
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/operations.py +3 -2
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/remoting.py +3 -3
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/darwin64/container.dylib +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/linux32/client_sm.so +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/linux64/client_sm.so +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/linux64/container.so +0 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/resources/win32/client_sm.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/win32/server_sm.exe +0 -0
- fmu_manipulation_toolbox-1.9rc6/fmu_manipulation_toolbox/resources/win64/client_sm.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/win64/container.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/win64/server_sm.exe +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/PKG-INFO +1 -1
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/SOURCES.txt +5 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/setup.py +1 -1
- fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/__version__.py +0 -1
- fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win32/client_sm.dll +0 -0
- fmu_manipulation_toolbox-1.9rc4/fmu_manipulation_toolbox/resources/win64/client_sm.dll +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/LICENSE.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/README.md +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/__init__.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/__main__.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/assembly.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/checker.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/gui.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/gui_style.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/help.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-checked-disabled.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-checked-hover.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-checked.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-unchecked-disabled.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-unchecked-hover.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/checkbox-unchecked.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/container.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/drop_fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Annotation.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2AttributeGroups.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ModelDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2ScalarVariable.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Type.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2Unit.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-2.0/fmi2VariableDependency.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Annotation.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3AttributeGroups.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3BuildDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3InterfaceType.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3LayeredStandardManifest.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3ModelDescription.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Terminal.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3TerminalsAndIcons.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Type.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Unit.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3Variable.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmi-3.0/fmi3VariableDependency.xsd +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/fmu_manipulation_toolbox.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/help.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/icon-round.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/icon.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/icon_fmu.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/license.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/linux32/server_sm +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/linux64/server_sm +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/mask.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/resources/model.png +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/split.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/version.py +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/dependency_links.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/entry_points.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/requires.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox.egg-info/top_level.txt +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/setup.cfg +0 -0
- {fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/tests/test_suite.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.9rc6
|
|
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-rc6'
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from .utils import setup_logger, make_wide
|
|
7
|
+
from ..assembly import Assembly, AssemblyError
|
|
8
|
+
from ..container import FMUContainerError
|
|
9
|
+
from ..version import __version__ as version
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def fmucontainer():
|
|
13
|
+
logger = setup_logger()
|
|
14
|
+
|
|
15
|
+
logger.info(f"FMUContainer version {version}")
|
|
16
|
+
parser = argparse.ArgumentParser(prog="fmucontainer", description="Generate FMU from FMU's",
|
|
17
|
+
formatter_class=make_wide(argparse.ArgumentDefaultsHelpFormatter),
|
|
18
|
+
add_help=False,
|
|
19
|
+
epilog="see: https://github.com/grouperenault/fmu_manipulation_toolbox/blob/main/"
|
|
20
|
+
"container/README.md")
|
|
21
|
+
|
|
22
|
+
parser.add_argument('-h', '-help', action="help")
|
|
23
|
+
|
|
24
|
+
parser.add_argument("-fmu-directory", action="store", dest="fmu_directory", required=False, default=".",
|
|
25
|
+
help="Directory containing initial FMU’s and used to generate containers. "
|
|
26
|
+
"If not defined, current directory is used.")
|
|
27
|
+
|
|
28
|
+
parser.add_argument("-fmi", action="store", dest="fmi_version", required=False, default="2",
|
|
29
|
+
help="Define version of FMI to be used for container interface."
|
|
30
|
+
"Only '2' or '3' is supported.")
|
|
31
|
+
|
|
32
|
+
parser.add_argument("-container", action="append", dest="container_descriptions_list", default=[],
|
|
33
|
+
metavar="filename.{csv|json|ssp},[:step_size]", required=True,
|
|
34
|
+
help="Description of the container to create.")
|
|
35
|
+
|
|
36
|
+
parser.add_argument("-debug", action="store_true", dest="debug",
|
|
37
|
+
help="Add lot of useful log during the process.")
|
|
38
|
+
|
|
39
|
+
parser.add_argument("-no-auto-input", action="store_false", dest="auto_input", default=True,
|
|
40
|
+
help="Create ONLY explicit input.")
|
|
41
|
+
|
|
42
|
+
parser.add_argument("-no-auto-output", action="store_false", dest="auto_output", default=True,
|
|
43
|
+
help="Create ONLY explicit output.")
|
|
44
|
+
|
|
45
|
+
parser.add_argument("-auto-parameter", action="store_true", dest="auto_parameter", default=False,
|
|
46
|
+
help="Expose parameters of the embedded fmu's.")
|
|
47
|
+
|
|
48
|
+
parser.add_argument("-auto-local", action="store_true", dest="auto_local", default=False,
|
|
49
|
+
help="Expose local variables of the embedded fmu's.")
|
|
50
|
+
|
|
51
|
+
parser.add_argument("-no-auto-link", action="store_false", dest="auto_link", default=True,
|
|
52
|
+
help="Create ONLY explicit links.")
|
|
53
|
+
|
|
54
|
+
parser.add_argument("-mt", action="store_true", dest="mt", default=False,
|
|
55
|
+
help="Enable Multi-Threaded mode for the generated container.")
|
|
56
|
+
|
|
57
|
+
parser.add_argument("-profile", action="store_true", dest="profiling", default=False,
|
|
58
|
+
help="Enable Profiling mode for the generated container.")
|
|
59
|
+
|
|
60
|
+
parser.add_argument("-sequential", action="store_true", dest="sequential", default=False,
|
|
61
|
+
help="Use sequential mode to schedule embedded fmu's.")
|
|
62
|
+
|
|
63
|
+
parser.add_argument("-dump-json", action="store_true", dest="dump", default=False,
|
|
64
|
+
help="Dump a JSON file for each container.")
|
|
65
|
+
|
|
66
|
+
config = parser.parse_args()
|
|
67
|
+
|
|
68
|
+
if config.debug:
|
|
69
|
+
logger.setLevel(logging.DEBUG)
|
|
70
|
+
|
|
71
|
+
fmu_directory = Path(config.fmu_directory)
|
|
72
|
+
logger.info(f"FMU directory: '{fmu_directory}'")
|
|
73
|
+
|
|
74
|
+
for description in config.container_descriptions_list:
|
|
75
|
+
try:
|
|
76
|
+
tokens = description.split(":")
|
|
77
|
+
filename = ":".join(tokens[:-1])
|
|
78
|
+
step_size = float(tokens[-1])
|
|
79
|
+
except ValueError:
|
|
80
|
+
step_size = None
|
|
81
|
+
filename = description
|
|
82
|
+
|
|
83
|
+
try:
|
|
84
|
+
assembly = Assembly(filename, step_size=step_size, auto_link=config.auto_link,
|
|
85
|
+
auto_input=config.auto_input, auto_output=config.auto_output,
|
|
86
|
+
auto_local=config.auto_local, mt=config.mt, sequential=config.sequential,
|
|
87
|
+
profiling=config.profiling, fmu_directory=fmu_directory, debug=config.debug,
|
|
88
|
+
auto_parameter=config.auto_parameter)
|
|
89
|
+
except FileNotFoundError as e:
|
|
90
|
+
logger.fatal(f"Cannot read file: {e}")
|
|
91
|
+
continue
|
|
92
|
+
except (FMUContainerError, AssemblyError) as e:
|
|
93
|
+
logger.fatal(f"{filename}: {e}")
|
|
94
|
+
continue
|
|
95
|
+
|
|
96
|
+
try:
|
|
97
|
+
assembly.make_fmu(dump_json=config.dump, fmi_version=int(config.fmi_version))
|
|
98
|
+
except FMUContainerError as e:
|
|
99
|
+
logger.fatal(f"{filename}: {e}")
|
|
100
|
+
continue
|
|
101
|
+
|
|
102
|
+
if __name__ == "__main__":
|
|
103
|
+
fmucontainer()
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import logging
|
|
3
|
+
|
|
4
|
+
from .utils import setup_logger, make_wide
|
|
5
|
+
from ..split import FMUSplitter, FMUSplitterError
|
|
6
|
+
from ..version import __version__ as version
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def fmusplit():
|
|
10
|
+
logger = setup_logger()
|
|
11
|
+
|
|
12
|
+
logger.info(f"FMUSplit version {version}")
|
|
13
|
+
parser = argparse.ArgumentParser(prog="fmusplit", description="Split FMU Container into FMU's",
|
|
14
|
+
formatter_class=make_wide(argparse.ArgumentDefaultsHelpFormatter),
|
|
15
|
+
add_help=False,
|
|
16
|
+
epilog="see: https://github.com/grouperenault/fmu_manipulation_toolbox/blob/main/"
|
|
17
|
+
"container/README.md")
|
|
18
|
+
parser.add_argument('-h', '-help', action="help")
|
|
19
|
+
|
|
20
|
+
parser.add_argument("-debug", action="store_true", dest="debug",
|
|
21
|
+
help="Add lot of useful log during the process.")
|
|
22
|
+
|
|
23
|
+
parser.add_argument("-fmu", action="append", dest="fmu_filename_list", default=[],
|
|
24
|
+
metavar="filename.fmu", required=True,
|
|
25
|
+
help="Description of the FMU container to split.")
|
|
26
|
+
|
|
27
|
+
config = parser.parse_args()
|
|
28
|
+
|
|
29
|
+
if config.debug:
|
|
30
|
+
logger.setLevel(logging.DEBUG)
|
|
31
|
+
|
|
32
|
+
for fmu_filename in config.fmu_filename_list:
|
|
33
|
+
try:
|
|
34
|
+
splitter = FMUSplitter(fmu_filename)
|
|
35
|
+
splitter.split_fmu()
|
|
36
|
+
except FMUSplitterError as e:
|
|
37
|
+
logger.fatal(f"{fmu_filename}: {e}")
|
|
38
|
+
continue
|
|
39
|
+
except FileNotFoundError as e:
|
|
40
|
+
logger.fatal(f"Cannot read file: {e}")
|
|
41
|
+
continue
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
if __name__ == "__main__":
|
|
45
|
+
fmusplit()
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import argparse
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from .utils import setup_logger, make_wide
|
|
5
|
+
from ..operations import (OperationSummary, OperationError, OperationRemoveRegexp,
|
|
6
|
+
OperationRemoveSources, OperationTrimUntil, OperationKeepOnlyRegexp, OperationMergeTopLevel,
|
|
7
|
+
OperationStripTopLevel, OperationRenameFromCSV, OperationSaveNamesToCSV, FMU, FMUError)
|
|
8
|
+
from ..remoting import (OperationAddFrontendWin32, OperationAddFrontendWin64, OperationAddRemotingWin32,
|
|
9
|
+
OperationAddRemotingWin64)
|
|
10
|
+
from ..checker import checker_list
|
|
11
|
+
from ..version import __version__ as version
|
|
12
|
+
from ..help import Help
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def fmutool():
|
|
16
|
+
logger = setup_logger()
|
|
17
|
+
|
|
18
|
+
logger.info(f"FMU Manipulation Toolbox version {version}")
|
|
19
|
+
help_message = Help()
|
|
20
|
+
|
|
21
|
+
parser = argparse.ArgumentParser(prog='fmutool',
|
|
22
|
+
description="Analyse and Manipulate a FMU by modifying its 'modelDescription.xml'",
|
|
23
|
+
formatter_class=make_wide(argparse.HelpFormatter),
|
|
24
|
+
add_help=False,
|
|
25
|
+
epilog="see: https://github.com/grouperenault/fmu_manipulation_toolbox/blob/main/README.md")
|
|
26
|
+
|
|
27
|
+
def add_option(option, *args, **kwargs):
|
|
28
|
+
parser.add_argument(option, *args, help=help_message.usage(option), **kwargs)
|
|
29
|
+
|
|
30
|
+
add_option('-h', '-help', action="help")
|
|
31
|
+
|
|
32
|
+
# I/O
|
|
33
|
+
add_option('-input', action='store', dest='fmu_input', default=None, required=True, metavar='path/to/module.fmu')
|
|
34
|
+
add_option('-output', action='store', dest='fmu_output', default=None, metavar='path/to/module-modified.fmu')
|
|
35
|
+
|
|
36
|
+
# Port name manipulation
|
|
37
|
+
add_option('-remove-toplevel', action='append_const', dest='operations_list', const=OperationStripTopLevel())
|
|
38
|
+
add_option('-merge-toplevel', action='append_const', dest='operations_list', const=OperationMergeTopLevel())
|
|
39
|
+
add_option('-trim-until', action='append', dest='operations_list', type=OperationTrimUntil, metavar='prefix')
|
|
40
|
+
add_option('-remove-regexp', action='append', dest='operations_list', type=OperationRemoveRegexp,
|
|
41
|
+
metavar='regular-expression')
|
|
42
|
+
add_option('-keep-only-regexp', action='append', dest='operations_list', type=OperationKeepOnlyRegexp,
|
|
43
|
+
metavar='regular-expression')
|
|
44
|
+
add_option('-remove-all', action='append_const', dest='operations_list', const=OperationRemoveRegexp('.*'))
|
|
45
|
+
|
|
46
|
+
# Batch Rename
|
|
47
|
+
add_option('-dump-csv', action='append', dest='operations_list', type=OperationSaveNamesToCSV,
|
|
48
|
+
metavar='path/to/list.csv')
|
|
49
|
+
add_option('-rename-from-csv', action='append', dest='operations_list', type=OperationRenameFromCSV,
|
|
50
|
+
metavar='path/to/translation.csv')
|
|
51
|
+
|
|
52
|
+
# Remoting
|
|
53
|
+
add_option('-add-remoting-win32', action='append_const', dest='operations_list', const=OperationAddRemotingWin32())
|
|
54
|
+
add_option('-add-remoting-win64', action='append_const', dest='operations_list', const=OperationAddRemotingWin64())
|
|
55
|
+
add_option('-add-frontend-win32', action='append_const', dest='operations_list', const=OperationAddFrontendWin32())
|
|
56
|
+
add_option('-add-frontend-win64', action='append_const', dest='operations_list', const=OperationAddFrontendWin64())
|
|
57
|
+
|
|
58
|
+
# Extraction / Removal
|
|
59
|
+
add_option('-extract-descriptor', action='store', dest='extract_description',
|
|
60
|
+
metavar='path/to/saved-modelDescriptor.xml')
|
|
61
|
+
add_option('-remove-sources', action='append_const', dest='operations_list',
|
|
62
|
+
const=OperationRemoveSources())
|
|
63
|
+
# Filter
|
|
64
|
+
add_option('-only-parameters', action='append_const', dest='apply_on', const='parameter')
|
|
65
|
+
add_option('-only-inputs', action='append_const', dest='apply_on', const='input')
|
|
66
|
+
add_option('-only-outputs', action='append_const', dest='apply_on', const='output')
|
|
67
|
+
# Checker
|
|
68
|
+
add_option('-summary', action='append_const', dest='operations_list', const=OperationSummary())
|
|
69
|
+
add_option('-check', action='append_const', dest='operations_list', const=[checker() for checker in checker_list])
|
|
70
|
+
|
|
71
|
+
cli_options = parser.parse_args()
|
|
72
|
+
# handle the "no operation" use case
|
|
73
|
+
if not cli_options.operations_list:
|
|
74
|
+
cli_options.operations_list = []
|
|
75
|
+
|
|
76
|
+
if cli_options.fmu_input == cli_options.fmu_output:
|
|
77
|
+
logger.fatal(f"'-input' and '-output' should point to different files.")
|
|
78
|
+
sys.exit(-3)
|
|
79
|
+
|
|
80
|
+
logger.info(f"READING Input='{cli_options.fmu_input}'")
|
|
81
|
+
try:
|
|
82
|
+
fmu = FMU(cli_options.fmu_input)
|
|
83
|
+
except FMUError as reason:
|
|
84
|
+
logger.fatal(f"{reason}")
|
|
85
|
+
sys.exit(-4)
|
|
86
|
+
|
|
87
|
+
if cli_options.apply_on:
|
|
88
|
+
logger.info("Applying operation for :")
|
|
89
|
+
for causality in cli_options.apply_on:
|
|
90
|
+
logger.info(f" - causality = {causality}")
|
|
91
|
+
|
|
92
|
+
for operation in cli_options.operations_list:
|
|
93
|
+
logger.info(f" => {operation}")
|
|
94
|
+
try:
|
|
95
|
+
fmu.apply_operation(operation, cli_options.apply_on)
|
|
96
|
+
except OperationError as reason:
|
|
97
|
+
logger.fatal(f"{reason}")
|
|
98
|
+
sys.exit(-6)
|
|
99
|
+
|
|
100
|
+
if cli_options.extract_description:
|
|
101
|
+
logger.info(f"WRITING ModelDescriptor='{cli_options.extract_description}'")
|
|
102
|
+
fmu.save_descriptor(cli_options.extract_description)
|
|
103
|
+
|
|
104
|
+
if cli_options.fmu_output:
|
|
105
|
+
logger.info(f"WRITING Output='{cli_options.fmu_output}'")
|
|
106
|
+
try:
|
|
107
|
+
fmu.repack(cli_options.fmu_output)
|
|
108
|
+
except FMUError as reason:
|
|
109
|
+
logger.fatal(f"FATAL ERROR: {reason}")
|
|
110
|
+
sys.exit(-5)
|
|
111
|
+
else:
|
|
112
|
+
logger.info(f"INFO Modified FMU is not saved. If necessary use '-output' option.")
|
|
113
|
+
|
|
114
|
+
if __name__ == "__main__":
|
|
115
|
+
fmutool()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
import sys
|
|
3
|
+
from colorama import Fore, Style, init
|
|
4
|
+
|
|
5
|
+
def setup_logger():
|
|
6
|
+
class CustomFormatter(logging.Formatter):
|
|
7
|
+
def format(self, record):
|
|
8
|
+
log_format = "%(levelname)-8s | %(message)s"
|
|
9
|
+
format_per_level = {
|
|
10
|
+
logging.DEBUG: str(Fore.BLUE) + log_format,
|
|
11
|
+
logging.INFO: str(Fore.CYAN) + log_format,
|
|
12
|
+
logging.WARNING: str(Fore.YELLOW) + log_format,
|
|
13
|
+
logging.ERROR: str(Fore.RED) + log_format,
|
|
14
|
+
logging.CRITICAL: str(Fore.RED + Style.BRIGHT) + log_format,
|
|
15
|
+
}
|
|
16
|
+
formatter = logging.Formatter(format_per_level[record.levelno])
|
|
17
|
+
return formatter.format(record)
|
|
18
|
+
init()
|
|
19
|
+
logger = logging.getLogger("fmu_manipulation_toolbox")
|
|
20
|
+
handler = logging.StreamHandler(stream=sys.stdout)
|
|
21
|
+
handler.setFormatter(CustomFormatter())
|
|
22
|
+
logger.addHandler(handler)
|
|
23
|
+
logger.setLevel(logging.INFO)
|
|
24
|
+
|
|
25
|
+
return logger
|
|
26
|
+
|
|
27
|
+
def make_wide(formatter, w=120, h=36):
|
|
28
|
+
"""Return a wider HelpFormatter, if possible."""
|
|
29
|
+
try:
|
|
30
|
+
# https://stackoverflow.com/a/5464440
|
|
31
|
+
# beware: "Only the name of this class is considered a public API."
|
|
32
|
+
kwargs = {'width': w, 'max_help_position': h}
|
|
33
|
+
formatter(None, **kwargs)
|
|
34
|
+
return lambda prog: formatter(prog, **kwargs)
|
|
35
|
+
except TypeError:
|
|
36
|
+
return formatter
|
|
@@ -10,7 +10,7 @@ from datetime import datetime
|
|
|
10
10
|
from pathlib import Path
|
|
11
11
|
from typing import *
|
|
12
12
|
|
|
13
|
-
from .operations import FMU, OperationAbstract, FMUError
|
|
13
|
+
from .operations import FMU, OperationAbstract, FMUError, FMUPort
|
|
14
14
|
from .version import __version__ as tool_version
|
|
15
15
|
|
|
16
16
|
|
|
@@ -71,9 +71,7 @@ class EmbeddedFMUPort:
|
|
|
71
71
|
"string"
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
def __init__(self, fmi_type, attrs: Dict[str, str], fmi_version=0):
|
|
74
|
+
def __init__(self, fmi_type, attrs: Union[FMUPort, Dict[str, str]], fmi_version=0):
|
|
77
75
|
self.causality = attrs.get("causality", "local")
|
|
78
76
|
self.variability = attrs.get("variability", "continuous")
|
|
79
77
|
self.name = attrs["name"]
|
|
@@ -88,8 +86,6 @@ class EmbeddedFMUPort:
|
|
|
88
86
|
self.start_value = attrs.get("start", None)
|
|
89
87
|
self.initial = attrs.get("initial", None)
|
|
90
88
|
|
|
91
|
-
|
|
92
|
-
|
|
93
89
|
def xml(self, vr: int, name=None, causality=None, start=None, fmi_version=2) -> str:
|
|
94
90
|
if name is None:
|
|
95
91
|
name = self.name
|
|
@@ -191,7 +187,7 @@ class EmbeddedFMU(OperationAbstract):
|
|
|
191
187
|
if fmi_version == "2.0":
|
|
192
188
|
self.guid = attrs['guid']
|
|
193
189
|
self.fmi_version = 2
|
|
194
|
-
if fmi_version == "3.0":
|
|
190
|
+
if fmi_version == "3.0": # TODO: handle 3.x cases
|
|
195
191
|
self.guid = attrs['instantiationToken']
|
|
196
192
|
self.fmi_version = 3
|
|
197
193
|
|
|
@@ -208,7 +204,13 @@ class EmbeddedFMU(OperationAbstract):
|
|
|
208
204
|
self.start_time = float(attrs.get("startTime", 0.0))
|
|
209
205
|
self.stop_time = float(attrs.get("stopTime", self.start_time + 1.0))
|
|
210
206
|
|
|
211
|
-
def port_attrs(self, fmu_port):
|
|
207
|
+
def port_attrs(self, fmu_port: FMUPort):
|
|
208
|
+
# Container will manage Enumeration as Integer
|
|
209
|
+
if fmu_port.fmi_type == "Enumeration":
|
|
210
|
+
if self.fmi_version == 2:
|
|
211
|
+
fmu_port.fmi_type = "Integer"
|
|
212
|
+
else:
|
|
213
|
+
fmu_port.fmi_type = "Int32"
|
|
212
214
|
port = EmbeddedFMUPort(fmu_port.fmi_type, fmu_port, fmi_version=self.fmi_version)
|
|
213
215
|
self.ports[port.name] = port
|
|
214
216
|
|
|
@@ -160,8 +160,9 @@ class Manipulation:
|
|
|
160
160
|
self.current_port = FMUPort()
|
|
161
161
|
self.current_port.push_attrs(attrs)
|
|
162
162
|
elif self.fmu.fmi_version == 2 and name in self.fmu.FMI2_TYPES:
|
|
163
|
-
self.current_port.
|
|
164
|
-
|
|
163
|
+
if self.current_port: # <Enumeration> can be found before port defition. Ignored.
|
|
164
|
+
self.current_port.fmi_type = name
|
|
165
|
+
self.current_port.push_attrs(attrs)
|
|
165
166
|
elif self.fmu.fmi_version == 3 and name in self.fmu.FMI3_TYPES:
|
|
166
167
|
self.current_port = FMUPort()
|
|
167
168
|
self.current_port.fmi_type = name
|
|
@@ -19,8 +19,8 @@ class OperationAddRemotingWinAbstract(OperationAbstract):
|
|
|
19
19
|
"Integer": [],
|
|
20
20
|
"Boolean": []
|
|
21
21
|
}
|
|
22
|
-
self.nb_input = 0
|
|
23
|
-
self.nb_output = 0
|
|
22
|
+
self.nb_input = 0
|
|
23
|
+
self.nb_output = 0
|
|
24
24
|
|
|
25
25
|
def fmi_attrs(self, attrs):
|
|
26
26
|
if not attrs["fmiVersion"] == "2.0":
|
|
@@ -61,7 +61,7 @@ class OperationAddRemotingWinAbstract(OperationAbstract):
|
|
|
61
61
|
|
|
62
62
|
def port_attrs(self, fmu_port) -> int:
|
|
63
63
|
try:
|
|
64
|
-
self.vr[fmu_port.fmi_type].append(fmu_port["valueReference"])
|
|
64
|
+
self.vr[fmu_port.fmi_type].append(int(fmu_port["valueReference"]))
|
|
65
65
|
if fmu_port["causality"] in ("input", "parameter"):
|
|
66
66
|
self.nb_input += 1
|
|
67
67
|
else:
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: fmu_manipulation_toolbox
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.9rc6
|
|
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
|
|
@@ -21,6 +21,11 @@ fmu_manipulation_toolbox.egg-info/dependency_links.txt
|
|
|
21
21
|
fmu_manipulation_toolbox.egg-info/entry_points.txt
|
|
22
22
|
fmu_manipulation_toolbox.egg-info/requires.txt
|
|
23
23
|
fmu_manipulation_toolbox.egg-info/top_level.txt
|
|
24
|
+
fmu_manipulation_toolbox/cli/__init__.py
|
|
25
|
+
fmu_manipulation_toolbox/cli/fmucontainer.py
|
|
26
|
+
fmu_manipulation_toolbox/cli/fmusplit.py
|
|
27
|
+
fmu_manipulation_toolbox/cli/fmutool.py
|
|
28
|
+
fmu_manipulation_toolbox/cli/utils.py
|
|
24
29
|
fmu_manipulation_toolbox/resources/checkbox-checked-disabled.png
|
|
25
30
|
fmu_manipulation_toolbox/resources/checkbox-checked-hover.png
|
|
26
31
|
fmu_manipulation_toolbox/resources/checkbox-checked.png
|
|
@@ -24,7 +24,7 @@ except Exception as e:
|
|
|
24
24
|
setup(
|
|
25
25
|
name="fmu_manipulation_toolbox",
|
|
26
26
|
version=version,
|
|
27
|
-
packages=["fmu_manipulation_toolbox"],
|
|
27
|
+
packages=["fmu_manipulation_toolbox", "fmu_manipulation_toolbox.cli"],
|
|
28
28
|
package_data={"fmu_manipulation_toolbox": [
|
|
29
29
|
"resources/win32/client_sm.dll",
|
|
30
30
|
"resources/win32/server_sm.exe",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
'V1.9-rc4'
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/gui.py
RENAMED
|
File without changes
|
|
File without changes
|
{fmu_manipulation_toolbox-1.9rc4 → fmu_manipulation_toolbox-1.9rc6}/fmu_manipulation_toolbox/help.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
|