PySimultan 0.5.8__py3-none-any.whl → 0.5.9__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PySimultan2/__about__.py +1 -1
- PySimultan2/data_model.py +54 -0
- PySimultan2/files.py +18 -0
- {pysimultan-0.5.8.dist-info → pysimultan-0.5.9.dist-info}/METADATA +7 -3
- {pysimultan-0.5.8.dist-info → pysimultan-0.5.9.dist-info}/RECORD +7 -7
- {pysimultan-0.5.8.dist-info → pysimultan-0.5.9.dist-info}/WHEEL +1 -1
- {pysimultan-0.5.8.dist-info → pysimultan-0.5.9.dist-info}/licenses/LICENSE.txt +0 -0
PySimultan2/__about__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
version = '0.5.
|
1
|
+
version = '0.5.9'
|
PySimultan2/data_model.py
CHANGED
@@ -532,6 +532,60 @@ class DataModel:
|
|
532
532
|
)
|
533
533
|
)
|
534
534
|
|
535
|
+
def add_resource_file(self,
|
536
|
+
filename: Union[str, FileInfo, PythonFileInfo],
|
537
|
+
target_dir: Union[ResourceDirectoryEntry, FileInfo, str] = None) -> ResourceEntry:
|
538
|
+
|
539
|
+
"""
|
540
|
+
Add a file as resource to the project which already exists in the project folder
|
541
|
+
:param filename:
|
542
|
+
:param target_dir:
|
543
|
+
:return:
|
544
|
+
"""
|
545
|
+
|
546
|
+
if isinstance(filename, str):
|
547
|
+
filename = FileInfo(filename)
|
548
|
+
elif isinstance(filename, PythonFileInfo):
|
549
|
+
filename = FileInfo(filename.full_path)
|
550
|
+
|
551
|
+
if target_dir is None:
|
552
|
+
# check if file is already in project folder
|
553
|
+
if not os.path.exists(os.path.join(str(self.project.ProjectUnpackFolder), filename.Name)):
|
554
|
+
raise FileNotFoundError(f'File {filename} not found in project folder {self.project.ProjectUnpackFolder}')
|
555
|
+
|
556
|
+
self.project.AddResourceFile(FileInfo(str(filename)),
|
557
|
+
self.project_data_manager)
|
558
|
+
|
559
|
+
full_filename = os.path.join(str(self.project.ProjectUnpackFolder), filename.Name)
|
560
|
+
|
561
|
+
return next(
|
562
|
+
(
|
563
|
+
x for x in self.project_data_manager.AssetManager.Resources if x.CurrentFullPath == full_filename
|
564
|
+
)
|
565
|
+
, None
|
566
|
+
)
|
567
|
+
|
568
|
+
else:
|
569
|
+
if isinstance(target_dir, str):
|
570
|
+
target_dir = DirectoryInfo(target_dir)
|
571
|
+
elif isinstance(target_dir, ResourceDirectoryEntry):
|
572
|
+
target_dir = DirectoryInfo(target_dir.CurrentFullPath)
|
573
|
+
elif isinstance(target_dir, FileInfo):
|
574
|
+
pass
|
575
|
+
|
576
|
+
# check if file is already in project folder
|
577
|
+
if not os.path.exists(os.path.join(target_dir.FullPath, filename.Name)):
|
578
|
+
raise FileNotFoundError(f'File {filename} not found in project folder {target_dir.FullPath}')
|
579
|
+
|
580
|
+
self.project.AddResourceFile(
|
581
|
+
FileInfo(os.path.join(target_dir.FullPath, filename.Name)),
|
582
|
+
self.project_data_manager)
|
583
|
+
|
584
|
+
# get added resource
|
585
|
+
return next((x for x in self.project_data_manager.AssetManager.Resources if
|
586
|
+
x.CurrentFullPath == os.path.join(target_dir.FullPath, filename.Name)), None)
|
587
|
+
|
588
|
+
|
535
589
|
def add_resource(self,
|
536
590
|
filename: Union[str, FileInfo],
|
537
591
|
target_dir: Optional[Union[DirectoryInfo, ResourceDirectoryEntry, str]] = None,
|
PySimultan2/files.py
CHANGED
@@ -281,6 +281,21 @@ class FileInfo(object, metaclass=MetaMock):
|
|
281
281
|
file_info.write_content(content)
|
282
282
|
return file_info
|
283
283
|
|
284
|
+
@classmethod
|
285
|
+
def from_existing_file(cls,
|
286
|
+
file_path: str,
|
287
|
+
*args,
|
288
|
+
**kwargs) -> FileInfo:
|
289
|
+
|
290
|
+
data_model = kwargs.get('data_model', config.get_default_data_model())
|
291
|
+
resource = data_model.add_resource_file(file_path)
|
292
|
+
|
293
|
+
return cls(resource_entry=resource,
|
294
|
+
data_model=data_model,
|
295
|
+
*args,
|
296
|
+
**kwargs)
|
297
|
+
|
298
|
+
|
284
299
|
def __init__(self, file_path=None, *args, **kwargs):
|
285
300
|
"""
|
286
301
|
Custom file info object to be used with the with statement. This object is used to open a file and close it
|
@@ -475,7 +490,10 @@ class FileInfo(object, metaclass=MetaMock):
|
|
475
490
|
:return: None
|
476
491
|
"""
|
477
492
|
if self.resource_entry is not None:
|
493
|
+
if self.resource_entry.Key in self._cls_instances:
|
494
|
+
del self._cls_instances[self.resource_entry.Key]
|
478
495
|
self.data_model.delete_resource(self.resource_entry)
|
496
|
+
|
479
497
|
os.remove(self.file_path)
|
480
498
|
|
481
499
|
def to_json(self) -> dict:
|
@@ -1,11 +1,12 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: PySimultan
|
3
|
-
Version: 0.5.
|
3
|
+
Version: 0.5.9
|
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
|
7
7
|
Author-email: Bühler Maximilian <maximilian.buehler@tuwien.ac.at>
|
8
|
-
License: MIT
|
8
|
+
License-Expression: MIT
|
9
|
+
License-File: LICENSE.txt
|
9
10
|
Classifier: Development Status :: 4 - Beta
|
10
11
|
Classifier: Programming Language :: Python
|
11
12
|
Classifier: Programming Language :: Python :: 3.8
|
@@ -166,6 +167,9 @@ print(instances[0].param_1)
|
|
166
167
|
|
167
168
|
# Change Log
|
168
169
|
|
170
|
+
## [0.5.8] - 2024-12-17
|
171
|
+
- Added FileInfo.from_existing_file method to create FileInfo object from existing file in ProjectUnpackFolder
|
172
|
+
|
169
173
|
## [0.5.7] - 2024-12-09
|
170
174
|
- Added support for different taxonomy for content
|
171
175
|
- Added support for numpy np.float32, np.float64 and np.int32, np.int64
|
@@ -1,9 +1,9 @@
|
|
1
1
|
PySimultan2/CHANGELOG.md,sha256=BBfCqgFQeigrlRQdHAksDz70-0fLKjzWkHbfFjJ2eDg,361
|
2
|
-
PySimultan2/__about__.py,sha256=
|
2
|
+
PySimultan2/__about__.py,sha256=qqSUxPPY_oV00hMzjB1sl4cBwwVOu75QAU3g1azPtlc,19
|
3
3
|
PySimultan2/__init__.py,sha256=PGVR1uhY01dF5tHyad-znURUZ_LVB95vsjId2BT0aJM,3245
|
4
|
-
PySimultan2/data_model.py,sha256=
|
4
|
+
PySimultan2/data_model.py,sha256=7rf1IT6jLKkCkpH9Zmkdy-wpPQXwt7wWl_RFw4sl2Co,36503
|
5
5
|
PySimultan2/default_types.py,sha256=K-Eka5BCKk8DT3HU5761Ym_-ZFmu1_Dro0zW0LVGoHA,27157
|
6
|
-
PySimultan2/files.py,sha256=
|
6
|
+
PySimultan2/files.py,sha256=jvjGB_yLvJbXBhtxy7-l9nTK4voRiuimr-w8Cq7XtI0,23053
|
7
7
|
PySimultan2/multi_values.py,sha256=ZFXlTLuZo32x7_7diYAp2XEjp5uwgHLgNOzN7v74-5I,13650
|
8
8
|
PySimultan2/object_mapper.py,sha256=_SQye38NmIr4m_-X9CuvUJnVDBmjmUDdPH2bnaxpzKY,18546
|
9
9
|
PySimultan2/simultan_object.py,sha256=akaSUZZWIVfwx1wT5EdOgRR2UeShUthX-LE2Uk6w8CQ,19058
|
@@ -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.9.dist-info/METADATA,sha256=WyBbt76L0Bt4PjMpNYG_baQKQzFZtNBZqu5e2_iKpdc,6136
|
79
|
+
pysimultan-0.5.9.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
80
|
+
pysimultan-0.5.9.dist-info/licenses/LICENSE.txt,sha256=pmSr98k6N005KMojnZxzLGRuRlDjDx3PUrK1lFj53HA,1126
|
81
|
+
pysimultan-0.5.9.dist-info/RECORD,,
|
File without changes
|