PySimultan 0.5.9.5__tar.gz → 0.5.9.7__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) hide show
  1. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/PKG-INFO +5 -1
  2. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/README.md +4 -0
  3. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/CHANGELOG.md +5 -0
  4. pysimultan-0.5.9.7/src/PySimultan2/__about__.py +1 -0
  5. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/data_model.py +39 -6
  6. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/default_types.py +11 -3
  7. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/object_mapper.py +29 -3
  8. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/taxonomy_maps.py +45 -27
  9. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/utils.py +1 -1
  10. pysimultan-0.5.9.7/tests/test_default_component.py +105 -0
  11. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_register_class.py +1 -45
  12. pysimultan-0.5.9.5/src/PySimultan2/__about__.py +0 -1
  13. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/.gitignore +0 -0
  14. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/LICENSE.txt +0 -0
  15. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/pyproject.toml +0 -0
  16. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/__init__.py +0 -0
  17. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/files.py +0 -0
  18. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/geometry/__init__.py +0 -0
  19. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/geometry/geometry_base.py +0 -0
  20. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/geometry/utils.py +0 -0
  21. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/multi_values.py +0 -0
  22. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/AssimpNet.dll +0 -0
  23. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/AvalonDock.dll +0 -0
  24. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/BruTile.dll +0 -0
  25. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ClosedXML.dll +0 -0
  26. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ComponentBuilder.dll +0 -0
  27. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ComponentBuilder.dll.config +0 -0
  28. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ComponentBuilder.runtimeconfig.json +0 -0
  29. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ComponentBuilder.xml +0 -0
  30. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ControlzEx.dll +0 -0
  31. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  32. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
  33. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/DotSpatial.Projections.dll +0 -0
  34. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/ExcelNumberFormat.dll +0 -0
  35. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Fluent.dll +0 -0
  36. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
  37. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
  38. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
  39. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/HelixToolkit.dll +0 -0
  40. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/MathNet.Numerics.dll +0 -0
  41. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
  42. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
  43. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  44. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  45. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
  46. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
  47. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  48. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  49. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
  50. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
  51. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Newtonsoft.Json.dll +0 -0
  52. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  53. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
  54. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  55. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +0 -0
  56. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  57. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.Lang.xml +0 -0
  58. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  59. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.Plugins.xml +0 -0
  60. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  61. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.UI.xml +0 -0
  62. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.dll +0 -0
  63. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SIMULTAN.xml +0 -0
  64. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
  65. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.DXGI.dll +0 -0
  66. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
  67. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
  68. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
  69. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.Mathematics.dll +0 -0
  70. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/SharpDX.dll +0 -0
  71. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Sprache.Calc.dll +0 -0
  72. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/Sprache.dll +0 -0
  73. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/System.Collections.Immutable.dll +0 -0
  74. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/System.Data.OleDb.dll +0 -0
  75. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
  76. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/System.Reflection.Metadata.dll +0 -0
  77. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/System.Reflection.MetadataLoadContext.dll +0 -0
  78. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
  79. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/__init__.py +0 -0
  80. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/assimp.dll +0 -0
  81. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/componentmanager.user +0 -0
  82. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/defaultsettings.xml +0 -0
  83. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/resources/setup.bat +0 -0
  84. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/simultan_object.py +0 -0
  85. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/src/PySimultan2/type_setter_lookup.py +0 -0
  86. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/RoomAcoustics_V02.py +0 -0
  87. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/__init__.py +0 -0
  88. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/__init__.py +0 -0
  89. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/create_component.py +0 -0
  90. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/create_component_with_taxonomy_slot.py +0 -0
  91. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/create_referenced_component.py +0 -0
  92. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/create_taxonomies.py +0 -0
  93. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/__init__.py +0 -0
  94. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/empty_test_excel.xlsx +0 -0
  95. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example3.yml +0 -0
  96. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example4.yml +0 -0
  97. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example_create_typed_component.yml +0 -0
  98. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example_create_typed_component_with_slots.yml +0 -0
  99. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example_extend.yml +0 -0
  100. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_example_update_references.yml +0 -0
  101. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/readme_examples/resources/template_reference_list.yml +0 -0
  102. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/resources/__init__.py +0 -0
  103. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/resources/new_test_file.txt +0 -0
  104. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/resources/new_test_file2.txt +0 -0
  105. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_calc_static_zone_temperature.py +0 -0
  106. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_calculate_steady_state_temperature.py +0 -0
  107. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_circular_references.py +0 -0
  108. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_create_geometry.py +0 -0
  109. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_directory_and_files.py +0 -0
  110. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_files.py +0 -0
  111. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_files_load.py +0 -0
  112. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_load_geometry.py +0 -0
  113. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_load_multi_values.py +0 -0
  114. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_new_dll.py +0 -0
  115. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_new_project_creation.py +0 -0
  116. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_numeric_map.py +0 -0
  117. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_parameter_reference.py +0 -0
  118. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_pythonnet.py +0 -0
  119. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_register_decorator.py +0 -0
  120. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_set_attr_property.py +0 -0
  121. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_set_dictionary.py +0 -0
  122. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_set_properties.py +0 -0
  123. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_taxonomie_maps.py +0 -0
  124. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_taxonomies.py +0 -0
  125. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/test_ui.py +0 -0
  126. {pysimultan-0.5.9.5 → pysimultan-0.5.9.7}/tests/ui_minimal_example.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: PySimultan
