PySimultan 0.5.2.5__tar.gz → 0.5.3__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/PKG-INFO +1 -1
  2. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/CHANGELOG.md +3 -0
  3. pysimultan-0.5.3/src/PySimultan2/__about__.py +1 -0
  4. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/data_model.py +49 -7
  5. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/files.py +55 -7
  6. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/object_mapper.py +0 -1
  7. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/utils.py +9 -0
  8. pysimultan-0.5.3/tests/test_directory_and_files.py +44 -0
  9. pysimultan-0.5.3/tests/test_empty_file.txt +0 -0
  10. pysimultan-0.5.2.5/src/PySimultan2/__about__.py +0 -1
  11. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/.gitignore +0 -0
  12. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/LICENSE.txt +0 -0
  13. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/README.md +0 -0
  14. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/pyproject.toml +0 -0
  15. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/__init__.py +0 -0
  16. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/default_types.py +0 -0
  17. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/geometry/__init__.py +0 -0
  18. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/geometry/geometry_base.py +0 -0
  19. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/geometry/utils.py +0 -0
  20. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/multi_values.py +0 -0
  21. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/AssimpNet.dll +0 -0
  22. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/AvalonDock.dll +0 -0
  23. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/BruTile.dll +0 -0
  24. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ClosedXML.dll +0 -0
  25. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ComponentBuilder.dll +0 -0
  26. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ComponentBuilder.dll.config +0 -0
  27. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ComponentBuilder.runtimeconfig.json +0 -0
  28. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ComponentBuilder.xml +0 -0
  29. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ControlzEx.dll +0 -0
  30. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  31. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
  32. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/DotSpatial.Projections.dll +0 -0
  33. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/ExcelNumberFormat.dll +0 -0
  34. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Fluent.dll +0 -0
  35. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
  36. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
  37. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
  38. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/HelixToolkit.dll +0 -0
  39. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/MathNet.Numerics.dll +0 -0
  40. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
  41. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
  42. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  43. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  44. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
  45. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
  46. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  47. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  48. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
  49. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
  50. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Newtonsoft.Json.dll +0 -0
  51. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  52. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
  53. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  54. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +0 -0
  55. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  56. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.Lang.xml +0 -0
  57. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  58. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.Plugins.xml +0 -0
  59. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  60. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.UI.xml +0 -0
  61. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.dll +0 -0
  62. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SIMULTAN.xml +0 -0
  63. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
  64. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.DXGI.dll +0 -0
  65. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
  66. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
  67. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
  68. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.Mathematics.dll +0 -0
  69. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/SharpDX.dll +0 -0
  70. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Sprache.Calc.dll +0 -0
  71. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/Sprache.dll +0 -0
  72. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/System.Collections.Immutable.dll +0 -0
  73. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/System.Data.OleDb.dll +0 -0
  74. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
  75. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/System.Reflection.Metadata.dll +0 -0
  76. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/System.Reflection.MetadataLoadContext.dll +0 -0
  77. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
  78. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/__init__.py +0 -0
  79. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/assimp.dll +0 -0
  80. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/componentmanager.user +0 -0
  81. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/defaultsettings.xml +0 -0
  82. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/resources/setup.bat +0 -0
  83. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/simultan_object.py +0 -0
  84. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/taxonomy_maps.py +0 -0
  85. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/src/PySimultan2/type_setter_lookup.py +0 -0
  86. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/__init__.py +0 -0
  87. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/__init__.py +0 -0
  88. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/create_component.py +0 -0
  89. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/create_component_with_taxonomy_slot.py +0 -0
  90. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/create_referenced_component.py +0 -0
  91. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/create_taxonomies.py +0 -0
  92. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/__init__.py +0 -0
  93. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/change_references_example.simultan +0 -0
  94. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/empty_project.simultan +0 -0
  95. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/empty_test_excel.xlsx +0 -0
  96. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/example1.simultan +0 -0
  97. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/example2.simultan +0 -0
  98. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/example3.simultan +0 -0
  99. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/example4_reference_list.simultan +0 -0
  100. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/example_extend_1.simultan +0 -0
  101. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/list_test.simultan +0 -0
  102. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example3.yml +0 -0
  103. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example4.yml +0 -0
  104. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example_create_typed_component.yml +0 -0
  105. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example_create_typed_component_with_slots.yml +0 -0
  106. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example_extend.yml +0 -0
  107. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_example_update_references.yml +0 -0
  108. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/readme_examples/resources/template_reference_list.yml +0 -0
  109. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/U5.simultan +0 -0
  110. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/U5_1.simultan +0 -0
  111. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/U5_orig.simultan +0 -0
  112. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/__init__.py +0 -0
  113. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/new_geometry_test.simultan +0 -0
  114. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/new_test_file.txt +0 -0
  115. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/new_test_file2.txt +0 -0
  116. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_file.yml +0 -0
  117. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_file_load.simultan +0 -0
  118. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_file_project.simultan +0 -0
  119. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_multi_value_big_table_load.simultan +0 -0
  120. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_parameter_reference_project.simultan +0 -0
  121. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/resources/test_set_dictionary.simultan +0 -0
  122. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_calc_static_zone_temperature.py +0 -0
  123. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_calculate_steady_state_temperature.py +0 -0
  124. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_circular_references.py +0 -0
  125. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_create_geometry.py +0 -0
  126. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_files.py +0 -0
  127. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_files_load.py +0 -0
  128. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_load_geometry.py +0 -0
  129. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_load_multi_values.py +0 -0
  130. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_new_dll.py +0 -0
  131. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_new_project_creation.py +0 -0
  132. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_numeric_map.py +0 -0
  133. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_parameter_reference.py +0 -0
  134. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_pythonnet.py +0 -0
  135. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_register_class.py +0 -0
  136. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_register_decorator.py +0 -0
  137. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_set_attr_property.py +0 -0
  138. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_set_dictionary.py +0 -0
  139. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_set_properties.py +0 -0
  140. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_taxonomie_maps.py +0 -0
  141. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_taxonomies.py +0 -0
  142. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/test_ui.py +0 -0
  143. {pysimultan-0.5.2.5 → pysimultan-0.5.3}/tests/ui_minimal_example.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PySimultan
