PySimultan 0.5.2.5__py3-none-any.whl → 0.5.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PySimultan2/CHANGELOG.md +3 -0
- PySimultan2/__about__.py +1 -1
- PySimultan2/data_model.py +49 -7
- PySimultan2/files.py +55 -7
- PySimultan2/object_mapper.py +0 -1
- PySimultan2/utils.py +9 -0
- {pysimultan-0.5.2.5.dist-info → pysimultan-0.5.3.dist-info}/METADATA +1 -1
- {pysimultan-0.5.2.5.dist-info → pysimultan-0.5.3.dist-info}/RECORD +10 -10
- {pysimultan-0.5.2.5.dist-info → pysimultan-0.5.3.dist-info}/WHEEL +0 -0
- {pysimultan-0.5.2.5.dist-info → pysimultan-0.5.3.dist-info}/licenses/LICENSE.txt +0 -0
PySimultan2/CHANGELOG.md
CHANGED
PySimultan2/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = '0.5.
|
1
|
+
version = '0.5.3'
|
PySimultan2/data_model.py
CHANGED
@@ -23,7 +23,7 @@ from SIMULTAN.Serializer.SimGeo import *
|
|
23
23
|
from SIMULTAN.Serializer.Projects import *
|
24
24
|
from SIMULTAN.Data.Components import SimComponent, SimComponentCollection
|
25
25
|
from SIMULTAN.Data.MultiValues import SimMultiValueBigTable, SimMultiValueField3D
|
26
|
-
from SIMULTAN.Data.Assets import ResourceEntry
|
26
|
+
from SIMULTAN.Data.Assets import ResourceEntry, ResourceDirectoryEntry, ResourceFileEntry, ContainedResourceFileEntry
|
27
27
|
from SIMULTAN.Data.Geometry import OffsetAlgorithm
|
28
28
|
# from GeometryViewer.Service import *
|
29
29
|
# from SIMULTAN.UI.Services import *
|
@@ -37,6 +37,7 @@ from SIMULTAN.Data.Geometry import Layer, Vertex, Edge, PEdge, Face, Volume, Edg
|
|
37
37
|
from System.Security import SecureString
|
38
38
|
from SIMULTAN.Data import SimId
|
39
39
|
from System import Guid
|
40
|
+
from System.IO import DirectoryInfo
|
40
41
|
from System.IO import *
|
41
42
|
from System.Security import *
|
42
43
|
from System.Security.Cryptography import *
|
@@ -500,19 +501,35 @@ class DataModel:
|
|
500
501
|
self.get_file_infos.cache_clear()
|
501
502
|
return new_resource
|
502
503
|
|
503
|
-
def add_empty_resource(self,
|
504
|
+
def add_empty_resource(self,
|
505
|
+
filename: str,
|
506
|
+
target_dir: Union[ResourceDirectoryEntry, DirectoryInfo, str] = None) -> ResourceEntry:
|
504
507
|
"""
|
505
508
|
Add an empty resource to the project
|
506
|
-
:param
|
509
|
+
:param filename: name of the new resource
|
510
|
+
:param target_dir: directory to add the resource
|
507
511
|
:return:
|
508
512
|
"""
|
509
513
|
# return self.project.AddResourceFile(FileInfo(str(filename)))
|
510
514
|
|
511
515
|
self.get_file_infos.cache_clear()
|
512
|
-
|
516
|
+
if target_dir is None:
|
517
|
+
return self.project.AddEmptyResource(FileInfo(str(filename)))
|
518
|
+
else:
|
519
|
+
|
520
|
+
if isinstance(target_dir, ResourceDirectoryEntry):
|
521
|
+
target_dir = target_dir.CurrentFullPath
|
522
|
+
if isinstance(target_dir, DirectoryInfo):
|
523
|
+
target_dir = target_dir.FullPath
|
524
|
+
|
525
|
+
return self.project.AddEmptyResource(FileInfo(
|
526
|
+
os.path.join(target_dir, str(filename))
|
527
|
+
)
|
528
|
+
)
|
513
529
|
|
514
530
|
def add_resource(self,
|
515
531
|
filename: Union[str, FileInfo],
|
532
|
+
target_dir: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
516
533
|
tag: Union[SimTaxonomyEntry, SimTaxonomyEntryReference] = None) -> ResourceEntry:
|
517
534
|
"""
|
518
535
|
Add a new resource to the project. The resource will be copied to the project folder and added to the project
|
@@ -545,9 +562,21 @@ class DataModel:
|
|
545
562
|
if isinstance(filename, (str, PosixPath, WindowsPath)):
|
546
563
|
filename = FileInfo(str(filename))
|
547
564
|
|
548
|
-
|
549
|
-
|
550
|
-
|
565
|
+
if target_dir is None:
|
566
|
+
resource = self.project.CopyResourceAsContainedFileEntry(filename,
|
567
|
+
self.project.ProjectUnpackFolder,
|
568
|
+
'1')
|
569
|
+
else:
|
570
|
+
if isinstance(target_dir, str):
|
571
|
+
target_dir = DirectoryInfo(target_dir)
|
572
|
+
elif isinstance(target_dir, ResourceDirectoryEntry):
|
573
|
+
target_dir = DirectoryInfo(target_dir.CurrentFullPath)
|
574
|
+
elif isinstance(target_dir, DirectoryInfo):
|
575
|
+
pass
|
576
|
+
|
577
|
+
resource = self.project.CopyResourceAsContainedFileEntry(filename,
|
578
|
+
target_dir,
|
579
|
+
'1')
|
551
580
|
|
552
581
|
if del_copy:
|
553
582
|
os.remove(str(filename))
|
@@ -583,6 +612,19 @@ class DataModel:
|
|
583
612
|
self.get_file_infos.cache_clear()
|
584
613
|
return success
|
585
614
|
|
615
|
+
def create_resource_directory(self,
|
616
|
+
name: str,
|
617
|
+
parent_directory: DirectoryInfo=None,
|
618
|
+
collision_name_format: str = '{0} ({1})') -> ResourceEntry:
|
619
|
+
|
620
|
+
if parent_directory is None:
|
621
|
+
new_directory = self.project.CreateResourceDirIn(name, None, collision_name_format)
|
622
|
+
else:
|
623
|
+
new_directory = self.project.CreateResourceDirIn(name, parent_directory, collision_name_format)
|
624
|
+
|
625
|
+
return new_directory
|
626
|
+
|
627
|
+
|
586
628
|
def add_table(self, table: SimMultiValueBigTable):
|
587
629
|
self.project_data_manager.ValueManager.Add(table)
|
588
630
|
|
PySimultan2/files.py
CHANGED
@@ -14,10 +14,12 @@ import shutil
|
|
14
14
|
import zipfile
|
15
15
|
# from System.IO import FileInfo # public FileInfo (string fileName);
|
16
16
|
|
17
|
-
from SIMULTAN.Data.Assets import ResourceEntry, ResourceFileEntry, ContainedResourceFileEntry, Asset
|
17
|
+
from SIMULTAN.Data.Assets import ResourceEntry, ResourceFileEntry, ContainedResourceFileEntry, Asset, ResourceDirectoryEntry
|
18
18
|
from SIMULTAN.Data.Taxonomy import SimTaxonomyEntry, SimTaxonomyEntryReference, SimTaxonomy
|
19
19
|
from SIMULTAN.Data.Components import SimComponent, ComponentMapping
|
20
20
|
|
21
|
+
from System.IO import DirectoryInfo
|
22
|
+
|
21
23
|
# from .config import default_data_model
|
22
24
|
|
23
25
|
from . import config, logger
|
@@ -50,7 +52,7 @@ def tempdir():
|
|
50
52
|
yield dir_path
|
51
53
|
|
52
54
|
|
53
|
-
def add_tag_to_resource(resource: Union[ResourceFileEntry, ContainedResourceFileEntry],
|
55
|
+
def add_tag_to_resource(resource: Union[ResourceFileEntry, ContainedResourceFileEntry, ResourceDirectoryEntry],
|
54
56
|
tag: Union[SimTaxonomyEntry, SimTaxonomyEntryReference]):
|
55
57
|
"""
|
56
58
|
Add a tag to an asset.
|
@@ -109,12 +111,14 @@ def remove_asset_from_component(comp: Union[SimComponent, SimultanObject],
|
|
109
111
|
def create_asset_from_string(filename: str,
|
110
112
|
content: str,
|
111
113
|
data_model: DataModel,
|
114
|
+
target_dir: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
112
115
|
tag: Optional[Union[SimTaxonomyEntry, SimTaxonomyEntryReference]] = None) -> ResourceFileEntry:
|
113
116
|
"""
|
114
117
|
Create a new asset from a string. The asset is added to the data model.
|
115
118
|
:param filename: Name of the file to be created. E.g. 'new_file.txt'
|
116
119
|
:param content: Content of the file. E.g. 'This is the content of the file.'
|
117
120
|
:param data_model: Data model to add the asset to.
|
121
|
+
:param target_dir: Target directory to add the asset to.
|
118
122
|
:param tag: Tag to be added to the asset.
|
119
123
|
:return: ResourceFileEntry
|
120
124
|
"""
|
@@ -123,10 +127,12 @@ def create_asset_from_string(filename: str,
|
|
123
127
|
with open(filepath, 'w') as f:
|
124
128
|
f.write(content)
|
125
129
|
|
126
|
-
resource = data_model.add_resource(filepath
|
130
|
+
resource = data_model.add_resource(filepath,
|
131
|
+
target_dir=target_dir)
|
127
132
|
|
128
133
|
if tag is not None:
|
129
|
-
add_tag_to_resource(resource,
|
134
|
+
add_tag_to_resource(resource,
|
135
|
+
tag)
|
130
136
|
|
131
137
|
return resource
|
132
138
|
|
@@ -134,12 +140,14 @@ def create_asset_from_string(filename: str,
|
|
134
140
|
def create_asset_from_str_io(filename: str,
|
135
141
|
content: io.StringIO,
|
136
142
|
data_model: DataModel,
|
143
|
+
target_dir: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
137
144
|
tag: Union[SimTaxonomyEntry, SimTaxonomyEntryReference] = None) -> ResourceFileEntry:
|
138
145
|
"""
|
139
146
|
Create a new asset from a string io. The asset is added to the data model.
|
140
147
|
:param filename: Name of the file to be created. E.g. 'new_file.txt'
|
141
148
|
:param content: Content of the file. E.g. 'This is the content of the file.'
|
142
149
|
:param data_model: Data model to add the asset to.
|
150
|
+
:param target_dir: Target directory to add the asset to.
|
143
151
|
:param tag: Tag to be added to the asset.
|
144
152
|
:return: ResourceFileEntry
|
145
153
|
"""
|
@@ -148,7 +156,8 @@ def create_asset_from_str_io(filename: str,
|
|
148
156
|
with open(filepath, 'w') as f:
|
149
157
|
f.write(content.getvalue())
|
150
158
|
|
151
|
-
resource = data_model.add_resource(filepath
|
159
|
+
resource = data_model.add_resource(filepath,
|
160
|
+
target_dir=target_dir)
|
152
161
|
|
153
162
|
if tag is not None:
|
154
163
|
add_tag_to_resource(resource, tag)
|
@@ -175,6 +184,32 @@ def create_asset_from_file(file_info: FileInfo,
|
|
175
184
|
return resource
|
176
185
|
|
177
186
|
|
187
|
+
def add_directory(data_model: DataModel,
|
188
|
+
directory: str,
|
189
|
+
parent_directory: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
190
|
+
tag: Union[SimTaxonomyEntry, SimTaxonomyEntryReference] = None) -> ResourceDirectoryEntry:
|
191
|
+
|
192
|
+
"""
|
193
|
+
Add a directory to the data model.
|
194
|
+
:param data_model:
|
195
|
+
:param target_dir:
|
196
|
+
:param tag:
|
197
|
+
:return:
|
198
|
+
"""
|
199
|
+
|
200
|
+
# create the directory
|
201
|
+
resource_directory_entry = data_model.create_resource_directory(parent_directory=parent_directory)
|
202
|
+
|
203
|
+
for filename in os.listdir(directory):
|
204
|
+
file_path = os.path.join(directory, filename)
|
205
|
+
resource = data_model.add_resource(file_path)
|
206
|
+
if tag is not None:
|
207
|
+
add_tag_to_resource(resource, tag)
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
178
213
|
class MetaMock(type):
|
179
214
|
def __call__(cls, *args, **kwargs):
|
180
215
|
resource_entry = kwargs.get('resource_entry', None)
|
@@ -197,18 +232,27 @@ class FileInfo(object, metaclass=MetaMock):
|
|
197
232
|
@classmethod
|
198
233
|
def from_string(cls,
|
199
234
|
filename: str,
|
200
|
-
content: str,
|
235
|
+
content: str,
|
236
|
+
target_dir: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
237
|
+
*args,
|
238
|
+
**kwargs,
|
239
|
+
) -> FileInfo:
|
201
240
|
"""
|
202
241
|
Create a file info object from a string.
|
203
242
|
:param filename: Name of the file to be created. E.g. 'new_file.txt'
|
204
243
|
:param content: Content of the file. E.g. 'This is the content of the file.'
|
244
|
+
:param target_dir: Target directory to add the asset to.
|
205
245
|
:param args:
|
206
246
|
:param kwargs:
|
207
247
|
:return: FileInfo
|
208
248
|
"""
|
209
249
|
|
210
250
|
data_model = kwargs.get('data_model', config.get_default_data_model())
|
211
|
-
resource = create_asset_from_string(filename,
|
251
|
+
resource = create_asset_from_string(filename,
|
252
|
+
content,
|
253
|
+
target_dir=target_dir,
|
254
|
+
*args,
|
255
|
+
**kwargs)
|
212
256
|
|
213
257
|
file_info = cls(resource_entry=resource,
|
214
258
|
data_model=data_model)
|
@@ -247,6 +291,10 @@ class FileInfo(object, metaclass=MetaMock):
|
|
247
291
|
self.args = args
|
248
292
|
self.kwargs = kwargs
|
249
293
|
|
294
|
+
@property
|
295
|
+
def parent(self):
|
296
|
+
return self.resource_entry.Parent
|
297
|
+
|
250
298
|
@property
|
251
299
|
def key(self) -> int:
|
252
300
|
try:
|
PySimultan2/object_mapper.py
CHANGED
@@ -140,7 +140,6 @@ class PythonMapper(object):
|
|
140
140
|
mapper.registered_classes)
|
141
141
|
)[0]
|
142
142
|
mapper.registered_classes[key] = cls
|
143
|
-
print(f'Updated {cls} in {mapper.module} with {taxonomy}')
|
144
143
|
|
145
144
|
def update_from_submodules(self):
|
146
145
|
for submodule in self.submodules.values():
|
PySimultan2/utils.py
CHANGED
@@ -373,18 +373,27 @@ def create_parameter(value: Union[int, float, str, SimTaxonomyEntry] = 0,
|
|
373
373
|
raise ValueError(f'Parameter type {type(value)} not supported.')
|
374
374
|
|
375
375
|
if parameter_type == float:
|
376
|
+
if isinstance(value, (str, int)):
|
377
|
+
value = float(value)
|
378
|
+
|
376
379
|
return create_sim_double_parameter(name=name,
|
377
380
|
value=value,
|
378
381
|
slot=taxonomy_entry,
|
379
382
|
unit=kwargs.pop('unit', ''),
|
380
383
|
**kwargs)
|
381
384
|
elif parameter_type == int:
|
385
|
+
if isinstance(value, (str, float)):
|
386
|
+
value = int(value)
|
387
|
+
|
382
388
|
return create_sim_integer_parameter(name=name,
|
383
389
|
value=value,
|
384
390
|
slot=taxonomy_entry,
|
385
391
|
unit=kwargs.pop('unit', ''),
|
386
392
|
**kwargs)
|
387
393
|
elif parameter_type == str:
|
394
|
+
if isinstance(value, (int, float)):
|
395
|
+
value = str(value)
|
396
|
+
|
388
397
|
return create_sim_string_parameter(name=name,
|
389
398
|
value=value,
|
390
399
|
slot=taxonomy_entry,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: PySimultan
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.3
|
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
|
@@ -1,15 +1,15 @@
|
|
1
|
-
PySimultan2/CHANGELOG.md,sha256=
|
2
|
-
PySimultan2/__about__.py,sha256=
|
1
|
+
PySimultan2/CHANGELOG.md,sha256=LeVHBC6dGDwDwgXipNrwgvgews9QkyjsqtYa_jiLMm0,217
|
2
|
+
PySimultan2/__about__.py,sha256=lhcqEYOdmvV5zQ4d-IvOu1pQl5tG1hLWIoyYZuVEboM,19
|
3
3
|
PySimultan2/__init__.py,sha256=PGVR1uhY01dF5tHyad-znURUZ_LVB95vsjId2BT0aJM,3245
|
4
|
-
PySimultan2/data_model.py,sha256=
|
4
|
+
PySimultan2/data_model.py,sha256=V6myRSzIQMjJVCjHwNSIWu6FdBsUKdfGxHuLkEsrgi0,33864
|
5
5
|
PySimultan2/default_types.py,sha256=K-Eka5BCKk8DT3HU5761Ym_-ZFmu1_Dro0zW0LVGoHA,27157
|
6
|
-
PySimultan2/files.py,sha256=
|
6
|
+
PySimultan2/files.py,sha256=UWSI04x9ANpFbYbqTHo_UwSnBzVjuNDK_MlmIh1S_bY,15988
|
7
7
|
PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
|
8
|
-
PySimultan2/object_mapper.py,sha256=
|
8
|
+
PySimultan2/object_mapper.py,sha256=_SQye38NmIr4m_-X9CuvUJnVDBmjmUDdPH2bnaxpzKY,18546
|
9
9
|
PySimultan2/simultan_object.py,sha256=akaSUZZWIVfwx1wT5EdOgRR2UeShUthX-LE2Uk6w8CQ,19058
|
10
10
|
PySimultan2/taxonomy_maps.py,sha256=abMB2RSKEaliW-Ewegq-Inq9npHeOD1VVrMYoKJAlC0,8762
|
11
11
|
PySimultan2/type_setter_lookup.py,sha256=WtopIR2Z3v3wNFtqmeVorH7ZUbKoJYTTe5I3vfQuKUI,3404
|
12
|
-
PySimultan2/utils.py,sha256=
|
12
|
+
PySimultan2/utils.py,sha256=R1W3F0gkmYgrb6Lhsa_-7C8tNSoxGhQM-cCdxhgRmLc,64042
|
13
13
|
PySimultan2/geometry/__init__.py,sha256=nJolTD1i5J8qUkOQa-r3D20aq3Co3sN31Xc0n4wJpJo,248
|
14
14
|
PySimultan2/geometry/geometry_base.py,sha256=nbb9U2W3vFviVLxISLHRi2CVyLEM-3zIKvoZ1uSYs_8,23420
|
15
15
|
PySimultan2/geometry/utils.py,sha256=J25YsK8sso_UL7xRusItQZvyjtvxdOsSPelBQYFABhY,8519
|
@@ -75,7 +75,7 @@ PySimultan2/resources/assimp.dll,sha256=HwfDwXqoPDTFRyoQpA3qmgZoUdFtziJkV5fNtktE
|
|
75
75
|
PySimultan2/resources/componentmanager.user,sha256=hrzr1US4pqkFnLHXcvPkvrgGd7QvlxaV8mhS6fuikEs,760
|
76
76
|
PySimultan2/resources/defaultsettings.xml,sha256=s6Tk1tubLz5UYqXZWpD42EDHzedemRY1nEneoIVcUfg,392
|
77
77
|
PySimultan2/resources/setup.bat,sha256=fjvvYfVM6TalS-QTSiKAbAId5nTsk8kGGo06ba-wWaY,32
|
78
|
-
pysimultan-0.5.
|
79
|
-
pysimultan-0.5.
|
80
|
-
pysimultan-0.5.
|
81
|
-
pysimultan-0.5.
|
78
|
+
pysimultan-0.5.3.dist-info/METADATA,sha256=uHZ4LgdGra5hED0t2NNP_UuEdLHOiol5fZjrRQaAAn4,2665
|
79
|
+
pysimultan-0.5.3.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
|
80
|
+
pysimultan-0.5.3.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
|
81
|
+
pysimultan-0.5.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|