PySimultan 0.4.18__tar.gz → 0.4.20__tar.gz

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.
Files changed (137) hide show
  1. {pysimultan-0.4.18 → pysimultan-0.4.20}/PKG-INFO +10 -1
  2. {pysimultan-0.4.18 → pysimultan-0.4.20}/README.md +9 -0
  3. pysimultan-0.4.20/src/PySimultan2/__about__.py +1 -0
  4. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/default_types.py +53 -13
  5. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/taxonomy_maps.py +8 -0
  6. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/utils.py +34 -2
  7. pysimultan-0.4.20/tests/resources/test_set_dictionary.simultan +0 -0
  8. pysimultan-0.4.20/tests/test_set_dictionary.py +163 -0
  9. pysimultan-0.4.18/src/PySimultan2/__about__.py +0 -1
  10. pysimultan-0.4.18/tests/test_set_dictionary.py +0 -88
  11. {pysimultan-0.4.18 → pysimultan-0.4.20}/.gitignore +0 -0
  12. {pysimultan-0.4.18 → pysimultan-0.4.20}/LICENSE.txt +0 -0
  13. {pysimultan-0.4.18 → pysimultan-0.4.20}/pyproject.toml +0 -0
  14. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/__init__.py +0 -0
  15. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/data_model.py +0 -0
  16. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/files.py +0 -0
  17. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/geometry/__init__.py +0 -0
  18. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/geometry/geometry_base.py +0 -0
  19. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/geometry/utils.py +0 -0
  20. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/multi_values.py +0 -0
  21. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/object_mapper.py +0 -0
  22. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/AssimpNet.dll +0 -0
  23. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/AvalonDock.dll +0 -0
  24. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/BruTile.dll +0 -0
  25. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ClosedXML.dll +0 -0
  26. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ComponentBuilder.dll +0 -0
  27. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ComponentBuilder.dll.config +0 -0
  28. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ComponentBuilder.runtimeconfig.json +0 -0
  29. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ComponentBuilder.xml +0 -0
  30. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ControlzEx.dll +0 -0
  31. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  32. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
  33. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/DotSpatial.Projections.dll +0 -0
  34. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/ExcelNumberFormat.dll +0 -0
  35. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Fluent.dll +0 -0
  36. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/GeometryViewer.dll +0 -0
  37. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/GeometryViewer.dll.config +0 -0
  38. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/GeometryViewer.xml +0 -0
  39. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
  40. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
  41. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
  42. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/HelixToolkit.dll +0 -0
  43. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/MathNet.Numerics.dll +0 -0
  44. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
  45. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
  46. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  47. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  48. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
  49. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
  50. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  51. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  52. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
  53. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
  54. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Newtonsoft.Json.dll +0 -0
  55. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  56. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
  57. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  58. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +0 -0
  59. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  60. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.Lang.xml +0 -0
  61. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  62. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.Plugins.xml +0 -0
  63. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  64. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.UI.xml +0 -0
  65. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.dll +0 -0
  66. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SIMULTAN.xml +0 -0
  67. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
  68. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.DXGI.dll +0 -0
  69. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
  70. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
  71. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
  72. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.Mathematics.dll +0 -0
  73. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SharpDX.dll +0 -0
  74. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SitePlanner.dll +0 -0
  75. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SitePlanner.dll.config +0 -0
  76. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/SitePlanner.xml +0 -0
  77. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Sprache.Calc.dll +0 -0
  78. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/Sprache.dll +0 -0
  79. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/System.Data.OleDb.dll +0 -0
  80. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
  81. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
  82. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/__init__.py +0 -0
  83. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/assimp.dll +0 -0
  84. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/defaultsettings.xml +0 -0
  85. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/resources/setup.bat +0 -0
  86. {pysimultan-0.4.18 → pysimultan-0.4.20}/src/PySimultan2/simultan_object.py +0 -0
  87. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/__init__.py +0 -0
  88. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/__init__.py +0 -0
  89. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/create_component.py +0 -0
  90. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/create_component_with_taxonomy_slot.py +0 -0
  91. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/create_referenced_component.py +0 -0
  92. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/create_taxonomies.py +0 -0
  93. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/__init__.py +0 -0
  94. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/change_references_example.simultan +0 -0
  95. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/empty_project.simultan +0 -0
  96. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/empty_test_excel.xlsx +0 -0
  97. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/example1.simultan +0 -0
  98. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/example2.simultan +0 -0
  99. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/example3.simultan +0 -0
  100. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/example4_reference_list.simultan +0 -0
  101. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/example_extend_1.simultan +0 -0
  102. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/list_test.simultan +0 -0
  103. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example3.yml +0 -0
  104. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example4.yml +0 -0
  105. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example_create_typed_component.yml +0 -0
  106. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example_create_typed_component_with_slots.yml +0 -0
  107. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example_extend.yml +0 -0
  108. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_example_update_references.yml +0 -0
  109. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/readme_examples/resources/template_reference_list.yml +0 -0
  110. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/U5.simultan +0 -0
  111. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/U5_1.simultan +0 -0
  112. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/U5_orig.simultan +0 -0
  113. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/__init__.py +0 -0
  114. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/new_geometry_test.simultan +0 -0
  115. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/test_file.yml +0 -0
  116. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/test_file_load.simultan +0 -0
  117. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/test_file_project.simultan +0 -0
  118. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/resources/test_multi_value_big_table_load.simultan +0 -0
  119. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_calc_static_zone_temperature.py +0 -0
  120. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_calculate_steady_state_temperature.py +0 -0
  121. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_circular_references.py +0 -0
  122. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_create_geometry.py +0 -0
  123. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_files.py +0 -0
  124. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_files_load.py +0 -0
  125. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_load_geometry.py +0 -0
  126. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_load_multi_values.py +0 -0
  127. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_new_dll.py +0 -0
  128. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_new_project_creation.py +0 -0
  129. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_numeric_map.py +0 -0
  130. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_pythonnet.py +0 -0
  131. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_register_class.py +0 -0
  132. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_set_attr_property.py +0 -0
  133. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_set_properties.py +0 -0
  134. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_taxonomie_maps.py +0 -0
  135. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_taxonomies.py +0 -0
  136. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/test_ui.py +0 -0
  137. {pysimultan-0.4.18 → pysimultan-0.4.20}/tests/ui_minimal_example.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: PySimultan
