s2-python 0.2.0__tar.gz → 0.2.0.dev2__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 (76) hide show
  1. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/PKG-INFO +2 -3
  2. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/setup.cfg +2 -3
  3. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/PKG-INFO +2 -3
  4. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/SOURCES.txt +0 -4
  5. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/requires.txt +1 -2
  6. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/duration.py +3 -3
  7. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/handshake.py +3 -3
  8. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/handshake_response.py +3 -3
  9. s2_python-0.2.0.dev2/src/s2python/common/instruction_status_update.py +22 -0
  10. s2_python-0.2.0.dev2/src/s2python/common/number_range.py +39 -0
  11. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/power_forecast.py +6 -4
  12. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/power_forecast_element.py +5 -5
  13. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/power_forecast_value.py +2 -2
  14. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/power_measurement.py +4 -4
  15. s2_python-0.2.0.dev2/src/s2python/common/power_range.py +27 -0
  16. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/power_value.py +2 -2
  17. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/reception_status.py +5 -3
  18. s2_python-0.2.0.dev2/src/s2python/common/resource_manager_details.py +27 -0
  19. s2_python-0.2.0.dev2/src/s2python/common/revoke_object.py +16 -0
  20. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/role.py +2 -2
  21. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/select_control_type.py +3 -3
  22. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/session_request.py +3 -3
  23. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/timer.py +4 -4
  24. s2_python-0.2.0.dev2/src/s2python/common/transition.py +26 -0
  25. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_actuator_description.py +79 -52
  26. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_actuator_status.py +8 -8
  27. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_fill_level_target_profile.py +30 -0
  28. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_fill_level_target_profile_element.py +7 -5
  29. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_instruction.py +18 -0
  30. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_leakage_behaviour.py +5 -5
  31. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_leakage_behaviour_element.py +7 -5
  32. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_operation_mode.py +27 -16
  33. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_operation_mode_element.py +12 -10
  34. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_storage_description.py +20 -0
  35. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_storage_status.py +3 -3
  36. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_system_description.py +26 -0
  37. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_timer_status.py +17 -0
  38. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/frbc_usage_forecast.py +6 -4
  39. s2_python-0.2.0.dev2/src/s2python/frbc/frbc_usage_forecast_element.py +19 -0
  40. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/generated/gen_s2.py +327 -344
  41. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/s2_parser.py +8 -8
  42. s2_python-0.2.0.dev2/src/s2python/s2_validation_error.py +13 -0
  43. s2_python-0.2.0.dev2/src/s2python/validate_values_mixin.py +148 -0
  44. s2_python-0.2.0.dev2/src/s2python/version.py +1 -0
  45. s2_python-0.2.0/src/s2python/common/instruction_status_update.py +0 -18
  46. s2_python-0.2.0/src/s2python/common/number_range.py +0 -32
  47. s2_python-0.2.0/src/s2python/common/power_range.py +0 -22
  48. s2_python-0.2.0/src/s2python/common/resource_manager_details.py +0 -25
  49. s2_python-0.2.0/src/s2python/common/revoke_object.py +0 -16
  50. s2_python-0.2.0/src/s2python/common/transition.py +0 -24
  51. s2_python-0.2.0/src/s2python/frbc/frbc_fill_level_target_profile.py +0 -24
  52. s2_python-0.2.0/src/s2python/frbc/frbc_instruction.py +0 -18
  53. s2_python-0.2.0/src/s2python/frbc/frbc_storage_description.py +0 -18
  54. s2_python-0.2.0/src/s2python/frbc/frbc_system_description.py +0 -22
  55. s2_python-0.2.0/src/s2python/frbc/frbc_timer_status.py +0 -17
  56. s2_python-0.2.0/src/s2python/frbc/frbc_usage_forecast_element.py +0 -17
  57. s2_python-0.2.0/src/s2python/frbc/rm.py +0 -0
  58. s2_python-0.2.0/src/s2python/reception_status_awaiter.py +0 -60
  59. s2_python-0.2.0/src/s2python/s2_connection.py +0 -470
  60. s2_python-0.2.0/src/s2python/s2_control_type.py +0 -56
  61. s2_python-0.2.0/src/s2python/s2_validation_error.py +0 -13
  62. s2_python-0.2.0/src/s2python/validate_values_mixin.py +0 -70
  63. s2_python-0.2.0/src/s2python/version.py +0 -3
  64. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/README.rst +0 -0
  65. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/pyproject.toml +0 -0
  66. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/setup.py +0 -0
  67. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/dependency_links.txt +0 -0
  68. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/entry_points.txt +0 -0
  69. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/not-zip-safe +0 -0
  70. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2_python.egg-info/top_level.txt +0 -0
  71. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/__init__.py +0 -0
  72. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/__init__.py +1 -1
  73. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/common/support.py +0 -0
  74. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/frbc/__init__.py +0 -0
  75. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/generated/__init__.py +0 -0
  76. {s2_python-0.2.0 → s2_python-0.2.0.dev2}/src/s2python/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: s2-python