3
- Version: 0.5.2.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,3 +1,6 @@
1
+ Version 0.5.3 (01.12.2024)
2
+ - Added support for directories (Assets and FileInfo)
3
+
1
4
  Version 0.5.1 (25.11.2024)
2
5
 
3
6
  - setting re-register default in Mapper to True
@@ -0,0 +1 @@
1
+ version = '0.5.3'
@@ -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, filename: str):
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 file_name: name of the new resource
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
- return self.project.AddEmptyResource(FileInfo(str(filename)))
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
- resource = self.project.CopyResourceAsContainedFileEntry(filename,
549
- self.project.ProjectUnpackFolder,
550
- '1')
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
 
@@ -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, tag)
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, *args, **kwargs) -> FileInfo:
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, content, *args, **kwargs)
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:
@@ -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():
@@ -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,
@@ -0,0 +1,44 @@
1
+ import os
2
+ from PySimultan2.src.PySimultan2 import DataModel
3
+ from PySimultan2.src.PySimultan2.files import FileInfo
4
+
5
+
6
+ project_dir = os.environ.get('PROJECT_DIR', '/simultan_projects')
7
+ if not os.path.exists(project_dir):
8
+ os.makedirs(project_dir)
9
+
10
+ new_data_model = DataModel.create_new_project(project_path=os.path.join(project_dir, 'test_dir_files.simultan'),
11
+ user_name='admin',
12
+ password='admin')
13
+
14
+
15
+ new_directory = new_data_model.create_resource_directory('test_dir')
16
+ new_directory2 = new_data_model.create_resource_directory('test_dir2')
17
+ new_directory4 = new_data_model.create_resource_directory('test_dir3')
18
+
19
+ new_data_model.add_empty_resource(filename=os.path.join(new_directory.CurrentFullPath, 'test_empty_file.txt'))
20
+
21
+ new_data_model.add_empty_resource(filename='test_empty_file2.txt',
22
+ target_dir=new_directory)
23
+
24
+ new_file_info0 = FileInfo.from_string(filename='test_file.txt',
25
+ content='This is a test file',
26
+ data_model=new_data_model)
27
+
28
+ new_file_info = FileInfo.from_string(filename='test_file.txt',
29
+ content='This is a test file',
30
+ target_dir=new_directory,
31
+ data_model=new_data_model)
32
+
33
+ new_file_info2 = FileInfo.from_string(filename='test_file2.txt',
34
+ content='This is a test file 2',
35
+ target_dir=new_directory2.current_full_path,
36
+ data_model=new_data_model)
37
+
38
+ # create just a file in the directory
39
+ with open(os.path.join(new_directory2.current_full_path, 'not_contained_test_file3.txt'), 'w') as f:
40
+ f.write('This is a test file 3')
41
+
42
+
43
+ new_data_model.save()
44
+ new_data_model.cleanup()
File without changes
@@ -1 +0,0 @@
1
- version = '0.5.2.5'
File without changes
File without changes
File without changes
File without changes