3
- Version: 0.5.9.5
3
+ Version: 0.5.9.7
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
@@ -166,6 +166,10 @@ print(instances[0].param_1)
166
166
 
167
167
 
168
168
  # Change Log
169
+ ## [0.5.9.7] - 2025-01-09
170
+ - Added default component support to Mapper: if a default component is not present in the datamodel, it is automatically added
171
+ - Fixed content naming bug: Content.name is now used for the name of the TaxonomyEntry in SIMULTAN
172
+ - Added typing for better code completion
169
173
 
170
174
  ## [0.5.9.4] - 2024-12-31
171
175
  - Fixed bug in DirectoryInfo where \_\_dir_helper_file__ was not found if already existing
@@ -137,6 +137,10 @@ print(instances[0].param_1)
137
137
 
138
138
 
139
139
  # Change Log
140
+ ## [0.5.9.7] - 2025-01-09
141
+ - Added default component support to Mapper: if a default component is not present in the datamodel, it is automatically added
142
+ - Fixed content naming bug: Content.name is now used for the name of the TaxonomyEntry in SIMULTAN
143
+ - Added typing for better code completion
140
144
 
141
145
  ## [0.5.9.4] - 2024-12-31
142
146
  - Fixed bug in DirectoryInfo where \_\_dir_helper_file__ was not found if already existing
@@ -1,3 +1,8 @@
1
+ Version 0.5.9.7 (09.01.2024)
2
+ - Added default component support to Mapper: if a default component is not present in the datamodel, it is automatically added
3
+ - Fixed content naming bug: Content.name is now used for the name of the TaxonomyEntry in SIMULTAN
4
+ - Added typing for better code completion
5
+
1
6
  Version 0.5.9.4 (31.12.2024)
2
7
  - Fixed bug in DirectoryInfo where __dir__helper_file__ was not found if already existing
3
8
 
@@ -0,0 +1 @@
1
+ version = '0.5.9.7'
@@ -587,18 +587,33 @@ class DataModel:
587
587
 
588
588
  del_copy = False
589
589
 
590
- existing_files = [x.Name for x in self.project_data_manager.AssetManager.Resources]
590
+ existing_files = [x.current_full_path for x in self.project_data_manager.AssetManager.Resources]
591
591
  try:
592
592
  act_filename = filename.replace('\\', os.sep)
