PySimultan 0.5.0__tar.gz → 0.5.2.5__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/PKG-INFO +1 -1
  2. pysimultan-0.5.2.5/src/PySimultan2/CHANGELOG.md +4 -0
  3. pysimultan-0.5.2.5/src/PySimultan2/__about__.py +1 -0
  4. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/default_types.py +0 -4
  5. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/object_mapper.py +96 -10
  6. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/utils.py +30 -0
  7. pysimultan-0.5.2.5/tests/test_register_decorator.py +41 -0
  8. pysimultan-0.5.0/src/PySimultan2/__about__.py +0 -1
  9. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/.gitignore +0 -0
  10. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/LICENSE.txt +0 -0
  11. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/README.md +0 -0
  12. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/pyproject.toml +0 -0
  13. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/__init__.py +0 -0
  14. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/data_model.py +0 -0
  15. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/files.py +0 -0
  16. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/geometry/__init__.py +0 -0
  17. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/geometry/geometry_base.py +0 -0
  18. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/geometry/utils.py +0 -0
  19. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/multi_values.py +0 -0
  20. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/AssimpNet.dll +0 -0
  21. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/AvalonDock.dll +0 -0
  22. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/BruTile.dll +0 -0
  23. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ClosedXML.dll +0 -0
  24. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ComponentBuilder.dll +0 -0
  25. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ComponentBuilder.dll.config +0 -0
  26. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ComponentBuilder.runtimeconfig.json +0 -0
  27. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ComponentBuilder.xml +0 -0
  28. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ControlzEx.dll +0 -0
  29. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Cyotek.Drawing.BitmapFont.dll +0 -0
  30. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/DocumentFormat.OpenXml.dll +0 -0
  31. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/DotSpatial.Projections.dll +0 -0
  32. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/ExcelNumberFormat.dll +0 -0
  33. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Fluent.dll +0 -0
  34. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/HelixToolkit.Core.Wpf.dll +0 -0
  35. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.Wpf.dll +0 -0
  36. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/HelixToolkit.SharpDX.Core.dll +0 -0
  37. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/HelixToolkit.dll +0 -0
  38. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/MathNet.Numerics.dll +0 -0
  39. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.AspNetCore.Authorization.dll +0 -0
  40. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.AspNetCore.Metadata.dll +0 -0
  41. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.Extensions.DependencyInjection.Abstractions.dll +0 -0
  42. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.Extensions.Logging.Abstractions.dll +0 -0
  43. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.Extensions.Options.dll +0 -0
  44. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.Extensions.Primitives.dll +0 -0
  45. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.Shell.dll +0 -0
  46. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.WindowsAPICodePack.dll +0 -0
  47. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Microsoft.Xaml.Behaviors.dll +0 -0
  48. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Newtonsoft.Json.Bson.dll +0 -0
  49. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Newtonsoft.Json.dll +0 -0
  50. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll +0 -0
  51. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.Client.dll.config +0 -0
  52. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll +0 -0
  53. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.AutoUpdate.DataTransferLibrary.dll.config +0 -0
  54. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.Lang.dll +0 -0
  55. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.Lang.xml +0 -0
  56. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.Plugins.dll +0 -0
  57. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.Plugins.xml +0 -0
  58. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.UI.dll +0 -0
  59. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.UI.xml +0 -0
  60. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.dll +0 -0
  61. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SIMULTAN.xml +0 -0
  62. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.D3DCompiler.dll +0 -0
  63. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.DXGI.dll +0 -0
  64. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.Direct2D1.dll +0 -0
  65. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.Direct3D11.dll +0 -0
  66. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.Direct3D9.dll +0 -0
  67. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.Mathematics.dll +0 -0
  68. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/SharpDX.dll +0 -0
  69. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Sprache.Calc.dll +0 -0
  70. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/Sprache.dll +0 -0
  71. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/System.Collections.Immutable.dll +0 -0
  72. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/System.Data.OleDb.dll +0 -0
  73. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/System.Net.Http.Formatting.dll +0 -0
  74. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/System.Reflection.Metadata.dll +0 -0
  75. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/System.Reflection.MetadataLoadContext.dll +0 -0
  76. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/XAMLMarkupExtensions.dll +0 -0
  77. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/__init__.py +0 -0
  78. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/assimp.dll +0 -0
  79. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/componentmanager.user +0 -0
  80. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/defaultsettings.xml +0 -0
  81. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/resources/setup.bat +0 -0
  82. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/simultan_object.py +0 -0
  83. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/taxonomy_maps.py +0 -0
  84. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/src/PySimultan2/type_setter_lookup.py +0 -0
  85. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/__init__.py +0 -0
  86. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/__init__.py +0 -0
  87. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/create_component.py +0 -0
  88. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/create_component_with_taxonomy_slot.py +0 -0
  89. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/create_referenced_component.py +0 -0
  90. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/create_taxonomies.py +0 -0
  91. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/__init__.py +0 -0
  92. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/change_references_example.simultan +0 -0
  93. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/empty_project.simultan +0 -0
  94. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/empty_test_excel.xlsx +0 -0
  95. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/example1.simultan +0 -0
  96. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/example2.simultan +0 -0
  97. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/example3.simultan +0 -0
  98. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/example4_reference_list.simultan +0 -0
  99. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/example_extend_1.simultan +0 -0
  100. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/list_test.simultan +0 -0
  101. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example3.yml +0 -0
  102. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example4.yml +0 -0
  103. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example_create_typed_component.yml +0 -0
  104. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example_create_typed_component_with_slots.yml +0 -0
  105. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example_extend.yml +0 -0
  106. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_example_update_references.yml +0 -0
  107. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/readme_examples/resources/template_reference_list.yml +0 -0
  108. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/U5.simultan +0 -0
  109. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/U5_1.simultan +0 -0
  110. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/U5_orig.simultan +0 -0
  111. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/__init__.py +0 -0
  112. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/new_geometry_test.simultan +0 -0
  113. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/new_test_file.txt +0 -0
  114. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/new_test_file2.txt +0 -0
  115. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_file.yml +0 -0
  116. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_file_load.simultan +0 -0
  117. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_file_project.simultan +0 -0
  118. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_multi_value_big_table_load.simultan +0 -0
  119. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_parameter_reference_project.simultan +0 -0
  120. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/resources/test_set_dictionary.simultan +0 -0
  121. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_calc_static_zone_temperature.py +0 -0
  122. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_calculate_steady_state_temperature.py +0 -0
  123. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_circular_references.py +0 -0
  124. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_create_geometry.py +0 -0
  125. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_files.py +0 -0
  126. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_files_load.py +0 -0
  127. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_load_geometry.py +0 -0
  128. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_load_multi_values.py +0 -0
  129. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_new_dll.py +0 -0
  130. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_new_project_creation.py +0 -0
  131. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_numeric_map.py +0 -0
  132. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_parameter_reference.py +0 -0
  133. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_pythonnet.py +0 -0
  134. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_register_class.py +0 -0
  135. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_set_attr_property.py +0 -0
  136. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_set_dictionary.py +0 -0
  137. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_set_properties.py +0 -0
  138. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_taxonomie_maps.py +0 -0
  139. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_taxonomies.py +0 -0
  140. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/tests/test_ui.py +0 -0
  141. {pysimultan-0.5.0 → pysimultan-0.5.2.5}/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.0