3
- Version: 0.4.18
3
+ Version: 0.4.20
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
@@ -78,3 +78,12 @@ C:\Program Files\FreeCAD
78
78
 
79
79
 
80
80
  ```
81
+
82
+
83
+ # Change Log
84
+
85
+ ## [0.4.20] - 2024-07-01
86
+ - Fixed Bug in nested dictionary creation
87
+
88
+ ## [0.4.19] - 2024-07-01
89
+ - Refactored dictionaries
@@ -49,3 +49,12 @@ C:\Program Files\FreeCAD
49
49
 
50
50
 
51
51
  ```
52
+
53
+
54
+ # Change Log
55
+
56
+ ## [0.4.20] - 2024-07-01
57
+ - Fixed Bug in nested dictionary creation
58
+
59
+ ## [0.4.19] - 2024-07-01
60
+ - Refactored dictionaries
@@ -0,0 +1 @@
1
+ version = '0.4.20'
@@ -341,6 +341,9 @@ class ComponentDictionary(SimultanObject):
341
341
  super().__init__(*args, **kwargs)
342
342
  self.component_policy = kwargs.get('component_policy', 'subcomponent') # component add policy of the content/parameter/property, 'reference' or 'subcomponent'
343
343
 
344
+ def __load_init__(self, *args, **kwargs):
345
+ self._dict = {}
346
+
344
347
  @classmethod