3
- Version: 0.2.0
3
+ Version: 0.2.0.dev2
4
4
  Summary: S2 Protocol Python Wrapper
5
5
  Home-page: https://github.com/flexiblepower/s2-ws-json-python
6
6
  Author: Flexiblepower
@@ -14,10 +14,9 @@ Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Description-Content-Type: text/x-rst; charset=UTF-8
17
- Requires-Dist: pydantic~=2.8.2
17
+ Requires-Dist: pydantic~=1.10.7
18
18
  Requires-Dist: pytz
19
19
  Requires-Dist: click
20
- Requires-Dist: websockets~=13.0.1
21
20
  Provides-Extra: testing
22
21
  Requires-Dist: pytest; extra == "testing"
23
22
  Requires-Dist: pytest-coverage; extra == "testing"
@@ -8,7 +8,7 @@ license_files = LICENSE.txt
8
8
  long_description = file: README.rst
9
9
  long_description_content_type = text/x-rst; charset=UTF-8
10
10
  url = https://github.com/flexiblepower/s2-ws-json-python
11
- version = 0.2.0
11
+ version = 0.2.0.dev2
12
12
  platforms = Linux
13
13
  classifiers =
14
14
  Development Status :: 4 - Beta
@@ -26,10 +26,9 @@ package_dir =
26
26
  =src
27
27
  python_requires > = 3.8, <= 3.12
28
28
  install_requires =
29
- pydantic~=2.8.2
29
+ pydantic~=1.10.7
30
30
  pytz
31
31
  click
32
- websockets~=13.0.1
33
32
 
34
33
  [options.packages.find]
35
34
  where = src
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: s2-python
3
- Version: 0.2.0
3
+ Version: 0.2.0.dev2
4
4
  Summary: S2 Protocol Python Wrapper
5
5
  Home-page: https://github.com/flexiblepower/s2-ws-json-python
6
6
  Author: Flexiblepower
@@ -14,10 +14,9 @@ Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Description-Content-Type: text/x-rst; charset=UTF-8
17
- Requires-Dist: pydantic~=2.8.2
17
+ Requires-Dist: pydantic~=1.10.7
18
18
  Requires-Dist: pytz
19
19
  Requires-Dist: click
20
- Requires-Dist: websockets~=13.0.1
21
20
  Provides-Extra: testing
22
21
  Requires-Dist: pytest; extra == "testing"
23
22
  Requires-Dist: pytest-coverage; extra == "testing"
@@ -10,9 +10,6 @@ src/s2_python.egg-info/not-zip-safe
10
10
  src/s2_python.egg-info/requires.txt
11
11
  src/s2_python.egg-info/top_level.txt
12
12
  src/s2python/__init__.py
13
- src/s2python/reception_status_awaiter.py
14
- src/s2python/s2_connection.py
15
- src/s2python/s2_control_type.py
16
13
  src/s2python/s2_parser.py
17
14
  src/s2python/s2_validation_error.py
18
15
  src/s2python/utils.py
@@ -55,6 +52,5 @@ src/s2python/frbc/frbc_system_description.py
55
52
  src/s2python/frbc/frbc_timer_status.py
56
53
  src/s2python/frbc/frbc_usage_forecast.py
57
54
  src/s2python/frbc/frbc_usage_forecast_element.py
58
- src/s2python/frbc/rm.py
59
55
  src/s2python/generated/__init__.py
60
56
  src/s2python/generated/gen_s2.py
@@ -1,7 +1,6 @@
1
- pydantic~=2.8.2
1
+ pydantic~=1.10.7
2
2
  pytz