593
593
  except TypeError:
594
594
  act_filename = filename
595
595
 
596
- if os.path.basename(act_filename) in existing_files:
596
+ if not act_filename.startswith(self.project.ProjectUnpackFolder.FullPath) and target_dir is None:
597
+ target_dir_str = self.project.ProjectUnpackFolder.FullPath
598
+ elif target_dir is not None:
599
+ if isinstance(target_dir, ResourceDirectoryEntry):
600
+ target_dir_str = target_dir.CurrentFullPath
601
+ elif isinstance(target_dir, SystemFileInfo):
602
+ target_dir_str = target_dir.FullPath
603
+ elif isinstance(target_dir, str):
604
+ target_dir_str = target_dir
605
+ elif isinstance(target_dir, DirectoryInfo):
606
+ target_dir_str = target_dir.FullPath
607
+
608
+ full_filename = os.path.join(target_dir_str, os.path.basename(act_filename))
609
+
610
+ if full_filename in existing_files:
597
611
  # create copy with running counter in temp dir and use this file:
598
612
  counter = 1
599
613
  while True:
600
614
  new_filename = os.path.basename(filename) + f'({str(counter)})'
601
- if new_filename not in existing_files and not os.path.exists(new_filename):
615
+ full_filename = os.path.join(target_dir_str, new_filename)
616
+ if full_filename not in existing_files and not os.path.exists(new_filename):
602
617
  break
603
618
  counter += 1
604
619
  shutil.copy(filename, os.path.join(os.path.dirname(filename), new_filename))
@@ -776,7 +791,10 @@ class DataModel:
776
791
  None)
777
792
  return model_to_work_with, resource_file
778
793
 
779
- def get_or_create_taxonomy(self, taxonomy_key: str, taxonomy_name: str = None, description='', create=True):
794
+ def get_or_create_taxonomy(self, taxonomy_key: str,
795
+ taxonomy_name: str = None,
796
+ description='',
797
+ create=True) -> SimTaxonomy:
780
798
  taxonomy = next((x for x in self.taxonomies if x.Key == taxonomy_key), None)
781
799
  if taxonomy is None:
782
800
  if create:
@@ -784,7 +802,11 @@ class DataModel:
784
802
  else:
785
803
  raise ValueError(f'Taxonomy {taxonomy_key} not found in project {self.project_path}')
786
804
 
787
- return next((x for x in self.taxonomies if x.Key == taxonomy_key), None)
805
+ taxonomy = next((x for x in self.taxonomies if x.Key == taxonomy_key), None)
806
+
807
+ if create and taxonomy is None:
808
+ raise ValueError(f'Could not create taxonomy {taxonomy_key} in project {self.project_path}')
809
+ return taxonomy
788
810
 