345
348
  def create_from_values(cls,
346
349
  values: dict[str, Any],
@@ -374,13 +377,54 @@ class ComponentDictionary(SimultanObject):
374
377
 
375
378
  if kwargs.get('check_dict', True) and comp_dict is not None and key in object.__getattribute__(self,
376
379
  '_dict').keys():
377
- return object.__getattribute__(self, '_dict')[key]
380
+ return object.__getattribute__(self, '_dict').get(key, None)
378
381
  else:
379
382
  # data_model = config.default_data_model
380
- obj = get_component_taxonomy_entry(self._wrapped_obj, key)
381
- if obj is not None:
382
- val = get_obj_value(obj, data_model=self._data_model, object_mapper=self._object_mapper)
383
- self._dict[key] = val
383
+ # obj = get_component_taxonomy_entry(self._wrapped_obj, key)
384
+ # if obj is not None:
385
+ # val = get_obj_value(obj, data_model=self._data_model, object_mapper=self._object_mapper)
386
+ data_model = self._data_model
387
+ object_mapper = self._object_mapper
388
+ wrapped_obj = self._wrapped_obj
389
+
390
+ if key in self._taxonomy_map.parameter_taxonomy_entry_dict.keys():
391
+ text_or_key = self._taxonomy_map.parameter_taxonomy_entry_dict[key]
392
+ else:
393
+ content = Content(text_or_key=f'__dict_key__{key}',
394
+ property_name=key,
395
+ type=None,
396
+ unit=None,
397
+ documentation=f'Property {key} in ComponentDictionary',
398
+ component_policy=self.component_policy)
399
+ self._taxonomy_map.add_content(content)
400
+ text_or_key = content.text_or_key
401
+
402
+ try:
403
+ components = list(wrapped_obj.Components.Items)
404
+ val = next((get_obj_value(x.Component,
405
+ data_model=data_model,
406
+ object_mapper=object_mapper) for x in components if
407
+ x.Slot.SlotBase.Target.Key == text_or_key), None)
408
+ if val is None:
409
+ ref_components = list(wrapped_obj.ReferencedComponents.Items)
410
+ val = next((get_obj_value(x.Target,
411
+ data_model=data_model,
412
+ object_mapper=object_mapper) for x in ref_components
413
+ if x.Slot.SlotBase.Target.Key == text_or_key), None)
414
+ if val is None:
415
+ parameters = list(wrapped_obj.Parameters.Items)
416
+ val = next((get_obj_value(x,
417
+ data_model=data_model,
418
+ object_mapper=object_mapper) for x in parameters if
419
+ x.NameTaxonomyEntry.TextOrKey == text_or_key), None)
420
+
421
+ except Exception as e:
422
+ logger.error(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
423
+ raise ValueError(f'Could not get value for key {key} ({text_or_key}) in {self}:\n{e}')
424
+
425
+ self._dict[key] = get_obj_value(val,
426
+ data_model=data_model,
427
+ object_mapper=object_mapper)
384
428
  return self._dict[key]
385
429
 
386
430
  def __setitem__(self, key, value):
@@ -391,7 +435,7 @@ class ComponentDictionary(SimultanObject):
391
435
  if key in self._taxonomy_map.content_dict.keys():
392
436
  content = self._taxonomy_map.content_dict[key]
393
437
  else:
394
- content = Content(text_or_key=key,
438
+ content = Content(text_or_key=f'__dict_key__{key}',
395
439
  property_name=key,
396
440
  type=None,
397
441
  unit=None,
@@ -399,7 +443,6 @@ class ComponentDictionary(SimultanObject):
399
443
  component_policy=self.component_policy)
400
444
  self._taxonomy_map.add_content(content)
401
445
  taxonomy_entry = content.get_taxonomie_entry(self._data_model)
402
-
403
446
  component_idx, ref_component_idx, parameter_idx, ref_asset_idx = get_param_indices(self._wrapped_obj,
404
447
  taxonomy_entry)
405
448
 
@@ -425,6 +468,7 @@ class ComponentDictionary(SimultanObject):
425
468
  ref_component_idx=ref_component_idx,
426
469
  parameter_idx=parameter_idx,
427
470
  keep=[])
471
+ return
428
472
 
429
473
  if isinstance(value, (list, tuple, set, ComponentList)):
430
474
  setter_fcn = set_property_to_list
@@ -436,11 +480,7 @@ class ComponentDictionary(SimultanObject):
436
480
  setter_fcn(*fcn_arg_list)
437
481
  item = self.__getitem__(key, check_dict=False)
438
482
 
439
- # self._object_mapper.create_python_object(self._wrapped_obj)
440
- #
441
- # if isinstance(value, ):
442
-
443
- self._dict[key] = self.__getitem__(key, check_dict=False)
483
+ self._dict[key] = item
444
484
 
445
485
  def __delitem__(self, key):
446
486
  self[key] = None
@@ -471,7 +511,7 @@ class ComponentDictionary(SimultanObject):
471
511
  data_model=self._data_model,
472
512
  object_mapper=self._object_mapper)
473
513
  for ref_component in self._wrapped_obj.ReferencedComponents.Items:
474
- comp_dict[ref_component.Slot.SlotBase.Target.Name] = get_obj_value(ref_component.Target,
514
+ comp_dict[ref_component.Slot.SlotBase.Target.Key] = get_obj_value(ref_component.Target,
475
515
  data_model=self._data_model,
476
516
  object_mapper=self._object_mapper)
477
517
  for ref_asset in self._wrapped_obj.ReferencedAssets.Items:
@@ -87,6 +87,7 @@ class TaxonomyMap(object):
87
87
 
88
88
  self._content = []
89
89
  self._content_dict = {}
90
+ self._parameter_taxonomy_entry_dict = {}
90
91
 
91
92
  self.taxonomy_name = kwargs.get('taxonomy_name', kwargs.get('taxonomy_key', None))
92
93
  self.taxonomy_key = kwargs.get('taxonomy_key', None)
@@ -124,6 +125,13 @@ class TaxonomyMap(object):
124
125
  self._content_dict[content.text_or_key] = content
125
126
  return self._content_dict
126
127
 
128
+ @property
129
+ def parameter_taxonomy_entry_dict(self):
130
+ if not self._parameter_taxonomy_entry_dict:
131
+ for content in self._content:
132
+ self._parameter_taxonomy_entry_dict[content.property_name] = content.text_or_key
133
+ return self._parameter_taxonomy_entry_dict
134
+
127
135
  def write(self, filename=None):
128
136
  if filename is not None:
129
137
  with open(filename, mode='w') as f:
@@ -1,10 +1,16 @@
1
1
  from __future__ import annotations
2
2
 
3
+ import sys
4
+ import traceback
5
+
3
6
  from enum import Enum
4
7
  from weakref import WeakSet
5
8
  import numpy as np
6
9
  import pandas as pd
7
10
  from typing import List as TypeList, Union, Optional, Type, Any, TYPE_CHECKING
11
+
12
+ from System import ArgumentException, NotSupportedException
13
+
8
14
  from SIMULTAN.Data.Components import (ComponentWalker, SimComponent, SimBoolParameter, SimDoubleParameter,
9
15
  SimEnumParameter, SimIntegerParameter, SimStringParameter, ComponentMapping,
10
16
  SimSlot, SimComponentVisibility, SimChildComponentEntry, SimDefaultSlots,
@@ -417,8 +423,31 @@ def add_sub_component(comp: SimComponent,
417
423
  new_slot = SimSlot(sub_comp.Slots[0].Target, str(slot_extension))
418
424
 
419
425
  entry = SimChildComponentEntry(new_slot, sub_comp)
426
+
427
+ error = None
428
+ new_slot_extension = 0
429
+
420
430
  if entry not in comp.Components.Items:
421
- comp.Components.InsertItem(len(comp.Components.Items), entry)
431
+ try:
432
+ comp.Components.InsertItem(len(comp.Components.Items), entry)
433
+ except (ArgumentException, NotSupportedException) as e:
434
+ error = e
435
+
436
+ while error is not None and new_slot_extension < 100:
437
+ try:
438
+ try:
439
+ slot_extension += 1
440
+ if slot_extension > 1000:
441
+ break
442
+ except Exception as e:
443
+ new_slot_extension += 1
444
+ slot_extension = slot_extension + f'_{new_slot_extension}'
445
+ new_slot = SimSlot(sub_comp.Slots[0].Target, str(slot_extension))
446
+ entry = SimChildComponentEntry(new_slot, sub_comp)
447
+ comp.Components.InsertItem(len(comp.Components.Items), entry)
448
+ error = None
449
+ except (ArgumentException, NotSupportedException) as e:
450
+ error = e
422
451
  return True
423
452
 
424
453
 
@@ -727,7 +756,8 @@ type_convert_dict = {SimComponent: get_sim_component_value,
727
756
  SimEnumParameter: get_parameter_value,
728
757
  ResourceEntry: get_resource_entry_value,
729
758
  ContainedResourceFileEntry: get_resource_entry_value,
730
- LinkedResourceFileEntry: get_resource_entry_value}
759
+ LinkedResourceFileEntry: get_resource_entry_value
760
+ }
731
761
 
732
762
 
733
763
  def get_obj_value(obj: Union[SimComponent, SimDoubleParameter, SimIntegerParameter, SimStringParameter,
@@ -738,6 +768,8 @@ def get_obj_value(obj: Union[SimComponent, SimDoubleParameter, SimIntegerParamet
738
768
 
739
769
  if obj is None:
740
770
  return
771
+ elif isinstance(obj, (int, float, str)):
772
+ return obj
741
773
  elif type(obj) in type_convert_dict.keys():
742
774
  return type_convert_dict[type(obj)](obj, data_model=data_model, object_mapper=object_mapper)
743
775
  else:
@@ -0,0 +1,163 @@
1
+ from PySimultan2.src.PySimultan2.data_model import DataModel
2
+ from PySimultan2.src.PySimultan2.object_mapper import PythonMapper
3
+ from PySimultan2.src.PySimultan2.taxonomy_maps import TaxonomyMap, Content
4
+
5
+ import resources
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
+
14
+ with pkg_resources.path(resources, 'test_set_dictionary.simultan') as r_path:
15
+ project_path = str(r_path)
16
+
17
+ data_model = DataModel.create_new_project(project_path=project_path,
18
+ user_name='admin',
19
+ password='admin')
20
+
21
+ mapper = PythonMapper()
22
+
23
+
24
+ def map_classes():
25
+ class TestComponent(object):
26
+ def __init__(self, *args, **kwargs):
27
+ self.mapped_property = kwargs.get('mapped_property')
28
+ self.value2 = kwargs.get('value2')
29
+
30
+ content0 = Content(text_or_key='value', # text or key of the content/parameter/property
31
+ property_name='mapped_property', # name of the generated property
32
+ type=None, # type of the content/parameter/property
33
+ unit=None, # unit of the content/parameter/property
34
+ documentation='mapped_property to test',
35
+ component_policy='subcomponent')
36
+
37
+ content1 = Content(text_or_key='value2', # text or key of the content/parameter/property
38
+ property_name='value2', # name of the generated property
39
+ type=None, # type of the content/parameter/property
40
+ unit=None, # unit of the content/parameter/property
41
+ documentation='value2',
42
+ component_policy='reference')
43
+
44
+ test_component_map = TaxonomyMap(taxonomy_name='PySimultan',
45
+ taxonomy_key='PySimultan',
46
+ taxonomy_entry_name='TestComponent',
47
+ taxonomy_entry_key='TestComponent',
48
+ content=[content0, content1],
49
+ )
50
+
51
+ mapper.register(test_component_map.taxonomy_entry_key, TestComponent, taxonomy_map=test_component_map)
52
+ cls1 = mapper.get_mapped_class(test_component_map.taxonomy_entry_key)
53
+
54
+ test_component_map_2 = TaxonomyMap(taxonomy_name='PySimultan',
55
+ taxonomy_key='PySimultan',
56
+ taxonomy_entry_name='TestComponent2',
57
+ taxonomy_entry_key='TestComponent2',
58
+ content=[content0],
59
+ )
60
+
61
+ mapper.register(test_component_map_2.taxonomy_entry_key, TestComponent, taxonomy_map=test_component_map_2)
62
+ cls2 = mapper.get_mapped_class(test_component_map_2.taxonomy_entry_key)
63
+
64
+ return cls1, cls2
65
+
66
+
67
+ mapped_cls_1, mapped_cls_2 = map_classes()
68
+ component = mapped_cls_1(name='test_component',
69
+ mapped_property=None)
70
+
71
+
72
+ def test_set_dictionary_param(component):
73
+
74
+ other_component = mapped_cls_2(name='other_component',
75
+ mapped_property=None)
76
+ other_component_2 = mapped_cls_2(name='other_component_2',
77
+ mapped_property=None)
78
+ other_component_3 = mapped_cls_2(name='other_component_3',
79
+ mapped_property=None)
80
+ other_component_4 = mapped_cls_2(name='other_component_4',
81
+ mapped_property=None)
82
+
83
+ new_test = mapped_cls_1(name='test_component_2',
84
+ mapped_property={'val_a': 1,
85
+ 'val_b': 2.0,
86
+ 'val_c': 'test',
87
+ 'val_d': True,
88
+ 'val_e': [other_component, other_component_2, other_component_3],
89
+ 'val_f': {'a': other_component_2, 'b': other_component_3},
90
+ 'val_g': None,
91
+ 'val_h': other_component,
92
+ 'val_i': other_component_4,
93
+ })
94
+
95
+ test_dict = {'val_a': 1,
96
+ 'val_b': 2.0,
97
+ 'val_c': 'test',
98
+ 'val_d': True,
99
+ 'val_e': [other_component, other_component_2, other_component_3],
100
+ 'val_f': {'a': other_component_2, 'b': other_component_3},
101
+ 'val_g': None,
102
+ 'val_h': other_component,
103
+ 'val_i': 5,
104
+ 'val_j': new_test
105
+ }
106
+
107
+ component.mapped_property = test_dict
108
+ component.mapped_property['val_a'] = 222
109
+
110
+ assert component.mapped_property['val_j'].mapped_property['val_a'] == 1
111
+ component.mapped_property['val_j'].mapped_property._generate_internal_dict()
112
+
113
+ component.mapped_property['val_i'] = other_component_4
114
+
115
+ print(component.mapped_property)
116
+
117
+
118
+ def load_data_model(data_model: DataModel):
119
+ data_model = DataModel(project_path=project_path,
120
+ user_name='admin',
121
+ password='admin')
122
+ typed_data = data_model.get_typed_data(mapper=mapper,
123
+ create_all=True)
124
+
125
+ TestComponent = mapper.get_mapped_class('TestComponent')
126
+ test_component = TestComponent.cls_instances[0]
127
+
128
+ TestComponent2 = mapper.get_mapped_class('TestComponent2')
129
+ other_component = next(x for x in TestComponent2.cls_instances if x.name == 'other_component')
130
+ other_component_2 = next(x for x in TestComponent2.cls_instances if x.name == 'other_component_2')
131
+ other_component_3 = next(x for x in TestComponent2.cls_instances if x.name == 'other_component_3')
132
+ other_component_4 = next(x for x in TestComponent2.cls_instances if x.name == 'other_component_4')
133
+
134
+ assert test_component.mapped_property['val_a'] == 222
135
+ assert test_component.mapped_property['val_b'] == 2.0
136
+ assert test_component.mapped_property['val_c'] == 'test'
137
+ assert test_component.mapped_property['val_d'] is True
138
+ assert test_component.mapped_property['val_g'] is None
139
+ assert test_component.mapped_property['val_h'] == other_component
140
+ assert len(test_component.mapped_property['val_e']) == 3
141
+ assert test_component.mapped_property['val_e'][0] == other_component
142
+ assert test_component.mapped_property['val_e'][1] == other_component_2
143
+ assert test_component.mapped_property['val_e'][2] == other_component_3
144
+ assert test_component.mapped_property['val_f']['a'] == other_component_2
145
+ assert test_component.mapped_property['val_f']['b'] == other_component_3
146
+ assert test_component.mapped_property['val_i'] == other_component_4
147
+
148
+ return data_model
149
+
150
+
151
+ if __name__ == '__main__':
152
+ test_set_dictionary_param(component)
153
+ data_model.save()
154
+ mapper.clear()
155
+ data_model.cleanup()
156
+ data_model = DataModel(project_path=project_path,
157
+ user_name='admin',
158
+ password='admin')
159
+ load_data_model(data_model)
160
+
161
+
162
+ data_model.cleanup()
163
+ print('Test passed')
@@ -1 +0,0 @@
1
- version = '0.4.18'
@@ -1,88 +0,0 @@
1
- from PySimultan2.data_model import DataModel
2
- from PySimultan2.object_mapper import PythonMapper
3
- from PySimultan2.taxonomy_maps import TaxonomyMap, Content
4
-
5
- import resources
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
-
14
- with pkg_resources.path(resources, 'test_set_dictionary.simultan') as r_path:
15
- project_path = str(r_path)
16
-
17
- data_model = DataModel.create_new_project(project_path=project_path,
18
- user_name='admin',
19
- password='admin')
20
-
21
- mapper = PythonMapper()
22
-
23
-
24
- def map_classes():
25
- class TestComponent(object):
26
- def __init__(self, *args, **kwargs):
27
- self.mapped_property = kwargs.get('mapped_property')
28
- self.value2 = kwargs.get('value2')
29
-
30
- content0 = Content(text_or_key='value', # text or key of the content/parameter/property
31
- property_name='mapped_property', # name of the generated property
32
- type=None, # type of the content/parameter/property
33
- unit=None, # unit of the content/parameter/property
34
- documentation='mapped_property to test',
35
- component_policy='subcomponent')
36
-
37
- content1 = Content(text_or_key='value2', # text or key of the content/parameter/property
38
- property_name='value2', # name of the generated property
39
- type=None, # type of the content/parameter/property
40
- unit=None, # unit of the content/parameter/property
41
- documentation='value2',
42
- component_policy='reference')
43
-
44
- test_component_map = TaxonomyMap(taxonomy_name='PySimultan',
45
- taxonomy_key='PySimultan',
46
- taxonomy_entry_name='TestComponent',
47
- taxonomy_entry_key='TestComponent',
48
- content=[content0, content1],
49
- )
50
-
51
- mapper.register(test_component_map.taxonomy_entry_key, TestComponent, taxonomy_map=test_component_map)
52
- cls1 = mapper.get_mapped_class(test_component_map.taxonomy_entry_key)
53
-
54
- test_component_map_2 = TaxonomyMap(taxonomy_name='PySimultan',
55
- taxonomy_key='PySimultan',
56
- taxonomy_entry_name='TestComponent2',
57
- taxonomy_entry_key='TestComponent2',
58
- content=[content0],
59
- )
60
-
61
- mapper.register(test_component_map_2.taxonomy_entry_key, TestComponent, taxonomy_map=test_component_map_2)
62
- cls2 = mapper.get_mapped_class(test_component_map_2.taxonomy_entry_key)
63
-
64
- return cls1, cls2
65
-
66
-
67
- mapped_cls_1, mapped_cls_2 = map_classes()
68
- component = mapped_cls_1(name='test_component',
69
- mapped_property=None)
70
-
71
-
72
- def test_set_dictionary_param(component):
73
- test_dict = {'val_a': 1,
74
- 'val_b': 2.0,
75
- 'val_c': 'test'}
76
- component.mapped_property = test_dict
77
-
78
- component.mapped_property['val_a'] = 222
79
-
80
- print(component.mapped_property)
81
-
82
-
83
- if __name__ == '__main__':
84
- test_set_dictionary_param(component)
85
- data_model.save()
86
-
87
- data_model.cleanup()
88
- print('Test passed')
File without changes
File without changes
File without changes