PySimultan 0.4.0__tar.gz → 0.4.1__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {pysimultan-0.4.0 → pysimultan-0.4.1}/.gitignore +2 -2
- {pysimultan-0.4.0 → pysimultan-0.4.1}/PKG-INFO +1 -1
- pysimultan-0.4.1/src/PySimultan2/__about__.py +1 -0
- pysimultan-0.4.1/src/PySimultan2/__init__.py +99 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/data_model.py +56 -68
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/default_types.py +2 -2
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/files.py +6 -3
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/geometry/geometry_base.py +3 -2
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/geometry/utils.py +1 -1
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/object_mapper.py +13 -5
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/simultan_object.py +20 -4
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/taxonomy_maps.py +13 -1
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/utils.py +36 -39
- pysimultan-0.4.1/tests/__init__.py +0 -0
- pysimultan-0.4.1/tests/readme_examples/__init__.py +0 -0
- pysimultan-0.4.1/tests/readme_examples/create_component.py +35 -0
- pysimultan-0.4.1/tests/readme_examples/create_component_with_taxonomy_slot.py +76 -0
- pysimultan-0.4.1/tests/readme_examples/create_referenced_component.py +61 -0
- pysimultan-0.4.1/tests/readme_examples/create_taxonomies.py +29 -0
- pysimultan-0.4.1/tests/readme_examples/resources/__init__.py +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/change_references_example.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/empty_project.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/empty_test_excel.xlsx +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/example1.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/example2.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/example3.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/example4_reference_list.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/example_extend_1.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/list_test.simultan +0 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example3.yml +20 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example4.yml +50 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example_create_typed_component.yml +10 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example_create_typed_component_with_slots.yml +22 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example_extend.yml +10 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_example_update_references.yml +33 -0
- pysimultan-0.4.1/tests/readme_examples/resources/template_reference_list.yml +1 -0
- pysimultan-0.4.1/tests/resources/U5.simultan +0 -0
- pysimultan-0.4.1/tests/resources/U5_1.simultan +0 -0
- pysimultan-0.4.1/tests/resources/U5_orig.simultan +0 -0
- pysimultan-0.4.1/tests/resources/__init__.py +0 -0
- pysimultan-0.4.1/tests/resources/new_geometry_test.simultan +0 -0
- pysimultan-0.4.1/tests/resources/test_file.yml +1 -0
- pysimultan-0.4.1/tests/resources/test_file_load.simultan +0 -0
- pysimultan-0.4.1/tests/resources/test_file_project.simultan +0 -0
- pysimultan-0.4.1/tests/resources/test_multi_value_big_table_load.simultan +0 -0
- pysimultan-0.4.1/tests/test_calc_static_zone_temperature.py +0 -0
- pysimultan-0.4.1/tests/test_calculate_steady_state_temperature.py +595 -0
- pysimultan-0.4.1/tests/test_circular_references.py +176 -0
- pysimultan-0.4.1/tests/test_create_geometry.py +166 -0
- pysimultan-0.4.1/tests/test_files.py +109 -0
- pysimultan-0.4.1/tests/test_files_load.py +97 -0
- pysimultan-0.4.1/tests/test_load_geometry.py +148 -0
- pysimultan-0.4.1/tests/test_load_multi_values.py +17 -0
- pysimultan-0.4.1/tests/test_new_dll.py +24 -0
- pysimultan-0.4.1/tests/test_new_project_creation.py +25 -0
- pysimultan-0.4.1/tests/test_numeric_map.py +122 -0
- pysimultan-0.4.1/tests/test_pythonnet.py +2 -0
- pysimultan-0.4.1/tests/test_register_class.py +149 -0
- pysimultan-0.4.1/tests/test_set_attr_property.py +76 -0
- pysimultan-0.4.1/tests/test_set_dictionary.py +88 -0
- pysimultan-0.4.1/tests/test_set_properties.py +159 -0
- pysimultan-0.4.1/tests/test_taxonomie_maps.py +33 -0
- pysimultan-0.4.1/tests/test_taxonomies.py +15 -0
- pysimultan-0.4.1/tests/test_ui.py +515 -0
- pysimultan-0.4.1/tests/ui_minimal_example.py +55 -0
- pysimultan-0.4.0/src/PySimultan2/__about__.py +0 -1
- pysimultan-0.4.0/src/PySimultan2/__init__.py +0 -38
- pysimultan-0.4.0/src/PySimultan2/config.py +0 -52
- {pysimultan-0.4.0 → pysimultan-0.4.1}/LICENSE.txt +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/README.md +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/pyproject.toml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/geometry/__init__.py +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/multi_values.py +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/AssimpNet.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/AvalonDock.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/BruTile.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ClosedXML.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ComponentBuilder.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ComponentBuilder.dll.config +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ComponentBuilder.runtimeconfig.json +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ComponentBuilder.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ControlzEx.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/DotSpatial.Projections.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/ExcelNumberFormat.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Fluent.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/GeometryViewer.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/GeometryViewer.dll.config +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/GeometryViewer.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/HelixToolkit.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/MathNet.Numerics.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Newtonsoft.Json.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.Lang.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.Plugins.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.UI.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.UI.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SIMULTAN.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.DXGI.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.Mathematics.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SharpDX.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SitePlanner.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SitePlanner.dll.config +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/SitePlanner.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Sprache.Calc.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/Sprache.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/System.Data.OleDb.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/__init__.py +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/assimp.dll +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/defaultsettings.xml +0 -0
- {pysimultan-0.4.0 → pysimultan-0.4.1}/src/PySimultan2/resources/setup.bat +0 -0
@@ -17,9 +17,9 @@ build
|
|
17
17
|
~*.simultan
|
18
18
|
*.simultanbackup
|
19
19
|
simultan_exception*
|
20
|
-
/tests/resources/~*
|
20
|
+
/PySimultan2/tests/resources/~*
|
21
21
|
/tests/resources/*.codxf
|
22
|
-
/tests/readme_examples/resources/~*
|
22
|
+
/PySimultan2/tests/readme_examples/resources/~*
|
23
23
|
/tests/readme_examples/resources/*.codxf
|
24
24
|
|
25
25
|
*.AppImage
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: PySimultan
|
3
|
-
Version: 0.4.
|
3
|
+
Version: 0.4.1
|
4
4
|
Project-URL: Documentation, https://github.com/Bühler Maximilian/PySimultan2#readme
|
5
5
|
Project-URL: Issues, https://github.com/Bühler Maximilian/PySimultan2/issues
|
6
6
|
Project-URL: Source, https://github.com/Bühler Maximilian/PySimultan2
|
@@ -0,0 +1 @@
|
|
1
|
+
version = '0.4.1'
|
@@ -0,0 +1,99 @@
|
|
1
|
+
import os
|
2
|
+
import sys
|
3
|
+
import colorlog
|
4
|
+
# from .config import *
|
5
|
+
from ruamel.yaml import YAML, yaml_object, add_representer
|
6
|
+
|
7
|
+
def setup_logging():
|
8
|
+
handler = colorlog.StreamHandler()
|
9
|
+
formatter = colorlog.ColoredFormatter(
|
10
|
+
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
|
11
|
+
datefmt=None,
|
12
|
+
reset=True,
|
13
|
+
log_colors={
|
14
|
+
'DEBUG': 'cyan',
|
15
|
+
'INFO': 'green',
|
16
|
+
'WARNING': 'yellow',
|
17
|
+
'ERROR': 'red',
|
18
|
+
'CRITICAL': 'red,bg_white',
|
19
|
+
},
|
20
|
+
secondary_log_colors={},
|
21
|
+
style='%'
|
22
|
+
)
|
23
|
+
|
24
|
+
handler.setFormatter(formatter)
|
25
|
+
|
26
|
+
logger = colorlog.getLogger('PySimultan')
|
27
|
+
logger.addHandler(handler)
|
28
|
+
|
29
|
+
return logger
|
30
|
+
|
31
|
+
|
32
|
+
def setup():
|
33
|
+
import colorlog
|
34
|
+
try:
|
35
|
+
import importlib.resources as pkg_resources
|
36
|
+
except ImportError:
|
37
|
+
# Try backported to PY<37 importlib_resources.
|
38
|
+
import importlib_resources as pkg_resources
|
39
|
+
|
40
|
+
from . import resources
|
41
|
+
sys.path.append(str(pkg_resources.files(resources)))
|
42
|
+
|
43
|
+
logger = colorlog.getLogger('PySimultan')
|
44
|
+
logger.setLevel('DEBUG')
|
45
|
+
|
46
|
+
dll_path = os.environ.get('SIMULTAN_SDK_DIR', None)
|
47
|
+
if dll_path is None:
|
48
|
+
with pkg_resources.path(resources, 'SIMULTAN.dll') as r_path:
|
49
|
+
dll_path = str(r_path)
|
50
|
+
sys.path.append(dll_path)
|
51
|
+
|
52
|
+
from pythonnet import load
|
53
|
+
from pythonnet import clr_loader, set_runtime
|
54
|
+
list(clr_loader.find_runtimes())
|
55
|
+
load('coreclr')
|
56
|
+
import clr
|
57
|
+
test = clr.AddReference(
|
58
|
+
os.path.join(dll_path, 'SIMULTAN.dll') if not dll_path.endswith('SIMULTAN.dll') else dll_path)
|
59
|
+
clr.AddReference("System.Security.Cryptography")
|
60
|
+
# clr.AddReference(os.path.join(dll_path, 'SIMULTAN'))
|
61
|
+
|
62
|
+
from SIMULTAN.Data.Components import SimComponent
|
63
|
+
|
64
|
+
continue_on_error = True
|
65
|
+
|
66
|
+
def represent_none(self, _):
|
67
|
+
return self.represent_scalar('tag:yaml.org,2002:null', '')
|
68
|
+
|
69
|
+
add_representer(type(None), represent_none)
|
70
|
+
yaml = YAML()
|
71
|
+
yaml.default_flow_style = None
|
72
|
+
yaml.preserve_quotes = True
|
73
|
+
yaml.allow_unicode = True
|
74
|
+
|
75
|
+
return yaml
|
76
|
+
|
77
|
+
|
78
|
+
logger = setup_logging()
|
79
|
+
yaml = setup()
|
80
|
+
|
81
|
+
|
82
|
+
class Config:
|
83
|
+
def __init__(self):
|
84
|
+
self._default_data_model = None
|
85
|
+
self._default_mapper = None
|
86
|
+
self.logger = logger
|
87
|
+
|
88
|
+
def get_default_data_model(self, *args, **kwargs):
|
89
|
+
return self._default_data_model
|
90
|
+
|
91
|
+
def get_default_mapper(self, *args, **kwargs):
|
92
|
+
return self._default_mapper
|
93
|
+
|
94
|
+
|
95
|
+
config = Config()
|
96
|
+
|
97
|
+
from .data_model import DataModel
|
98
|
+
from .files import FileInfo
|
99
|
+
from .object_mapper import PythonMapper
|
@@ -3,7 +3,6 @@ import os
|
|
3
3
|
import shutil
|
4
4
|
from uuid import uuid4
|
5
5
|
from colorlog import getLogger
|
6
|
-
from functools import lru_cache, reduce
|
7
6
|
from weakref import WeakSet, WeakValueDictionary
|
8
7
|
from . import config
|
9
8
|
from .utils import *
|
@@ -46,6 +45,7 @@ from .files import add_tag_to_resource
|
|
46
45
|
|
47
46
|
if TYPE_CHECKING:
|
48
47
|
from .object_mapper import PythonMapper
|
48
|
+
from .geometry import GeometryModel
|
49
49
|
|
50
50
|
|
51
51
|
logger = getLogger('PySimultan')
|
@@ -114,7 +114,7 @@ class DataModel:
|
|
114
114
|
else:
|
115
115
|
print("Failed to create project")
|
116
116
|
|
117
|
-
return cls(project_path=project_path, user_name=user_name, password=password)
|
117
|
+
return cls(project_path=project_path, user_name=user_name, password=password, project_data_manager=projectData)
|
118
118
|
|
119
119
|
def __new__(cls, *args, **kwargs):
|
120
120
|
|
@@ -147,6 +147,8 @@ class DataModel:
|
|
147
147
|
self._project = None
|
148
148
|
self._zip_loader = None
|
149
149
|
|
150
|
+
self.project_data_manager = kwargs.get('project_data_manager', None)
|
151
|
+
|
150
152
|
self.project_path = kwargs.get('project_path', None)
|
151
153
|
|
152
154
|
self.service_provider = Utils.ServicesProvider()
|
@@ -156,38 +158,10 @@ class DataModel:
|
|
156
158
|
self.i_aut_service.password = self.password
|
157
159
|
|
158
160
|
self.service_provider.AddService[SimultanUsers.IAuthenticationService](self.i_aut_service())
|
159
|
-
|
160
|
-
# self.serv = GeometryViewerService([], self.service_provider)
|
161
|
-
# self.service_provider.AddService[IGeometryViewerService](self.serv)
|
162
|
-
|
163
161
|
self.exch = self.project.AllProjectDataManagers.ComponentGeometryExchange
|
164
162
|
# self.exch.ModelStore = self.serv
|
165
163
|
|
166
164
|
self.resources = {}
|
167
|
-
# self.models_dict = {}
|
168
|
-
#
|
169
|
-
# if self.project_data_manager.AssetManager.Resources.__len__() > 0:
|
170
|
-
# for resource in self.project_data_manager.AssetManager.Resources:
|
171
|
-
# if resource is None:
|
172
|
-
# continue
|
173
|
-
# self.resources[resource.Key] = resource
|
174
|
-
# self.models_dict[resource.Key] = None
|
175
|
-
# current_full_path = resource.CurrentFullPath
|
176
|
-
# if current_full_path == '?':
|
177
|
-
# continue
|
178
|
-
#
|
179
|
-
# if resource.Extension == '.simgeo':
|
180
|
-
# error_list = NetList[SimGeoIOError]()
|
181
|
-
#
|
182
|
-
# model = SimGeoIO.Load(resource, self.project_data_manager, error_list, OffsetAlgorithm.Full)
|
183
|
-
# self.models_dict[resource.Key] = model
|
184
|
-
# try:
|
185
|
-
# self.project_data_manager.GeometryModels.AddGeometryModel(model)
|
186
|
-
# except Exception as e:
|
187
|
-
# logger.warning(f'Error while loading Model: {model} from {model.File}: {e}. Trying reload...')
|
188
|
-
# raise e
|
189
|
-
|
190
|
-
self.ValueFields = self.project_data_manager.ValueManager.Items
|
191
165
|
self.import_data_model()
|
192
166
|
|
193
167
|
self.__mongo_instance = None
|
@@ -197,40 +171,41 @@ class DataModel:
|
|
197
171
|
return self.project_data_manager.AssetManager.Resources
|
198
172
|
|
199
173
|
@property
|
200
|
-
def
|
201
|
-
|
202
|
-
|
203
|
-
return
|
174
|
+
def models(self) -> dict[int, 'GeometryModel']:
|
175
|
+
"""
|
176
|
+
Return the geometry models of the project
|
177
|
+
:return: dict[int, GeometryModel]
|
178
|
+
"""
|
204
179
|
|
205
|
-
|
206
|
-
|
207
|
-
self.__mongo_instance = value
|
180
|
+
# if self.models_dict:
|
181
|
+
# return self.models_dict
|
208
182
|
|
209
|
-
@property
|
210
|
-
def models(self):
|
211
183
|
self.models_dict = {}
|
212
184
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
185
|
+
# self.project_data_manager.Reset()
|
186
|
+
|
187
|
+
resources = self.project_data_manager.AssetManager.Resources
|
188
|
+
|
189
|
+
for resource in resources:
|
190
|
+
if resource is None:
|
191
|
+
continue
|
192
|
+
self.resources[resource.Key] = resource
|
218
193
|
|
219
|
-
|
220
|
-
|
221
|
-
|
194
|
+
current_full_path = resource.CurrentFullPath
|
195
|
+
if current_full_path == '?':
|
196
|
+
continue
|
222
197
|
|
223
|
-
|
224
|
-
|
225
|
-
|
198
|
+
if resource.Extension == '.simgeo':
|
199
|
+
self.models_dict[resource.Key] = None
|
200
|
+
error_list = NetList[SimGeoIOError]()
|
226
201
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
202
|
+
model = SimGeoIO.Load(resource, self.project_data_manager, error_list, OffsetAlgorithm.Full)
|
203
|
+
self.models_dict[resource.Key] = model
|
204
|
+
try:
|
205
|
+
self.project_data_manager.GeometryModels.AddGeometryModel(model)
|
206
|
+
except Exception as e:
|
207
|
+
logger.warning(f'Error while loading Model: {model} from {model.File}: {e}')
|
208
|
+
raise e
|
234
209
|
|
235
210
|
return self.models_dict
|
236
211
|
|
@@ -238,14 +213,20 @@ class DataModel:
|
|
238
213
|
def taxonomies(self):
|
239
214
|
return self.project_data_manager.Taxonomies
|
240
215
|
|
216
|
+
@property
|
217
|
+
def ValueFields(self):
|
218
|
+
return self.project_data_manager.ValueManager.Items
|
219
|
+
|
241
220
|
@property
|
242
221
|
def value_fields(self):
|
243
222
|
return self.project_data_manager.ValueManager
|
244
223
|
|
245
224
|
@property
|
246
225
|
def project_data_manager(self):
|
247
|
-
|
226
|
+
|
227
|
+
if self._project_data_manager is None:
|
248
228
|
self._project_data_manager = ExtendedProjectData()
|
229
|
+
|
249
230
|
return self._project_data_manager
|
250
231
|
|
251
232
|
@project_data_manager.setter
|
@@ -261,7 +242,6 @@ class DataModel:
|
|
261
242
|
@user.setter
|
262
243
|
def user(self, value: SimultanUsers.SimUserRole):
|
263
244
|
if value != self._user:
|
264
|
-
self.project_data_manager = None
|
265
245
|
self._project = None
|
266
246
|
self._user = value
|
267
247
|
|
@@ -306,7 +286,6 @@ class DataModel:
|
|
306
286
|
def remove_field(self, field: SimMultiValueField3D):
|
307
287
|
self.project_data_manager.ValueManager.Remove(field)
|
308
288
|
|
309
|
-
@lru_cache(maxsize=None)
|
310
289
|
def get_geo_instance(self, file_id, type, id):
|
311
290
|
geo_model = self.models[file_id]
|
312
291
|
objects = getattr(geo_model.Geometry, type)
|
@@ -381,16 +360,28 @@ class DataModel:
|
|
381
360
|
"""
|
382
361
|
logger.info('closing project...')
|
383
362
|
try:
|
363
|
+
|
384
364
|
self._project.DisableProjectUnpackFolderWatcher()
|
385
365
|
if self._project is not None:
|
366
|
+
if self._project.IsOpened:
|
367
|
+
ZipProjectIO.Close(self._project, True)
|
386
368
|
if self._project.IsLoaded:
|
387
369
|
ZipProjectIO.Unload(self._project)
|
388
|
-
if self._project.IsOpened:
|
389
|
-
ZipProjectIO.Close(self._project, False, True)
|
390
370
|
|
391
|
-
self._project_data_manager.Reset()
|
392
371
|
except Exception as e:
|
393
372
|
pass
|
373
|
+
finally:
|
374
|
+
if self._project_data_manager is not None:
|
375
|
+
del self._project_data_manager
|
376
|
+
self._project_data_manager = None
|
377
|
+
|
378
|
+
data_models = WeakSet()
|
379
|
+
data_models_dict = WeakValueDictionary()
|
380
|
+
|
381
|
+
if config.default_data_model is self:
|
382
|
+
config.default_data_model = None
|
383
|
+
|
384
|
+
del self
|
394
385
|
|
395
386
|
# def create_new_component(self):
|
396
387
|
#
|
@@ -570,14 +561,13 @@ class DataModel:
|
|
570
561
|
if isinstance(component, SimultanObject):
|
571
562
|
component = component._wrapped_obj
|
572
563
|
|
573
|
-
if not component.Instances:
|
574
|
-
return []
|
575
|
-
|
576
564
|
for instance in component.Instances:
|
577
565
|
for placement in instance.Placements.Items:
|
578
566
|
geo_model = next((x for x in self.models.values() if x is not None and x.File.Key == placement.FileId), None)
|
579
567
|
if geo_model is not None:
|
580
568
|
ref_geometries.append((geo_model.Geometry.GeometryFromId(placement.GeometryId), geo_model))
|
569
|
+
if geo_model is None:
|
570
|
+
logger.warning(f'Geometry model with id {placement.FileId} not found in project {self.project_path}')
|
581
571
|
|
582
572
|
return ref_geometries
|
583
573
|
|
@@ -665,7 +655,6 @@ class DataModel:
|
|
665
655
|
None)
|
666
656
|
return model_to_work_with, resource_file
|
667
657
|
|
668
|
-
@lru_cache(maxsize=None)
|
669
658
|
def get_or_create_taxonomy(self, taxonomy_key: str, taxonomy_name: str = None, description='', create=True):
|
670
659
|
taxonomy = next((x for x in self.taxonomies if x.Key == taxonomy_key), None)
|
671
660
|
if taxonomy is None:
|
@@ -676,7 +665,6 @@ class DataModel:
|
|
676
665
|
|
677
666
|
return next((x for x in self.taxonomies if x.Key == taxonomy_key), None)
|
678
667
|
|
679
|
-
@lru_cache(maxsize=None)
|
680
668
|
def get_or_create_taxonomy_entry(self,
|
681
669
|
name: str,
|
682
670
|
key: str,
|
@@ -113,7 +113,7 @@ class ComponentList(SimultanObject):
|
|
113
113
|
|
114
114
|
try:
|
115
115
|
indices = sort_slots(slots)
|
116
|
-
return [self._object_mapper.create_python_object(x) for x in
|
116
|
+
return [self._object_mapper.create_python_object(x, data_model=self._data_model) for x in
|
117
117
|
[all_components[i] for i in np.argsort(indices)]]
|
118
118
|
except TypeError as e:
|
119
119
|
logger.warning(f'Could not sort list {all_components}:\n{e}')
|
@@ -259,7 +259,7 @@ class ComponentList(SimultanObject):
|
|
259
259
|
return f'List {self.name}: ' + repr(list(self.data))
|
260
260
|
|
261
261
|
def __iter__(self):
|
262
|
-
return iter([self._object_mapper.create_python_object(x) for x in self.data])
|
262
|
+
return iter([self._object_mapper.create_python_object(x, data_model=self._data_model) for x in self.data])
|
263
263
|
|
264
264
|
def __next__(self):
|
265
265
|
try:
|
@@ -18,7 +18,9 @@ from SIMULTAN.Data.Assets import ResourceEntry, ResourceFileEntry, ContainedReso
|
|
18
18
|
from SIMULTAN.Data.Taxonomy import SimTaxonomyEntry, SimTaxonomyEntryReference, SimTaxonomy
|
19
19
|
from SIMULTAN.Data.Components import SimComponent, ComponentMapping
|
20
20
|
|
21
|
-
from .config import default_data_model
|
21
|
+
# from .config import default_data_model
|
22
|
+
|
23
|
+
from . import config
|
22
24
|
|
23
25
|
from typing import TYPE_CHECKING
|
24
26
|
if TYPE_CHECKING:
|
@@ -195,7 +197,7 @@ class FileInfo(object, metaclass=MetaMock):
|
|
195
197
|
:return: FileInfo
|
196
198
|
"""
|
197
199
|
|
198
|
-
data_model = kwargs.get('data_model', default_data_model)
|
200
|
+
data_model = kwargs.get('data_model', config.default_data_model)
|
199
201
|
resource = create_asset_from_string(filename, content, *args, **kwargs)
|
200
202
|
|
201
203
|
file_info = cls(resource_entry=resource,
|
@@ -239,7 +241,8 @@ class FileInfo(object, metaclass=MetaMock):
|
|
239
241
|
def resource_entry(self) -> Union[ResourceFileEntry, ContainedResourceFileEntry, None]:
|
240
242
|
if self._resource_entry is None:
|
241
243
|
if self.data_model is None:
|
242
|
-
|
244
|
+
logger.warning(f'No data model provided. Using default data model: {config.default_data_model.id}.')
|
245
|
+
self.data_model = config.default_data_model
|
243
246
|
if self.data_model is not None:
|
244
247
|
self.resource_entry = self.data_model.add_resource(self.file_path)
|
245
248
|
return self._resource_entry
|
@@ -30,7 +30,7 @@ from SIMULTAN.Data.Geometry import VolumeAlgorithms
|
|
30
30
|
# from ..utils import create_mapped_python_object, create_python_object
|
31
31
|
# from ..files import create_asset_from_file, FileInfo, create_asset_from_string
|
32
32
|
from .. import config
|
33
|
-
from ..
|
33
|
+
from .. import logger
|
34
34
|
|
35
35
|
from typing import TYPE_CHECKING
|
36
36
|
if TYPE_CHECKING:
|
@@ -538,11 +538,12 @@ class GeometryModel(object, metaclass=MetaMock):
|
|
538
538
|
def create_simultan_instance(cls, *args, **kwargs):
|
539
539
|
|
540
540
|
data_model: DataModel = kwargs.get('data_model', config.default_data_model)
|
541
|
-
name = kwargs.get('name', 'GeometryModel')
|
541
|
+
name: str = kwargs.get('name', 'GeometryModel')
|
542
542
|
|
543
543
|
new_geo_model, resource = data_model.create_new_geometry_model(name=name)
|
544
544
|
data_model.project_data_manager.GeometryModels.AddGeometryModel(new_geo_model)
|
545
545
|
data_model.models_dict[resource.Key] = new_geo_model
|
546
|
+
data_model.save()
|
546
547
|
|
547
548
|
return new_geo_model
|
548
549
|
|
@@ -57,7 +57,7 @@ def create_cube(data_model,
|
|
57
57
|
scale: Optional[float] = 1):
|
58
58
|
|
59
59
|
if obj_mapper is None:
|
60
|
-
obj_mapper = config.
|
60
|
+
obj_mapper = config.get_default_mapper()
|
61
61
|
|
62
62
|
new_layer = obj_mapper.registered_geometry_classes[Layer](geometry_model=geo_model,
|
63
63
|
data_model=data_model,
|
@@ -136,15 +136,18 @@ class PythonMapper(object):
|
|
136
136
|
typed_data.append(typed_object)
|
137
137
|
return typed_data
|
138
138
|
|
139
|
-
# @lru_cache(maxsize=
|
139
|
+
# @lru_cache(maxsize=500)
|
140
140
|
def create_python_object(self, component, cls=None, data_model=None, *args, **kwargs):
|
141
141
|
|
142
142
|
if component is None:
|
143
143
|
return None
|
144
144
|
|
145
145
|
if data_model is None:
|
146
|
-
|
147
|
-
data_model =
|
146
|
+
logger.warning(f'No data model provided. Using default data model: {config.default_data_model.id}.')
|
147
|
+
data_model = config.default_data_model
|
148
|
+
data_model_id = data_model.id
|
149
|
+
# data_model_id = list(data_models)[0].id
|
150
|
+
# data_model = list(data_models)[0]
|
148
151
|
else:
|
149
152
|
data_model_id = data_model.id
|
150
153
|
|
@@ -201,6 +204,7 @@ class PythonMapper(object):
|
|
201
204
|
for prop in taxonomy_map.content:
|
202
205
|
|
203
206
|
prop_dict[prop.property_name] = add_properties(prop_name=prop.property_name,
|
207
|
+
text_or_key=prop.text_or_key,
|
204
208
|
content=prop,
|
205
209
|
taxonomy_map=taxonomy_map,
|
206
210
|
taxonomy=taxonomy)
|
@@ -213,6 +217,10 @@ class PythonMapper(object):
|
|
213
217
|
|
214
218
|
for cls in self.mapped_classes.values():
|
215
219
|
cls._cls_instances = WeakSet()
|
220
|
+
cls.__property_cache__ = {}
|
221
|
+
|
222
|
+
if config.default_mapper is self:
|
223
|
+
config.default_mapper = None
|
216
224
|
|
217
225
|
def copy(self):
|
218
226
|
new_mapper = PythonMapper()
|
@@ -222,5 +230,5 @@ class PythonMapper(object):
|
|
222
230
|
return new_mapper
|
223
231
|
|
224
232
|
|
225
|
-
if config.
|
226
|
-
config.
|
233
|
+
if config.get_default_mapper() is None:
|
234
|
+
config._default_mapper = PythonMapper()
|
@@ -6,7 +6,7 @@ from weakref import WeakSet, WeakValueDictionary
|
|
6
6
|
from . import utils
|
7
7
|
from numpy import ndarray
|
8
8
|
import colorlog
|
9
|
-
from typing import Union
|
9
|
+
from typing import Union, Optional
|
10
10
|
|
11
11
|
logger = colorlog.getLogger('PySimultan')
|
12
12
|
|
@@ -69,6 +69,8 @@ class MetaMock(type):
|
|
69
69
|
kwargs['data_model'] = data_model
|
70
70
|
else:
|
71
71
|
if config.default_data_model is not None:
|
72
|
+
logger.warning(
|
73
|
+
f'No data model provided. Using default data model: {config.default_data_model.id}.')
|
72
74
|
data_model = config.default_data_model
|
73
75
|
kwargs['data_model'] = data_model
|
74
76
|
else:
|
@@ -102,6 +104,11 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
102
104
|
_cls_instances_dict_cache = None
|
103
105
|
__type_view__ = None # ui view cls
|
104
106
|
|
107
|
+
@classmethod
|
108
|
+
def reset_cls(cls):
|
109
|
+
cls._cls_instances = WeakSet()
|
110
|
+
cls._cls_instances_dict_cache = None
|
111
|
+
|
105
112
|
@classmethod
|
106
113
|
def get_instance_by_id(cls, id: SimId) -> 'SimultanObject':
|
107
114
|
return cls._cls_instances_dict.get(id, None)
|
@@ -147,11 +154,12 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
147
154
|
|
148
155
|
self._wrapped_obj: Union[SimComponent, None] = kwargs.get('wrapped_obj', None)
|
149
156
|
self.__obj_init__ = kwargs.get('__obj_init__', False)
|
150
|
-
self._data_model_id = kwargs.get('data_model_id', None)
|
151
157
|
self._data_model: Union[DataModel, None] = kwargs.get('data_model', config.default_data_model)
|
152
158
|
self._object_mapper: Union[PythonMapper, None] = kwargs.get('object_mapper', config.default_mapper)
|
153
159
|
self.name = kwargs.get('name', None)
|
154
160
|
|
161
|
+
self.__property_cache__ = {}
|
162
|
+
|
155
163
|
self._slot = None
|
156
164
|
|
157
165
|
def __getattribute__(self, attr):
|
@@ -328,8 +336,16 @@ class SimultanObject(object, metaclass=MetaMock):
|
|
328
336
|
"""
|
329
337
|
other.associate(self)
|
330
338
|
|
331
|
-
def get_raw_attr(self, attr: str):
|
332
|
-
|
339
|
+
def get_raw_attr(self, attr: Optional[str] = None, text_or_key: Optional[str] = None):
|
340
|
+
if attr is not None:
|
341
|
+
content = self._taxonomy_map.get_content_by_property_name(attr)
|
342
|
+
if content is None:
|
343
|
+
raise KeyError(f'No content found for attribute {attr}')
|
344
|
+
|
345
|
+
return utils.get_component_taxonomy_entry(self._wrapped_obj, content.text_or_key)
|
346
|
+
|
347
|
+
if text_or_key is not None:
|
348
|
+
return utils.get_component_taxonomy_entry(self._wrapped_obj, text_or_key)
|
333
349
|
|
334
350
|
def set_attr_prop(self, attr: str, prop: str, value):
|
335
351
|
"""
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import io
|
2
|
+
from functools import cache
|
2
3
|
from ruamel.yaml import YAML, yaml_object, add_representer
|
3
|
-
from .
|
4
|
+
from . import yaml
|
4
5
|
|
5
6
|
from typing import TYPE_CHECKING, Optional, Union, Literal
|
6
7
|
if TYPE_CHECKING:
|
@@ -113,6 +114,9 @@ class TaxonomyMap(object):
|
|
113
114
|
content._taxonomy_map = self
|
114
115
|
self._content_dict = {}
|
115
116
|
|
117
|
+
self.get_content_by_property_name.cache_clear()
|
118
|
+
self.get_content_by_text_or_key.cache_clear()
|
119
|
+
|
116
120
|
@property
|
117
121
|
def content_dict(self):
|
118
122
|
if self._content_dict == {}:
|
@@ -167,3 +171,11 @@ class TaxonomyMap(object):
|
|
167
171
|
|
168
172
|
def get_slot(self, data_model: 'DataModel'):
|
169
173
|
return SimTaxonomyEntryReference(self.get_or_create_simultan_taxonomy_entry(data_model=data_model, create=True))
|
174
|
+
|
175
|
+
@cache
|
176
|
+
def get_content_by_property_name(self, property_name: str):
|
177
|
+
return next((x for x in self.content if x.property_name == property_name), None)
|
178
|
+
|
179
|
+
@cache
|
180
|
+
def get_content_by_text_or_key(self, text_or_key: str):
|
181
|
+
return next((x for x in self.content if x.text_or_key == text_or_key), None)
|