789
811
  def get_or_create_taxonomy_entry(self,
790
812
  name: str,
@@ -860,7 +882,18 @@ class DataModel:
860
882
 
861
883
  @lru_cache()
862
884
  def get_file_infos(self) -> list[PythonFileInfo]:
863
- return [PythonFileInfo(resource_entry=asset) for asset in self.assets]
885
+ file_infos = []
886
+ for asset in self.assets:
887
+ if isinstance(asset, ResourceFileEntry):
888
+ file_infos.append(PythonFileInfo(resource_entry=asset))
889
+ return file_infos
890
+
891
+ def get_directory_infos(self) -> list[PythonDirectoryInfo]:
892
+ dir_infos = []
893
+ for asset in self.assets:
894
+ if isinstance(asset, ResourceDirectoryEntry):
895
+ dir_infos.append(PythonDirectoryInfo(resource_entry=asset, data_model=self))
896
+ return dir_infos
864
897
 
865
898
  def get_file_info_by_key(self,
866
899
  key: int) -> Optional[PythonFileInfo]:
@@ -17,6 +17,9 @@ from SIMULTAN.Data.Components import (ComponentWalker, SimComponent, SimBoolPara
17
17
  SimEnumParameter, SimIntegerParameter, SimStringParameter, ComponentMapping,
18
18
  SimSlot, SimComponentVisibility, SimChildComponentEntry, SimDefaultSlots,
19
19
  SimParameterOperations, SimComponentReference)
20
+
21
+ from SIMULTAN.Data.Assets import DocumentAsset
22
+
20
23
  from .files import FileInfo
21
24
 
22
25
  from . import config
@@ -562,9 +565,14 @@ class ComponentDictionary(SimultanObject):
562
565
  for ref_asset in self._wrapped_obj.ReferencedAssets.Items:
563
566
  for tag in ref_asset.Resource.Tags:
564
567
  key = tag.Target.Key.replace('__dict_key__', '')
565
- comp_dict[key] = get_obj_value(ref_asset.Target,
566
- data_model=self._data_model,
567
- object_mapper=self._object_mapper)
568
+ if isinstance(ref_asset, DocumentAsset):
569
+ comp_dict[key] = get_obj_value(ref_asset.Resource,
570
+ data_model=self._data_model,
571
+ object_mapper=self._object_mapper)
572
+ else:
573
+ comp_dict[key] = get_obj_value(ref_asset.Target,
574
+ data_model=self._data_model,
575
+ object_mapper=self._object_mapper)
568
576
 
569
577
  object.__setattr__(self, '_dict', comp_dict)
570
578
 
@@ -1,4 +1,4 @@
1
- from typing import Optional, Type, TYPE_CHECKING, Union, Any
1
+ from typing import Optional, Type, TYPE_CHECKING, Union, Any, Dict, List
2
2
  from copy import copy
3
3
  from collections import UserList
4
4
  from colorlog import getLogger
@@ -74,6 +74,8 @@ class PythonMapper(object):
74
74
  self.re_register = False
75
75
  self.load_undefined = False
76
76
 
77
+ self.default_components: List[Any] = []
78
+
77
79
  @property
78
80
  def module(self):
79
81
  return self._module
@@ -147,7 +149,9 @@ class PythonMapper(object):
147
149
  self.taxonomy_maps.update(submodule.taxonomy_maps)
148
150
  self.registered_geometry_classes.update(submodule.registered_geometry_classes)
149
151
 
150
- def create_mapped_class(self, taxonomy, cls):
152
+ def create_mapped_class(self,
153
+ taxonomy: str,
154
+ cls: Any):
151
155
 
152
156
  if any([issubclass(cls, x) for x in (SimultanObject, UserList)]):
153
157
  bases = (cls,)
@@ -179,7 +183,10 @@ class PythonMapper(object):
179
183
 
180
184
  return self.mapped_classes.get(taxonomy, None)
181
185
 
182
- def get_typed_data(self, data_model=None, component_list=None, create_all=False):
186
+ def get_typed_data(self,
187
+ data_model: 'DataModel' = None,
188
+ component_list: List[SimComponent] = None,
189
+ create_all: bool = False):
183
190
 
184
191
  typed_data = []
185
192
 
@@ -229,8 +236,27 @@ class PythonMapper(object):
229
236
  typed_object = self.create_python_object(component, data_model=data_model)
230
237
  if typed_object is not None:
231
238
  typed_data.append(typed_object)
239
+
240
+ if create_all:
241
+ self.create_default_components(data_model)
242
+
232
243
  return typed_data
233
244
 
245
+ def create_default_components(self, data_model: 'DataModel'):
246
+ for instance in self.default_components:
247
+ key = list(filter(lambda x: self.registered_classes[x] == type(instance),
248
+ self.registered_classes)
249
+ )[0]
250
+ cls = self.get_mapped_class(key)
251
+ if not cls.cls_instances:
252
+ self.create_mapped_python_object(obj=instance,
253
+ data_model=data_model)
254
+ else:
255
+ # check if default instance is already in data model
256
+ if not any([x.name == instance.name for x in cls.cls_instances]):
257
+ self.create_mapped_python_object(obj=instance,
258
+ data_model=data_model)
259
+
234
260
  def create_python_geometry_object(self,
235
261
  component: Union[Layer, Vertex, Edge, PEdge, Face, Volume, EdgeLoop],
236
262
  data_model: 'DataModel' = None,
@@ -3,12 +3,12 @@ from functools import cache
3
3
  from ruamel.yaml import YAML, yaml_object, add_representer
4
4
  from . import yaml
5
5
 
6
- from typing import TYPE_CHECKING, Optional, Union, Literal
6
+ from typing import TYPE_CHECKING, Optional, Union, Literal, Any, Dict
7
7
 
8
8
  if TYPE_CHECKING:
9
9
  from .data_model import DataModel
10
10
 
11
- from SIMULTAN.Data.Taxonomy import SimTaxonomyEntryReference
11
+ from SIMULTAN.Data.Taxonomy import SimTaxonomyEntryReference, SimTaxonomyEntry, SimTaxonomyEntryReference, SimTaxonomy
12
12
 
13
13
 
14
14
  @yaml_object(yaml)
@@ -17,6 +17,14 @@ class Content(object):
17
17
  yaml_tag = u'!Content'
18
18
 
19
19
  def __init__(self,
20
+ text_or_key: str,
21
+ name: Optional[str] = None,
22
+ property_name: Optional[str] = None,
23
+ slot_extension: Optional[str] = None,
24
+ type: Optional[Any] = None,
25
+ unit: Optional[str] = None,
26
+ documentation: Optional[str] = None,
27
+ component_policy: Optional[Literal['reference', 'subcomponent']] = 'subcomponent',
20
28
  *args,
21
29
  **kwargs):
22
30
  """
@@ -24,6 +32,7 @@ class Content(object):
24
32
 
25
33
  :param args:
26
34
  :Keyword Arguments
35
+ * *name* (``str``) -- name of the Taxonomy Entry in SIMULTAN
27
36
  * *text_or_key* (``str``) -- text or key of the content/parameter/property
28
37
  * *property_name* (``str``) -- name of the generated property
29
38
  * *slot_extension* (``str``) -- slot extension of the content/parameter/property
@@ -33,20 +42,20 @@ class Content(object):
33
42
  * *component_policy* (``str``) -- component add policy of the content/parameter/property, 'reference' or 'subcomponent'
34
43
  """
35
44
 
36
- self.name: str = kwargs.get('name', kwargs.get('text_or_key'))
37
- self.text_or_key: str = kwargs.get('text_or_key') # text or key of the content/parameter/property
38
- self.property_name: str = kwargs.get('property_name') # name of the generated property
39
- self.slot_extension: str = kwargs.get('slot_extension') # slot extension of the content/parameter/property
40
- self.type = kwargs.get('type', None) # type of the content/parameter/property
41
- self.unit: Optional[str] = kwargs.get('unit', None) # unit of the content/parameter/property
42
- self.documentation: Optional[str] = kwargs.get('documentation', None) # documentation of the content/parameter/property
43
- self.component_policy: Literal['reference', 'subcomponent'] = kwargs.get('component_policy', 'reference') # component add policy of the content/parameter/property, 'reference' or 'subcomponent'
45
+ self.name: str = name if name is not None else text_or_key # name of the Taxonomy Entry in SIMULTAN
46
+ self.text_or_key: str = text_or_key # text or key of the content/parameter/property
47
+ self.property_name: str = property_name if property_name is not None else text_or_key # name of the generated property in the python class
48
+ self.slot_extension: str = slot_extension # slot extension of the content/parameter/property
49
+ self.type: Optional[Any] = type # type of the content/parameter/property
50
+ self.unit: Optional[str] = unit # unit of the content/parameter/property
51
+ self.documentation: Optional[str] = documentation # documentation of the content/parameter/property
52
+ self.component_policy: Literal['reference', 'subcomponent'] = component_policy # component add policy of the content/parameter/property, 'reference' or 'subcomponent'
44
53
 
45
54
  self._taxonomies = {}
46
55
  self._taxonomy_entries = {}
47
- self._taxonomy_map = kwargs.get('taxonomy_map', None)
56
+ self._taxonomy_map: Optional['TaxonomyMap'] = kwargs.get('taxonomy_map', None)
48
57
 
49
- self.taxonomy_key = kwargs.get('taxonomy_key')
58
+ self.taxonomy_key: Optional[SimTaxonomy] = kwargs.get('taxonomy_key')
50
59
 
51
60
  add_kwargs = kwargs.copy()
52
61
  _ = [add_kwargs.pop(key, None) for key in ['taxonomy_name', 'taxonomy_key', 'taxonomy_entry_name',
@@ -54,10 +63,10 @@ class Content(object):
54
63
  'mapped_class', 'unit', 'type', 'component_policy',
55
64
  'text_or_key', 'property_name', 'slot_extension']]
56
65
 
57
- self.additional_attributes = add_kwargs
66
+ self.additional_attributes: dict[Any, Any] = add_kwargs
58
67
 
59
- self.taxonomy_key = kwargs.get('taxonomy_key')
60
- self.taxonomy_name = kwargs.get('taxonomy_name')
68
+ self.taxonomy_key: Optional[SimTaxonomy] = kwargs.get('taxonomy_key')
69
+ self.taxonomy_name: str = kwargs.get('taxonomy_name')
61
70
 
62
71
 
63
72
  def get_taxonomie_entry(self, data_model: 'DataModel'):
@@ -70,7 +79,7 @@ class Content(object):
70
79
  taxonomy_key=self.taxonomy_key,
71
80
  create=True)
72
81
 
73
- self._taxonomy_entries[data_model] = data_model.get_or_create_taxonomy_entry(name=self.text_or_key,
82
+ self._taxonomy_entries[data_model] = data_model.get_or_create_taxonomy_entry(name=self.name,
74
83
  key=self.text_or_key,
75
84
  description=self.documentation,
76
85
  sim_taxonomy=taxonomy)
@@ -97,29 +106,38 @@ class TaxonomyMap(object):
97
106
  taxonomie_map = yaml.load(f)
98
107
  return taxonomie_map[0]
99
108
 
100
- def __init__(self, *args, **kwargs):
109
+ def __init__(self,
110
+ taxonomy_key: str,
111
+ taxonomy_entry_key: str,
112
+ taxonomy_name: Optional[str] = None,
113
+ taxonomy_entry_name: Optional[str] = None,
114
+ content: Optional[list[Content]] = None,
115
+ documentation: Optional[str] = None,
116
+ *args,
117
+ **kwargs):
101
118
 
102
119
  self._content = []
103
120
  self._content_dict = {}
104
121
  self._parameter_taxonomy_entry_dict = {}
105
122
 
106
- self.taxonomy_name = kwargs.get('taxonomy_name', kwargs.get('taxonomy_key'))
107
- self.taxonomy_key = kwargs.get('taxonomy_key')
123
+ self.taxonomy_key = taxonomy_key
124
+ self.taxonomy_name = taxonomy_name if taxonomy_name is not None else taxonomy_key
108
125
 
109
- if self.taxonomy_key == kwargs.get('taxonomy_entry_key'):
126
+
127
+ if self.taxonomy_key == taxonomy_entry_key:
110
128
  raise ValueError('taxonomy_key and taxonomy_entry_key must be different')
111
129
 
112
- self.taxonomy_entry_name = kwargs.get('taxonomy_entry_name', kwargs.get('taxonomy_entry_key'))
113
- self.taxonomy_entry_key = kwargs.get('taxonomy_entry_key')
130
+ self.taxonomy_entry_key = taxonomy_entry_key
131
+ self.taxonomy_entry_name = taxonomy_entry_name if taxonomy_entry_name is not None else taxonomy_entry_key
114
132
 
115
- self.content = kwargs.get('content', [])
116
- self.documentation = kwargs.get('documentation', '')
133
+ self.content = content if content is not None else []
134
+ self.documentation = documentation
117
135
 
118
136
  self.python_mapper = kwargs.get('python_mapper', None)
119
137
  self.mapped_class = kwargs.get('mapped_class', None)
120
138
 
121
- self._taxonomies = {}
122
- self._taxonomy_entries = {}
139
+ self._taxonomies: Dict[DataModel, SimTaxonomy] = {}
140
+ self._taxonomy_entries: Dict[DataModel, SimTaxonomyEntry] = {}
123
141
 
124
142
  @property
125
143
  def content(self):
@@ -187,7 +205,7 @@ class TaxonomyMap(object):
187
205
 
188
206
  def get_or_create_simultan_taxonomy(self,
189
207
  data_model: 'DataModel',
190
- create=True):
208
+ create=True) -> SimTaxonomy:
191
209
  if self._taxonomies.get(data_model, None) is None:
192
210
  self._taxonomies[data_model] = data_model.get_or_create_taxonomy(
193
211
  taxonomy_name=self.taxonomy_name,
@@ -151,7 +151,7 @@ def create_taxonomy(name, key, description='', data_model=None) -> SimTaxonomy:
151
151
  :param data_model: data model; if not None, the taxonomy will be added to the data model
152
152
  :return: SimTaxonomy
153
153
  """
154
- new_taxonomy = SimTaxonomy(key, name, description)
154
+ new_taxonomy = SimTaxonomy(key, name, description, None)
155
155
  if data_model is not None:
156
156
  data_model.taxonomies.Add(new_taxonomy)
157
157
  return new_taxonomy
@@ -0,0 +1,105 @@
1
+ import os
2
+
3
+ project_dir = os.environ.get('PROJECT_DIR', '/simultan_projects')
4
+ if not os.path.exists(project_dir):
5
+ os.makedirs(project_dir)
6
+
7
+ try:
8
+ import importlib.resources as pkg_resources
9
+ except ImportError:
10
+ # Try backported to PY<37 importlib_resources.
11
+ import importlib_resources as pkg_resources
12
+
13
+ from PySimultan2.taxonomy_maps import Content, TaxonomyMap
14
+ from PySimultan2 import PythonMapper
15
+ from PySimultan2 import DataModel
16
+
17
+
18
+ mapper = PythonMapper(module='test_default_component')
19
+
20
+ class A:
21
+
22
+ def __init__(self,
23
+ name: str = 'A',
24
+ param_a: int = 0,
25
+ param_b: float = 0.0,
26
+ param_c: str = 'test_str',
27
+ *args, **kwargs):
28
+
29
+ self.param_a = param_a
30
+ self.param_b = param_b
31
+ self.param_c = param_c
32
+
33
+
34
+ # define content
35
+
36
+ param_a_content = Content(text_or_key='param_a',
37
+ property_name='param_a',
38
+ type=None,
39
+ unit='',
40
+ documentation='',
41
+ component_policy='subcomponent')
42
+
43
+ param_b_content = Content(text_or_key='param_b',
44
+ property_name='param_b',
45
+ type=None,
46
+ unit='',
47
+ documentation='',
48
+ component_policy='subcomponent')
49
+
50
+ param_c_content = Content(name='This is the Name of the Content C',
51
+ text_or_key='param_c',
52
+ property_name='param_c',
53
+ type=None,
54
+ unit='',
55
+ documentation='',
56
+ component_policy='subcomponent')
57
+
58
+ # define taxonomy maps
59
+ a_map = TaxonomyMap(taxonomy_name='test_default_component',
60
+ taxonomy_key='test_default_component',
61
+ taxonomy_entry_name='A',
62
+ taxonomy_entry_key='A',
63
+ content=[param_a_content,
64
+ param_b_content,
65
+ param_c_content]
66
+ )
67
+
68
+ # register taxonomy maps
69
+ mapper.register(a_map.taxonomy_entry_key,
70
+ A,
71
+ taxonomy_map=a_map,
72
+ re_register=True)
73
+
74
+
75
+ mapper.default_components.append(A(name='default_A',
76
+ param_a=5,
77
+ param_b=8.0,
78
+ param_c='default_str'))
79
+
80
+
81
+ data_model = DataModel.create_new_project(project_path=os.path.join(project_dir, 'test_default_component.simultan'),
82
+ user_name='admin',
83
+ password='admin')
84
+
85
+ typed_data = data_model.get_typed_data(mapper=mapper,
86
+ create_all=True)
87
+
88
+ MappedAClass = mapper.get_mapped_class('A')
89
+
90
+ MappedAClass(name='test_A',
91
+ param_a=17,
92
+ param_b=8.0,
93
+ param_c='test_str',
94
+ data_model=data_model,
95
+ mapper=mapper)
96
+
97
+
98
+
99
+
100
+ MappedAClass(name='test_A',
101
+ param_a=17,
102
+ param_b=8.0,
103
+ param_c='test_str')
104
+
105
+ assert MappedAClass.cls_instances[0].param_a == 5
@@ -3,7 +3,7 @@ import os
3
3
  from PySimultan2.data_model import DataModel
4
4
  from PySimultan2.object_mapper import PythonMapper
5
5
  from PySimultan2.taxonomy_maps import TaxonomyMap, Content
6
- from src.PySimultan2.config import yaml
6
+
7
7
  # from bson.objectid import ObjectId
8
8
 
9
9
 
@@ -63,50 +63,6 @@ def create_material_taxonomie_map(filename=None):
63
63
  return material
64
64
 
65
65
 
66
- def save_data_model_in_mongodb(host, data_model, db='pysimultan2'):
67
- from mongoengine import connect, disconnect
68
- from src.PySimultan2.mongo_utils.base_classes import SimComponent, SimTaxonomyEntry
69
-
70
- db = connect(db=db, host=host, alias='default')
71
- data_model.save_in_mongodb(db)
72
-
73
- # Execute the pipeline on the collection
74
- results = list(SimComponent.objects(slots__contains=SimTaxonomyEntry.objects(key='undefined').first()))
75
- for result in results:
76
- print(result)
77
-
78
- SimComponent.objects(slots__key='min_refinement_level')
79
-
80
- for result in results:
81
- print(result)
82
-
83
- disconnect(db)
84
-
85
-
86
- def save_in_mongodb(component, host, db='pysimultan2'):
87
- from mongoengine import connect, disconnect
88
-
89
- db = connect(db, host=host, alias='default')
90
- component.save_in_mongodb(db)
91
- disconnect(db)
92
-
93
-
94
- def load_from_mongodb(host):
95
- from src.PySimultan2.mongo_utils.base_classes import SimComponent, SimTaxonomyEntry
96
- db = connect('pysimultan2', host=host, alias='default2')
97
- # test_instances = TestClass.objects
98
- # loaded_base_components = list(BaseMongoDocument.objects)
99
- loaded_components = SimComponent.objects
100
- disconnect(db)
101
- return loaded_components
102
-
103
-
104
- def drop_mongodb(host):
105
- db = connect('pysimultan2', host=host, alias='default')
106
- db.drop_database('pysimultan2')
107
- disconnect(db)
108
-
109
-
110
66
  class Undefined(object):
111
67
 
112
68
  def __init__(self, *args, **kwargs):
@@ -1 +0,0 @@
1
- version = '0.5.9.5'
File without changes
File without changes