3
+ Version: 0.5.2.5
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
@@ -0,0 +1,4 @@
1
+ Version 0.5.1 (25.11.2024)
2
+
3
+ - setting re-register default in Mapper to True
4
+ - added uncache method to utils for monkey patching
@@ -0,0 +1 @@
1
+ version = '0.5.2.5'
@@ -1,14 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
- import xxsubtype
4
3
  from collections.abc import Iterable
5
4
  import numpy as np
6
- import pandas as pd
7
5
  import colorlog
8
6
  from typing import Union, List, Type, Set, Tuple, Any, Optional
9
7
 
10
- from reactivex import return_value
11
-
12
8
  from .utils import (sort_slots, create_simultan_component_for_taxonomy, create_mapped_python_object,
13
9
  set_property_to_sim_component, set_property_to_parameter, set_property_to_file_info,
14
10
  set_property_to_list, set_property_to_value_field, set_property_to_unknown_type,
@@ -32,9 +32,21 @@ default_taxonomy_maps = {'ComponentList': component_list_map,
32
32
 
33
33
  class PythonMapper(object):
34
34
 
35
+ mappers = {}
36
+
35
37
  def __new__(cls, *args, **kwargs):
36
38
  instance = super(PythonMapper, cls).__new__(cls)
37
39
  config.set_default_mapper(instance)
40
+
41
+ if kwargs.get('add_to_mappers', True):
42
+ initial_module_name = kwargs.get('module', 'unknown_module')
43
+ module_name = initial_module_name
44
+ i = 0
45
+ while module_name in cls.mappers.keys():
46
+ module_name = f'{initial_module_name}_{i}'
47
+ i+=1
48
+ cls.mappers[module_name] = instance
49
+
38
50
  return instance
39
51
 
40
52
  def __init__(self, *args, **kwargs):
@@ -42,6 +54,9 @@ class PythonMapper(object):
42
54
  self._mapped_classes = {}
43
55
 
44
56
  self.name = kwargs.get('name', 'PythonMapper')
57
+ self._module = kwargs.get('module', 'unknown_module')
58
+ self.submodules = kwargs.get('submodules', {})
59
+
45
60
  self.registered_classes: dict[str: SimultanObject] = copy(default_registered_classes) # dict with all registered classes: {taxonomy: class}
46
61
 
47
62
  self.undefined_registered_classes: dict[str: SimultanObject] = {} # dict with all registered classes: {taxonomy: class}
@@ -59,6 +74,18 @@ class PythonMapper(object):
59
74
  self.re_register = False
60
75
  self.load_undefined = False
61
76
 
77
+ @property
78
+ def module(self):
79
+ return self._module
80
+
81
+ @module.setter
82
+ def module(self, value):
83
+ if self._module != value:
84
+ del self.mappers[self._module]
85
+
86
+ self._module = value
87
+ self.mappers[value] = self
88
+
62
89
  @property
63
90
  def mapped_classes(self):
64
91
  if len(self.registered_classes) > len(self._mapped_classes):
@@ -73,10 +100,14 @@ class PythonMapper(object):
73
100
  self._mapped_classes = value
74
101
 
75
102
  def register(self,
76
- taxonomy,
77
- cls,
78
- re_register=False,
103
+ taxonomy: str,
104
+ cls: Type[Any],
105
+ re_register=True,
106
+ update_in_other_mappers=False,
79
107
  taxonomy_map=None):
108
+
109
+ # print(f'Registering {taxonomy} with {cls} {hash(cls)}')
110
+
80
111
  if not (self.re_register or re_register) and taxonomy in self.registered_classes.keys():
81
112
  return
82
113
 
@@ -95,8 +126,28 @@ class PythonMapper(object):
95
126
  self.registered_classes[taxonomy] = cls
96
127
  self.taxonomy_maps[taxonomy] = taxonomy_map
97
128
 
129
+ if update_in_other_mappers:
130
+ self.update_from_other_mappers()
131
+
98
132
  return self.get_mapped_class(taxonomy)
99
133
 
134
+ def update_from_other_mappers(self):
135
+ for mapper in self.mappers.values():
136
+ if mapper is not self:
137
+ for cls, taxonomy in mapper.registered_classes.items():
138
+ if cls in self.registered_classes.values():
139
+ key = list(filter(lambda x: mapper.registered_classes[x] == cls,
140
+ mapper.registered_classes)
141
+ )[0]
142
+ mapper.registered_classes[key] = cls
143
+ print(f'Updated {cls} in {mapper.module} with {taxonomy}')
144
+
145
+ def update_from_submodules(self):
146
+ for submodule in self.submodules.values():
147
+ self.registered_classes.update(submodule.registered_classes)
148
+ self.taxonomy_maps.update(submodule.taxonomy_maps)
149
+ self.registered_geometry_classes.update(submodule.registered_geometry_classes)
150
+
100
151
  def create_mapped_class(self, taxonomy, cls):
101
152
 
102
153
  if any([issubclass(cls, x) for x in (SimultanObject, UserList)]):
@@ -342,19 +393,31 @@ class PythonMapper(object):
342
393
  def copy(self,
343
394
  *args,
344
395
  **kwargs) -> 'PythonMapper':
345
- new_mapper = PythonMapper()
396
+
397
+ orig_new_module_name = kwargs.get('module', self.module)
398
+ new_module_name = orig_new_module_name
399
+ i = 0
400
+ while new_module_name in self.mappers.keys():
401
+ new_module_name = f'copy_{i}_of_{new_module_name}'
402
+ i+=1
403
+
404
+ new_mapper = PythonMapper(add_to_mappers=kwargs.get('add_to_mappers', True),
405
+ module=new_module_name)
346
406
  new_mapper.registered_classes = self.registered_classes
347
407
  new_mapper.taxonomy_maps = self.taxonomy_maps
348
408
  new_mapper.registered_geometry_classes = self.registered_geometry_classes
349
409
  new_mapper.load_undefined = self.load_undefined
410
+
350
411
  return new_mapper
351
412
 
352
413
  def __add__(self, other: 'PythonMapper') -> 'PythonMapper':
353
- new_mapper = self.copy()
354
- new_mapper.registered_classes.update(other.registered_classes)
355
- new_mapper.taxonomy_maps.update(other.taxonomy_maps)
356
- new_mapper.registered_geometry_classes.update(other.registered_geometry_classes)
357
- return new_mapper
414
+ # new_mapper = self.copy(add_to_mappers=True)
415
+ self.submodules[other.module] = other
416
+ self.submodules.update(other.submodules)
417
+ self.registered_classes.update(other.registered_classes)
418
+ self.taxonomy_maps.update(other.taxonomy_maps)
419
+ self.registered_geometry_classes.update(other.registered_geometry_classes)
420
+ return self
358
421
 
359
422
  def get_mapped_class_for_python_type(self, python_type: type) -> Optional[Type[SimultanObject]]:
360
423
  try:
@@ -366,6 +429,29 @@ class PythonMapper(object):
366
429
  except IndexError:
367
430
  return None
368
431
 
432
+ def __repr__(self):
433
+ return f'PythonMapper(module={self.module}, {len(self.registered_classes)} registered classes)'
434
+
369
435
 
370
436
  if config.get_default_mapper() is None:
371
- config.set_default_mapper(PythonMapper())
437
+ config.set_default_mapper(PythonMapper(module='default'))
438
+
439
+
440
+ def register(taxonomy: str,
441
+ taxonomy_map: TaxonomyMap,
442
+ re_register=True,
443
+ module: str = 'unknown_module') -> Any:
444
+
445
+ if module not in PythonMapper.mappers.keys():
446
+ PythonMapper(module=module)
447
+
448
+ mapper = PythonMapper.mappers[module]
449
+
450
+ def decorator(cls):
451
+ mapper.register(taxonomy,
452
+ cls,
453
+ re_register=re_register,
454
+ taxonomy_map=taxonomy_map)
455
+ return cls
456
+
457
+ return decorator
@@ -1448,3 +1448,33 @@ def add_properties(prop_name: str,
1448
1448
  delx.__taxonomy__ = taxonomy
1449
1449
 
1450
1450
  return property(getx, setx, delx, "automatic created property")
1451
+
1452
+
1453
+ def uncache(exclude):
1454
+ """Remove package modules from cache except excluded ones.
1455
+ On next import they will be reloaded.
1456
+
1457
+ Args:
1458
+ exclude (iter<str>): Sequence of module paths.
1459
+ """
1460
+ pkgs = []
1461
+ for mod in exclude:
1462
+ pkg = mod.split('.', 1)[0]
1463
+ pkgs.append(pkg)
1464
+
1465
+ to_uncache = []
1466
+ for mod in sys.modules:
1467
+ if mod in exclude:
1468
+ continue
1469
+
1470
+ if mod in pkgs:
1471
+ to_uncache.append(mod)
1472
+ continue
1473
+
1474
+ for pkg in pkgs:
1475
+ if mod.startswith(pkg + '.'):
1476
+ to_uncache.append(mod)
1477
+ break
1478
+
1479
+ for mod in to_uncache:
1480
+ del sys.modules[mod]
@@ -0,0 +1,41 @@
1
+ from PySimultan2.taxonomy_maps import TaxonomyMap, Content
2
+ from PySimultan2.object_mapper import register
3
+ from PySimultan2 import PythonMapper
4
+
5
+
6
+ content_a = Content(text_or_key='a',
7
+ property_name='a',
8
+ type=None,
9
+ unit=None,
10
+ documentation='Property a',)
11
+
12
+ content_b = Content(text_or_key='b',
13
+ property_name='b',
14
+ type=None,
15
+ unit=None,
16
+ documentation='Property a',)
17
+
18
+ test_map = TaxonomyMap(taxonomy_name='Test',
19
+ taxonomy_key='Test',
20
+ taxonomy_entry_name='TestClass',
21
+ taxonomy_entry_key='TestClass',
22
+ content=[content_a, content_b],
23
+ )
24
+
25
+ @register(test_map.taxonomy_entry_key, taxonomy_map=test_map, re_register=True, module='test_mapper')
26
+ class TestClass(object):
27
+
28
+ def __init__(self, *args, **kwargs):
29
+ self.a = kwargs.get('a', 1)
30
+ self.b = kwargs.get('b', 2)
31
+
32
+ def add(self):
33
+ return self.a + self.b
34
+
35
+ def __repr__(self):
36
+ return f'TestClass(a={self.a}, b={self.b})'
37
+
38
+
39
+
40
+ mapped_test_cls = PythonMapper.mappers['test_mapper'].get_mapped_class('TestClass')
41
+ print(mapped_test_cls)
@@ -1 +0,0 @@
1
- version = '0.5.0'
File without changes
File without changes
File without changes
File without changes