3
3
  click
4
- websockets~=13.0.1
5
4
 
6
5
  [development]
7
6
  pip-tools
@@ -11,12 +11,12 @@ from s2python.validate_values_mixin import (
11
11
  @catch_and_convert_exceptions
12
12
  class Duration(GenDuration, S2Message["Duration"]):
13
13
  def to_timedelta(self) -> timedelta:
14
- return timedelta(milliseconds=self.root)
14
+ return timedelta(milliseconds=self.__root__)
15
15
 
16
16
  @staticmethod
17
17
  def from_timedelta(duration: timedelta) -> "Duration":
18
- return Duration(root=math.ceil(duration.total_seconds() * 1000))
18
+ return Duration(__root__=math.ceil(duration.total_seconds() * 1000))
19
19
 
20
20
  @staticmethod
21
21
  def from_milliseconds(milliseconds: int) -> "Duration":
22
- return Duration(root=milliseconds)
22
+ return Duration(__root__=milliseconds)
@@ -9,7 +9,7 @@ from s2python.validate_values_mixin import (
9
9
 
10
10
  @catch_and_convert_exceptions
11
11
  class Handshake(GenHandshake, S2Message["Handshake"]):
12
- model_config = GenHandshake.model_config
13
- model_config["validate_assignment"] = True
12
+ class Config(GenHandshake.Config):
13
+ validate_assignment = True
14
14
 
15
- message_id: uuid.UUID = GenHandshake.model_fields["message_id"] # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenHandshake.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -9,7 +9,7 @@ from s2python.validate_values_mixin import (
9
9
 
10
10
  @catch_and_convert_exceptions
11
11
  class HandshakeResponse(GenHandshakeResponse, S2Message["HandshakeResponse"]):
12
- model_config = GenHandshakeResponse.model_config
13
- model_config["validate_assignment"] = True
12
+ class Config(GenHandshakeResponse.Config):
13
+ validate_assignment = True
14
14
 
15
- message_id: uuid.UUID = GenHandshakeResponse.model_fields["message_id"] # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenHandshakeResponse.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -0,0 +1,22 @@
1
+ import uuid
2
+
3
+ from s2python.generated.gen_s2 import (
4
+ InstructionStatusUpdate as GenInstructionStatusUpdate,
5
+ )
6
+ from s2python.validate_values_mixin import (
7
+ catch_and_convert_exceptions,
8
+ S2Message,
9
+ )
10
+
11
+
12
+ @catch_and_convert_exceptions
13
+ class InstructionStatusUpdate(
14
+ GenInstructionStatusUpdate, S2Message["InstructionStatusUpdate"]
15
+ ):
16
+ class Config(GenInstructionStatusUpdate.Config):
17
+ validate_assignment = True
18
+
19
+ message_id: uuid.UUID = GenInstructionStatusUpdate.__fields__["message_id"].field_info # type: ignore[assignment]
20
+ instruction_id: uuid.UUID = GenInstructionStatusUpdate.__fields__[
21
+ "instruction_id"
22
+ ].field_info # type: ignore[assignment]
@@ -0,0 +1,39 @@
1
+ from typing import Any, Dict
2
+
3
+ from pydantic import root_validator
4
+
5
+ from s2python.validate_values_mixin import (
6
+ S2Message,
7
+ catch_and_convert_exceptions,
8
+ )
9
+ from s2python.generated.gen_s2 import NumberRange as GenNumberRange
10
+
11
+
12
+ @catch_and_convert_exceptions
13
+ class NumberRange(GenNumberRange, S2Message["NumberRange"]):
14
+ class Config(GenNumberRange.Config):
15
+ validate_assignment = True
16
+
17
+ @root_validator(pre=False)
18
+ @classmethod
19
+ def validate_start_end_order( # pylint: disable=duplicate-code
20
+ cls, values: Dict[str, Any]
21
+ ) -> Dict[str, Any]:
22
+ if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
23
+ raise ValueError(
24
+ cls, "start_of_range should not be higher than end_of_range"
25
+ )
26
+
27
+ return values
28
+
29
+ def __hash__(self) -> int:
30
+ return hash(f"{self.start_of_range}|{self.end_of_range}")
31
+
32
+ def __eq__(self, other: Any) -> bool:
33
+ if isinstance(other, NumberRange):
34
+ return (
35
+ self.start_of_range == other.start_of_range
36
+ and self.end_of_range == other.end_of_range
37
+ )
38
+
39
+ return False
@@ -11,8 +11,10 @@ from s2python.validate_values_mixin import (
11
11
 
12
12
  @catch_and_convert_exceptions
13
13
  class PowerForecast(GenPowerForecast, S2Message["PowerForecast"]):
14
- model_config = GenPowerForecast.model_config
15
- model_config["validate_assignment"] = True
14
+ class Config(GenPowerForecast.Config):
15
+ validate_assignment = True
16
16
 
17
- message_id: uuid.UUID = GenPowerForecast.model_fields["message_id"] # type: ignore[assignment]
18
- elements: List[PowerForecastElement] = GenPowerForecast.model_fields["elements"] # type: ignore[assignment]
17
+ message_id: uuid.UUID = GenPowerForecast.__fields__["message_id"].field_info # type: ignore[assignment]
18
+ elements: List[PowerForecastElement] = GenPowerForecast.__fields__[
19
+ "elements"
20
+ ].field_info # type: ignore[assignment]
@@ -11,10 +11,10 @@ from s2python.common.power_forecast_value import PowerForecastValue
11
11
 
12
12
  @catch_and_convert_exceptions
13
13
  class PowerForecastElement(GenPowerForecastElement, S2Message["PowerForecastElement"]):
14
- model_config = GenPowerForecastElement.model_config
15
- model_config["validate_assignment"] = True
14
+ class Config(GenPowerForecastElement.Config):
15
+ validate_assignment = True
16
16
 
17
- duration: Duration = GenPowerForecastElement.model_fields["duration"] # type: ignore[assignment]
18
- power_values: List[PowerForecastValue] = GenPowerForecastElement.model_fields[
17
+ duration: Duration = GenPowerForecastElement.__fields__["duration"].field_info # type: ignore[assignment]
18
+ power_values: List[PowerForecastValue] = GenPowerForecastElement.__fields__[
19
19
  "power_values"
20
- ] # type: ignore[assignment]
20
+ ].field_info # type: ignore[assignment]
@@ -7,5 +7,5 @@ from s2python.validate_values_mixin import (
7
7
 
8
8
  @catch_and_convert_exceptions
9
9
  class PowerForecastValue(GenPowerForecastValue, S2Message["PowerForecastValue"]):
10
- model_config = GenPowerForecastValue.model_config
11
- model_config["validate_assignment"] = True
10
+ class Config(GenPowerForecastValue.Config):
11
+ validate_assignment = True
@@ -11,8 +11,8 @@ from s2python.validate_values_mixin import (
11
11
 
12
12
  @catch_and_convert_exceptions
13
13
  class PowerMeasurement(GenPowerMeasurement, S2Message["PowerMeasurement"]):
14
- model_config = GenPowerMeasurement.model_config
15
- model_config["validate_assignment"] = True
14
+ class Config(GenPowerMeasurement.Config):
15
+ validate_assignment = True
16
16
 
17
- message_id: uuid.UUID = GenPowerMeasurement.model_fields["message_id"] # type: ignore[assignment]
18
- values: List[PowerValue] = GenPowerMeasurement.model_fields["values"] # type: ignore[assignment]
17
+ message_id: uuid.UUID = GenPowerMeasurement.__fields__["message_id"].field_info # type: ignore[assignment]
18
+ values: List[PowerValue] = GenPowerMeasurement.__fields__["values"].field_info # type: ignore[assignment]
@@ -0,0 +1,27 @@
1
+ from typing import Any, Dict
2
+
3
+ from pydantic import root_validator
4
+
5
+ from s2python.generated.gen_s2 import PowerRange as GenPowerRange
6
+ from s2python.validate_values_mixin import (
7
+ S2Message,
8
+ catch_and_convert_exceptions,
9
+ )
10
+
11
+
12
+ @catch_and_convert_exceptions
13
+ class PowerRange(GenPowerRange, S2Message["PowerRange"]):
14
+ class Config(GenPowerRange.Config):
15
+ validate_assignment = True
16
+
17
+ @root_validator(pre=False)
18
+ @classmethod
19
+ def validate_start_end_order(
20
+ cls, values: Dict[str, Any]
21
+ ) -> Dict[str, Any]: # pylint: disable=duplicate-code
22
+ if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
23
+ raise ValueError(
24
+ cls, "start_of_range should not be higher than end_of_range"
25
+ )
26
+
27
+ return values
@@ -7,5 +7,5 @@ from s2python.validate_values_mixin import (
7
7
 
8
8
  @catch_and_convert_exceptions
9
9
  class PowerValue(GenPowerValue, S2Message["PowerValue"]):
10
- model_config = GenPowerValue.model_config
11
- model_config["validate_assignment"] = True
10
+ class Config(GenPowerValue.Config):
11
+ validate_assignment = True
@@ -9,7 +9,9 @@ from s2python.validate_values_mixin import (
9
9
 
10
10
  @catch_and_convert_exceptions
11
11
  class ReceptionStatus(GenReceptionStatus, S2Message["ReceptionStatus"]):
12
- model_config = GenReceptionStatus.model_config
13
- model_config["validate_assignment"] = True
12
+ class Config(GenReceptionStatus.Config):
13
+ validate_assignment = True
14
14
 
15
- subject_message_id: uuid.UUID = GenReceptionStatus.model_fields["subject_message_id"] # type: ignore[assignment]
15
+ subject_message_id: uuid.UUID = GenReceptionStatus.__fields__[
16
+ "subject_message_id"
17
+ ].field_info # type: ignore[assignment]
@@ -0,0 +1,27 @@
1
+ from typing import List
2
+ import uuid
3
+
4
+ from s2python.common.duration import Duration
5
+ from s2python.common.role import Role
6
+ from s2python.generated.gen_s2 import (
7
+ ResourceManagerDetails as GenResourceManagerDetails,
8
+ )
9
+ from s2python.validate_values_mixin import (
10
+ catch_and_convert_exceptions,
11
+ S2Message,
12
+ )
13
+
14
+
15
+ @catch_and_convert_exceptions
16
+ class ResourceManagerDetails(
17
+ GenResourceManagerDetails, S2Message["ResourceManagerDetails"]
18
+ ):
19
+ class Config(GenResourceManagerDetails.Config):
20
+ validate_assignment = True
21
+
22
+ instruction_processing_delay: Duration = GenResourceManagerDetails.__fields__[
23
+ "instruction_processing_delay"
24
+ ].field_info # type: ignore[assignment]
25
+ message_id: uuid.UUID = GenResourceManagerDetails.__fields__["message_id"].field_info # type: ignore[assignment]
26
+ resource_id: uuid.UUID = GenResourceManagerDetails.__fields__["resource_id"].field_info # type: ignore[assignment]
27
+ roles: List[Role] = GenResourceManagerDetails.__fields__["roles"].field_info # type: ignore[assignment]
@@ -0,0 +1,16 @@
1
+ import uuid
2
+
3
+ from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
8
+
9
+
10
+ @catch_and_convert_exceptions
11
+ class RevokeObject(GenRevokeObject, S2Message["RevokeObject"]):
12
+ class Config(GenRevokeObject.Config):
13
+ validate_assignment = True
14
+
15
+ message_id: uuid.UUID = GenRevokeObject.__fields__["message_id"].field_info # type: ignore[assignment]
16
+ object_id: uuid.UUID = GenRevokeObject.__fields__["object_id"].field_info # type: ignore[assignment]
@@ -7,5 +7,5 @@ from s2python.validate_values_mixin import (
7
7
 
8
8
  @catch_and_convert_exceptions
9
9
  class Role(GenRole, S2Message["Role"]):
10
- model_config = GenRole.model_config
11
- model_config["validate_assignment"] = True
10
+ class Config(GenRole.Config):
11
+ validate_assignment = True
@@ -9,7 +9,7 @@ from s2python.validate_values_mixin import (
9
9
 
10
10
  @catch_and_convert_exceptions
11
11
  class SelectControlType(GenSelectControlType, S2Message["SelectControlType"]):
12
- model_config = GenSelectControlType.model_config
13
- model_config["validate_assignment"] = True
12
+ class Config(GenSelectControlType.Config):
13
+ validate_assignment = True
14
14
 
15
- message_id: uuid.UUID = GenSelectControlType.model_fields["message_id"] # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenSelectControlType.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -9,7 +9,7 @@ from s2python.validate_values_mixin import (
9
9
 
10
10
  @catch_and_convert_exceptions
11
11
  class SessionRequest(GenSessionRequest, S2Message["SessionRequest"]):
12
- model_config = GenSessionRequest.model_config
13
- model_config["validate_assignment"] = True
12
+ class Config(GenSessionRequest.Config):
13
+ validate_assignment = True
14
14
 
15
- message_id: uuid.UUID = GenSessionRequest.model_fields["message_id"] # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenSessionRequest.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -10,8 +10,8 @@ from s2python.validate_values_mixin import (
10
10
 
11
11
  @catch_and_convert_exceptions
12
12
  class Timer(GenTimer, S2Message["Timer"]):
13
- model_config = GenTimer.model_config
14
- model_config["validate_assignment"] = True
13
+ class Config(GenTimer.Config):
14
+ validate_assignment = True
15
15
 
16
- id: uuid.UUID = GenTimer.model_fields["id"] # type: ignore[assignment]
17
- duration: Duration = GenTimer.model_fields["duration"] # type: ignore[assignment]
16
+ id: uuid.UUID = GenTimer.__fields__["id"].field_info # type: ignore[assignment]
17
+ duration: Duration = GenTimer.__fields__["duration"].field_info # type: ignore[assignment]
@@ -0,0 +1,26 @@
1
+ import uuid
2
+ from typing import Optional, List
3
+
4
+ from s2python.common.duration import Duration
5
+ from s2python.generated.gen_s2 import Transition as GenTransition
6
+ from s2python.validate_values_mixin import (
7
+ S2Message,
8
+ catch_and_convert_exceptions,
9
+ )
10
+
11
+
12
+ @catch_and_convert_exceptions
13
+ class Transition(GenTransition, S2Message["Transition"]):
14
+ class Config(GenTransition.Config):
15
+ validate_assignment = True
16
+
17
+ id: uuid.UUID = GenTransition.__fields__["id"].field_info # type: ignore[assignment]
18
+ from_: uuid.UUID = GenTransition.__fields__["from_"].field_info # type: ignore[assignment]
19
+ to: uuid.UUID = GenTransition.__fields__["to"].field_info # type: ignore[assignment]
20
+ start_timers: List[uuid.UUID] = GenTransition.__fields__["start_timers"].field_info # type: ignore[assignment]
21
+ blocking_timers: List[uuid.UUID] = GenTransition.__fields__[
22
+ "blocking_timers"
23
+ ].field_info # type: ignore[assignment]
24
+ transition_duration: Optional[Duration] = GenTransition.__fields__[
25
+ "transition_duration"
26
+ ].field_info # type: ignore[assignment]
@@ -1,15 +1,15 @@
1
1
  import uuid
2
2
 
3
- from typing import List
4
- from typing_extensions import Self
3
+ from typing import List, Any, Dict
5
4
 
6
- from pydantic import model_validator
5
+ from pydantic import root_validator
7
6
 
8
7
  from s2python.common import Transition, Timer, Commodity
9
8
  from s2python.common.support import commodity_has_quantity
10
9
  from s2python.frbc.frbc_operation_mode import FRBCOperationMode
11
10
  from s2python.generated.gen_s2 import (
12
11
  FRBCActuatorDescription as GenFRBCActuatorDescription,
12
+ CommodityQuantity,
13
13
  )
14
14
  from s2python.validate_values_mixin import (
15
15
  S2Message,
@@ -18,29 +18,34 @@ from s2python.validate_values_mixin import (
18
18
 
19
19
 
20
20
  @catch_and_convert_exceptions
21
- class FRBCActuatorDescription(GenFRBCActuatorDescription, S2Message["FRBCActuatorDescription"]):
22
- model_config = GenFRBCActuatorDescription.model_config
23
- model_config["validate_assignment"] = True
24
-
25
- id: uuid.UUID = GenFRBCActuatorDescription.model_fields["id"] # type: ignore[assignment]
26
- operation_modes: List[FRBCOperationMode] = GenFRBCActuatorDescription.model_fields[
21
+ class FRBCActuatorDescription(
22
+ GenFRBCActuatorDescription, S2Message["FRBCActuatorDescription"]
23
+ ):
24
+ class Config(GenFRBCActuatorDescription.Config):
25
+ validate_assignment = True
26
+
27
+ id: uuid.UUID = GenFRBCActuatorDescription.__fields__["id"].field_info # type: ignore[assignment]
28
+ operation_modes: List[FRBCOperationMode] = GenFRBCActuatorDescription.__fields__[
27
29
  "operation_modes"
28
- ] # type: ignore[assignment]
29
- transitions: List[Transition] = GenFRBCActuatorDescription.model_fields["transitions"] # type: ignore[assignment]
30
- timers: List[Timer] = GenFRBCActuatorDescription.model_fields["timers"] # type: ignore[assignment]
31
- supported_commodities: List[Commodity] = GenFRBCActuatorDescription.model_fields[
30
+ ].field_info # type: ignore[assignment]
31
+ transitions: List[Transition] = GenFRBCActuatorDescription.__fields__[
32
+ "transitions"
33
+ ].field_info # type: ignore[assignment]
34
+ timers: List[Timer] = GenFRBCActuatorDescription.__fields__["timers"].field_info # type: ignore[assignment]
35
+ supported_commodities: List[Commodity] = GenFRBCActuatorDescription.__fields__[
32
36
  "supported_commodities"
33
- ] # type: ignore[assignment]
37
+ ].field_info # type: ignore[assignment]
34
38
 
35
- @model_validator(mode="after")
36
- def validate_timers_in_transitions(self) -> Self:
37
- timers_by_id = {timer.id: timer for timer in self.timers}
39
+ @root_validator(pre=False)
40
+ @classmethod
41
+ def validate_timers_in_transitions(cls, values: Dict[str, Any]) -> Dict[str, Any]:
42
+ timers_by_id = {timer.id: timer for timer in values.get("timers", {})}
38
43
  transition: Transition
39
- for transition in self.transitions:
44
+ for transition in values.get("transitions", []):
40
45
  for start_timer_id in transition.start_timers:
41
46
  if start_timer_id not in timers_by_id:
42
47
  raise ValueError(
43
- self,
48
+ cls,
44
49
  f"{start_timer_id} was referenced as start timer in transition "
45
50
  f"{transition.id} but was not defined in 'timers'.",
46
51
  )
@@ -48,96 +53,118 @@ class FRBCActuatorDescription(GenFRBCActuatorDescription, S2Message["FRBCActuato
48
53
  for blocking_timer_id in transition.blocking_timers:
49
54
  if blocking_timer_id not in timers_by_id:
50
55
  raise ValueError(
51
- self,
56
+ cls,
52
57
  f"{blocking_timer_id} was referenced as blocking timer in transition "
53
58
  f"{transition.id} but was not defined in 'timers'.",
54
59
  )
55
60
 
56
- return self
61
+ return values
57
62
 
58
- @model_validator(mode="after")
59
- def validate_timers_unique_ids(self) -> Self:
63
+ @root_validator(pre=False)
64
+ @classmethod
65
+ def validate_timers_unique_ids(cls, values: Dict[str, Any]) -> Dict[str, Any]:
60
66
  ids = []
61
67
  timer: Timer
62
- for timer in self.timers:
68
+ for timer in values.get("timers", []):
63
69
  if timer.id in ids:
64
- raise ValueError(self, f"Id {timer.id} was found multiple times in 'timers'.")
70
+ raise ValueError(
71
+ cls, f"Id {timer.id} was found multiple times in 'timers'."
72
+ )
65
73
  ids.append(timer.id)
66
74
 
67
- return self
68
-
69
- @model_validator(mode="after")
70
- def validate_operation_modes_in_transitions(self) -> Self:
71
- operation_mode_by_id = {operation_mode.id: operation_mode for operation_mode in self.operation_modes}
75
+ return values
76
+
77
+ @root_validator(pre=False)
78
+ @classmethod
79
+ def validate_operation_modes_in_transitions(
80
+ cls, values: Dict[str, Any]
81
+ ) -> Dict[str, Any]:
82
+ operation_mode_by_id = {
83
+ operation_mode.id: operation_mode
84
+ for operation_mode in values.get("operation_modes", [])
85
+ }
72
86
  transition: Transition
73
- for transition in self.transitions:
87
+ for transition in values.get("transitions", []):
74
88
  if transition.from_ not in operation_mode_by_id:
75
89
  raise ValueError(
76
- self,
90
+ cls,
77
91
  f"Operation mode {transition.from_} was referenced as 'from' in transition "
78
92
  f"{transition.id} but was not defined in 'operation_modes'.",
79
93
  )
80
94
 
81
95
  if transition.to not in operation_mode_by_id:
82
96
  raise ValueError(
83
- self,
97
+ cls,
84
98
  f"Operation mode {transition.to} was referenced as 'to' in transition "
85
99
  f"{transition.id} but was not defined in 'operation_modes'.",
86
100
  )
87
101
 
88
- return self
102
+ return values
89
103
 
90
- @model_validator(mode="after")
91
- def validate_operation_modes_unique_ids(self) -> Self:
104
+ @root_validator(pre=False)
105
+ @classmethod
106
+ def validate_operation_modes_unique_ids(
107
+ cls, values: Dict[str, Any]
108
+ ) -> Dict[str, Any]:
92
109
  ids = []
93
110
  operation_mode: FRBCOperationMode
94
- for operation_mode in self.operation_modes:
111
+ for operation_mode in values.get("operation_modes", []):
95
112
  if operation_mode.id in ids:
96
113
  raise ValueError(
97
- self,
114
+ cls,
98
115
  f"Id {operation_mode.id} was found multiple times in 'operation_modes'.",
99
116
  )
100
117
  ids.append(operation_mode.id)
101
118
 
102
- return self
119
+ return values
103
120
 
104
- @model_validator(mode="after")
105
- def validate_operation_mode_elements_have_all_supported_commodities(self) -> Self:
106
- supported_commodities = self.supported_commodities
121
+ @root_validator(pre=False)
122
+ @classmethod
123
+ def validate_operation_mode_elements_have_all_supported_commodities(
124
+ cls, values: Dict[str, Any]
125
+ ) -> Dict[str, Any]:
126
+ supported_commodities = values.get("supported_commodities", [])
107
127
  operation_mode: FRBCOperationMode
108
- for operation_mode in self.operation_modes:
128
+ for operation_mode in values.get("operation_modes", []):
109
129
  for operation_mode_element in operation_mode.elements:
110
130
  for commodity in supported_commodities:
111
131
  power_ranges_for_commodity = [
112
132
  power_range
113
133
  for power_range in operation_mode_element.power_ranges
114
- if commodity_has_quantity(commodity, power_range.commodity_quantity)
134
+ if commodity_has_quantity(
135
+ commodity, power_range.commodity_quantity
136
+ )
115
137
  ]
116
138
 
117
139
  if len(power_ranges_for_commodity) > 1:
118
140
  raise ValueError(
119
- self,
141
+ cls,
120
142
  f"Multiple power ranges defined for commodity {commodity} in operation "
121
143
  f"mode {operation_mode.id} and element with fill_level_range "
122
144
  f"{operation_mode_element.fill_level_range}",
123
145
  )
124
146
  if not power_ranges_for_commodity:
125
147
  raise ValueError(
126
- self,
148
+ cls,
127
149
  f"No power ranges defined for commodity {commodity} in operation "
128
150
  f"mode {operation_mode.id} and element with fill_level_range "
129
151
  f"{operation_mode_element.fill_level_range}",
130
152
  )
131
- return self
153
+ return values
132
154
 
133
- @model_validator(mode="after")
134
- def validate_unique_supported_commodities(self) -> Self:
135
- supported_commodities: List[Commodity] = self.supported_commodities
155
+ @root_validator(pre=False)
156
+ @classmethod
157
+ def validate_unique_supported_commodities(
158
+ cls, values: Dict[str, Any]
159
+ ) -> Dict[str, Any]:
160
+ supported_commodities: List[CommodityQuantity] = values.get(
161
+ "supported_commodities", []
162
+ )
136
163
 
137
164
  for supported_commodity in supported_commodities:
138
165
  if supported_commodities.count(supported_commodity) > 1:
139
166
  raise ValueError(
140
- self,
167
+ cls,
141
168
  f"Found duplicate {supported_commodity} commodity in 'supported_commodities'",
142
169
  )
143
- return self
170
+ return values