s2-python 0.0.0__py3-none-any.whl → 0.1.0__py3-none-any.whl

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 (51) hide show
  1. s2_python-0.1.0.dist-info/METADATA +99 -0
  2. s2_python-0.1.0.dist-info/RECORD +50 -0
  3. {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/WHEEL +1 -1
  4. s2python/__init__.py +1 -1
  5. s2python/common/__init__.py +12 -2
  6. s2python/common/duration.py +7 -4
  7. s2python/common/handshake.py +6 -3
  8. s2python/common/handshake_response.py +6 -3
  9. s2python/common/instruction_status_update.py +14 -5
  10. s2python/common/number_range.py +22 -10
  11. s2python/common/power_forecast.py +10 -5
  12. s2python/common/power_forecast_element.py +11 -5
  13. s2python/common/power_forecast_value.py +5 -2
  14. s2python/common/power_measurement.py +8 -5
  15. s2python/common/power_range.py +12 -4
  16. s2python/common/power_value.py +5 -2
  17. s2python/common/reception_status.py +8 -3
  18. s2python/common/resource_manager_details.py +18 -8
  19. s2python/common/revoke_object.py +7 -4
  20. s2python/common/role.py +5 -2
  21. s2python/common/select_control_type.py +6 -3
  22. s2python/common/session_request.py +6 -3
  23. s2python/common/support.py +19 -11
  24. s2python/common/timer.py +7 -4
  25. s2python/common/transition.py +16 -9
  26. s2python/frbc/__init__.py +3 -1
  27. s2python/frbc/frbc_actuator_description.py +99 -37
  28. s2python/frbc/frbc_actuator_status.py +13 -6
  29. s2python/frbc/frbc_fill_level_target_profile.py +21 -6
  30. s2python/frbc/frbc_fill_level_target_profile_element.py +17 -5
  31. s2python/frbc/frbc_instruction.py +9 -6
  32. s2python/frbc/frbc_leakage_behaviour.py +10 -5
  33. s2python/frbc/frbc_leakage_behaviour_element.py +13 -4
  34. s2python/frbc/frbc_operation_mode.py +32 -13
  35. s2python/frbc/frbc_operation_mode_element.py +20 -7
  36. s2python/frbc/frbc_storage_description.py +13 -4
  37. s2python/frbc/frbc_storage_status.py +6 -3
  38. s2python/frbc/frbc_system_description.py +16 -6
  39. s2python/frbc/frbc_timer_status.py +8 -5
  40. s2python/frbc/frbc_usage_forecast.py +10 -5
  41. s2python/frbc/frbc_usage_forecast_element.py +11 -4
  42. s2python/generated/gen_s2.py +476 -476
  43. s2python/s2_parser.py +113 -0
  44. s2python/s2_validation_error.py +4 -1
  45. s2python/utils.py +8 -3
  46. s2python/validate_values_mixin.py +90 -37
  47. s2python/version.py +1 -1
  48. s2_python-0.0.0.dist-info/METADATA +0 -50
  49. s2_python-0.0.0.dist-info/RECORD +0 -49
  50. {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/entry_points.txt +0 -0
  51. {s2_python-0.0.0.dist-info → s2_python-0.1.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.1
2
+ Name: s2-python
3
+ Version: 0.1.0
4
+ Summary: S2 Protocol Python Wrapper
5
+ Home-page: https://github.com/flexiblepower/s2-ws-json-python
6
+ Author: Flexiblepower
7
+ Author-email: info@info.nl
8
+ License: APACHE
9
+ Platform: Linux
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Programming Language :: Python :: 3.8
12
+ Classifier: Programming Language :: Python :: 3.9
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Description-Content-Type: text/x-rst; charset=UTF-8
16
+ Requires-Dist: pydantic ~=1.10.7
17
+ Requires-Dist: pytz
18
+ Requires-Dist: click
19
+ Provides-Extra: development
20
+ Requires-Dist: pip-tools ; extra == 'development'
21
+ Requires-Dist: datamodel-code-generator ; extra == 'development'
22
+ Requires-Dist: pre-commit ; extra == 'development'
23
+ Requires-Dist: tox ; extra == 'development'
24
+ Provides-Extra: docs
25
+ Requires-Dist: sphinx ; extra == 'docs'
26
+ Requires-Dist: sphinx-rtd-theme >=1.2 ; extra == 'docs'
27
+ Requires-Dist: sphinx-tabs ; extra == 'docs'
28
+ Requires-Dist: sphinx-copybutton ; extra == 'docs'
29
+ Requires-Dist: sphinx-fontawesome ; extra == 'docs'
30
+ Requires-Dist: sphinxcontrib.httpdomain ; extra == 'docs'
31
+ Provides-Extra: testing
32
+ Requires-Dist: pytest ; extra == 'testing'
33
+ Requires-Dist: pytest-coverage ; extra == 'testing'
34
+ Requires-Dist: pytest-timer ; extra == 'testing'
35
+ Requires-Dist: mypy ; extra == 'testing'
36
+ Requires-Dist: types-pytz ; extra == 'testing'
37
+ Requires-Dist: pylint ; extra == 'testing'
38
+
39
+ Python Wrapper for S2 Flexibility Protocol
40
+ ===========================================
41
+ .. image:: https://img.shields.io/pypi/v/s2-python
42
+ :alt: PyPI - Version
43
+ .. image:: https://img.shields.io/pypi/pyversions/s2-python
44
+ :alt: PyPI - Python Version
45
+ .. image:: https://img.shields.io/pypi/l/s2-python
46
+ :alt: PyPI - License
47
+
48
+ This Python package implements the message validation for the EN50491-12-2 "S2" standard for home and building energy management. This implementation
49
+ is based on the asyncapi description of the protocol provided in the `s2-ws-json <https://github.com/flexiblepower/s2-ws-json/>`_ repository.
50
+
51
+ Currently, the package supports the *common* and *FILL RATE BASED CONTROL* types and messages.
52
+
53
+ To Install
54
+ -----------
55
+ You can install this package using pip or any Python dependency manager that collects the packages from Pypi:
56
+
57
+ .. code-block:: bash
58
+
59
+ pip install s2-python
60
+
61
+ The packages on Pypi may be found `here <https://pypi.org/project/s2-python/>`_
62
+
63
+ Example
64
+ ---------
65
+
66
+ .. code-block:: python
67
+
68
+ from s2python.common import PowerRange, CommodityQuantity
69
+
70
+ # create s2 messages as Python objects
71
+ number_range = PowerRange(
72
+ start_of_range=4.0,
73
+ end_of_range=5.0,
74
+ commodity_quantity=CommodityQuantity.ELECTRIC_POWER_L1,
75
+ )
76
+ # serialize s2 messages
77
+ number_range.to_json()
78
+ # deserialize s2 messages
79
+ json_str = '{"start_of_range": 4.0, "end_of_range": 5.0, "commodity_quantity": "ELECTRIC.POWER.L1"}'
80
+ PowerRange.from_json(json_str)
81
+
82
+ Development
83
+ -------------
84
+
85
+ For development, you can install the required dependencies using the following command:
86
+
87
+ pip install -e .[testing,development]
88
+
89
+
90
+ The tests can be run using tox:
91
+
92
+ tox
93
+
94
+ To build the package, you can use tox as well:
95
+
96
+ tox -e build,clean
97
+
98
+
99
+
@@ -0,0 +1,50 @@
1
+ s2python/__init__.py,sha256=e5lwvqsPl-z7IfEd0hRQhLBRKBYcuw2eqrecXnMfLdg,384
2
+ s2python/s2_parser.py,sha256=4oN4qBeW7RVNcXQ8GVib_oodK1_gszCrcXMQjPqRGUI,4088
3
+ s2python/s2_validation_error.py,sha256=fdV2tdRhYslDStTw8Cvb3mly7PpLiCbXbrkfOe3n2_w,295
4
+ s2python/utils.py,sha256=QX9b-mi-H_YUGTmGmJsrAbaWWM3dgaoaRLRXHHlaZDE,212
5
+ s2python/validate_values_mixin.py,sha256=RbhxqqhfhsNoTSeRxb7msQ6nEZWwAoUH6EQKkZkzH4k,4109
6
+ s2python/version.py,sha256=w9Iw7QVvd8lme2wKwEbCo5IgetVjSfFBOOYAcA_Q0Ns,18
7
+ s2python/common/__init__.py,sha256=fVJ0n13kRzzAtJcOxZHz3CEDexWXnyueJMcEXGdq_88,1345
8
+ s2python/common/duration.py,sha256=fMuftby-8wLeqpLKXd7VQqcmgTUUhTmWSW53R2b2vHM,661
9
+ s2python/common/handshake.py,sha256=IsbA41wBN4n0jopHn-vNDf2y1HP47p2kahM3NSwxAfc,440
10
+ s2python/common/handshake_response.py,sha256=Pa7kwRUFiecvPU84-z3D9_woxGqM4-_G9XtLgVmzMKA,496
11
+ s2python/common/instruction_status_update.py,sha256=w3bbVZ8jF3VBLKe3Q3fhWK9WhldxkkNgSzXuXyPzklA,694
12
+ s2python/common/number_range.py,sha256=NRND5K1-_U_6S4lVxfszI4A9o8hFYCrFQieska_ELgU,1163
13
+ s2python/common/power_forecast.py,sha256=-i1Z4JMGpmoo4N2DfmzMYiEh7o25xxsesKkUxhSWjAw,700
14
+ s2python/common/power_forecast_element.py,sha256=nQopGR0-uuE9jGyg2L-zusvkVACWqMJNxOyjm3PJYI4,787
15
+ s2python/common/power_forecast_value.py,sha256=UHiP8Go64RW6VzszzmAZ3JIyaGf2WOMGyx_PTmdmBoY,375
16
+ s2python/common/power_measurement.py,sha256=l_Na6Yw6twQveLw6j6FsX6BQh0fbmveHdHdsmnDzegs,675
17
+ s2python/common/power_range.py,sha256=Pazitj5zPzH2rz0gnKAzinwEhM28Dftglf3z6sHjIqA,796
18
+ s2python/common/power_value.py,sha256=xpu-MV_lkFYksfVDRRFbWiha8fA7KAF_p3CBoNNoyyg,327
19
+ s2python/common/reception_status.py,sha256=yd3tzG8UNMCjPy3WXpgMHjYnuFW3wyCv82tnq2kgEME,512
20
+ s2python/common/resource_manager_details.py,sha256=YOKnw7wMAX5JIt3LAnxfCvG0kTZjshHF8Yotfzyqbew,1050
21
+ s2python/common/revoke_object.py,sha256=EWuTqHoVyaPO-eIcFSCE7zROJXyR6RWkajX60IL8aM8,567
22
+ s2python/common/role.py,sha256=PV0noDy3D30dIodJgIWfGWcz-4hwZyBnpsWkyjc8c7g,291
23
+ s2python/common/select_control_type.py,sha256=y6yXcuCGPsm-QKSg6jJTzfUzAbZqvMkWepMhXERVQlM,496
24
+ s2python/common/session_request.py,sha256=bCnyAjSdeLShAC513x7ifaNRKZLAdzoJF2rU_zXxZEI,475
25
+ s2python/common/support.py,sha256=Kbrf_KGB45Wfr8j2pqDe1lLde6CIr3nl_LYkWnilmV0,1015
26
+ s2python/common/timer.py,sha256=-KhxxyJwK0pfVrpLBg9thYzOb2-LB5FgRBznwKCu76Y,538
27
+ s2python/common/transition.py,sha256=pYfo4sfWdnBR2Tvn3cW34zVT53d4PZSc3Ee3mubAYAg,1096
28
+ s2python/frbc/__init__.py,sha256=ROV3qZoldPkdgVFfMQr5Mf3GDfBzXaMfhNNCuXY6T0s,1104
29
+ s2python/frbc/frbc_actuator_description.py,sha256=9Zzzjhii3vABsLPOIN6qGavs0YyWthNV7whjcJadyGY,6801
30
+ s2python/frbc/frbc_actuator_status.py,sha256=xnTqGyh_h03BsBWRQfV7SMHn1yZV2KLV02FpIgojzr4,973
31
+ s2python/frbc/frbc_fill_level_target_profile.py,sha256=0kGB-uD0mqOZPdRBn_EJ8rMrA6DfTHMk7_nsSm7icRA,896
32
+ s2python/frbc/frbc_fill_level_target_profile_element.py,sha256=fqYwvbfEAM-e_hbUB6MN9NjGoCCdBcd-VGtmB9UyLbc,832
33
+ s2python/frbc/frbc_instruction.py,sha256=y8hZqh1jDKWVwehweWHQnbkFiSHlY87T4Al5kxEH9rQ,809
34
+ s2python/frbc/frbc_leakage_behaviour.py,sha256=CAuIAgaBDv82rPHmjJYchuVQilKLLjIOfI71UDnKXYk,776
35
+ s2python/frbc/frbc_leakage_behaviour_element.py,sha256=Bvw_4zuS5PgoZu_Pwy9kFCst75JbQyGKSvxOU7owYCA,636
36
+ s2python/frbc/frbc_operation_mode.py,sha256=bkMxQMP1pxF4rb0plUzBnFv7IG261lDq3FDf0HId0uE,2030
37
+ s2python/frbc/frbc_operation_mode_element.py,sha256=Bc5pJDwd83SbJiFYT2GA6sTzeLtsa8ohAM8LuY3uRc4,1079
38
+ s2python/frbc/frbc_storage_description.py,sha256=bxFVxYPhNCejMjBJtIiGjCCS7fyoOXHc3TUeWho7CYM,601
39
+ s2python/frbc/frbc_storage_status.py,sha256=PZCs-fh43in7LlYjalygW57iRQWwBp51tVEoZemS9-Y,496
40
+ s2python/frbc/frbc_system_description.py,sha256=RefubMI735vDV-cp6FEAEDe4bfcEYwY_EhCu5rC1oSs,991
41
+ s2python/frbc/frbc_timer_status.py,sha256=tyhjNia_I2j6rSggFiXp8i6QcZRiqhcOkMtn_TkXQ0Q,702
42
+ s2python/frbc/frbc_usage_forecast.py,sha256=8zWLBYpRfjiPKRz5x0QiZ2IF8HDGA8qlUgbOofAsQPA,743
43
+ s2python/frbc/frbc_usage_forecast_element.py,sha256=OuwrN4KarVe4tq6R4qkNz5j-sQstQDzLWP4g5B6L-iw,580
44
+ s2python/generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ s2python/generated/gen_s2.py,sha256=DXLCNE1gUS7XnRTgWlBpy73szr5HrHcrN0TZXvq8N_g,61928
46
+ s2_python-0.1.0.dist-info/METADATA,sha256=-V9F_j0oh6IkAVzrcX5oFFyY7bON8FwRwc7NUsLjIM4,3257
47
+ s2_python-0.1.0.dist-info/WHEEL,sha256=Xo9-1PvkuimrydujYJAjF7pCkriuXBpUPEjma1nZyJ0,92
48
+ s2_python-0.1.0.dist-info/entry_points.txt,sha256=feX-xmgJZgSe5-jxMgFKPKCJz4Ys3eQcGrsXsirNZyM,61
49
+ s2_python-0.1.0.dist-info/top_level.txt,sha256=OLFq0oDhr77Mp-EYLEcWk5P3jvooOt4IHkTI5KYJMc8,9
50
+ s2_python-0.1.0.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.41.2)
2
+ Generator: bdist_wheel (0.41.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
s2python/__init__.py CHANGED
@@ -2,7 +2,7 @@ from importlib.metadata import PackageNotFoundError, version # pragma: no cover
2
2
 
3
3
  try:
4
4
  # Change here if project is renamed and does not equal the package name
5
- dist_name = "s2-python"
5
+ dist_name = "s2-python" # pylint: disable=invalid-name
6
6
  __version__ = version(dist_name)
7
7
  except PackageNotFoundError: # pragma: no cover
8
8
  __version__ = "unknown"
@@ -1,5 +1,15 @@
1
- from s2python.generated.gen_s2 import (RoleType, CommodityQuantity, Commodity, InstructionStatus, ReceptionStatusValues,
2
- EnergyManagementRole, SessionRequestType, ControlType, Currency, RevokableObjects)
1
+ from s2python.generated.gen_s2 import (
2
+ RoleType,
3
+ CommodityQuantity,
4
+ Commodity,
5
+ InstructionStatus,
6
+ ReceptionStatusValues,
7
+ EnergyManagementRole,
8
+ SessionRequestType,
9
+ ControlType,
10
+ Currency,
11
+ RevokableObjects,
12
+ )
3
13
 
4
14
  from s2python.common.duration import Duration
5
15
  from s2python.common.role import Role
@@ -2,18 +2,21 @@ from datetime import timedelta
2
2
  import math
3
3
 
4
4
  from s2python.generated.gen_s2 import Duration as GenDuration
5
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
5
+ from s2python.validate_values_mixin import (
6
+ catch_and_convert_exceptions,
7
+ S2Message,
8
+ )
6
9
 
7
10
 
8
11
  @catch_and_convert_exceptions
9
- class Duration(GenDuration, ValidateValuesMixin['Duration']):
12
+ class Duration(GenDuration, S2Message["Duration"]):
10
13
  def to_timedelta(self) -> timedelta:
11
14
  return timedelta(milliseconds=self.__root__)
12
15
 
13
16
  @staticmethod
14
- def from_timedelta(duration: timedelta) -> 'Duration':
17
+ def from_timedelta(duration: timedelta) -> "Duration":
15
18
  return Duration(__root__=math.ceil(duration.total_seconds() * 1000))
16
19
 
17
20
  @staticmethod
18
- def from_milliseconds(milliseconds: int) -> 'Duration':
21
+ def from_milliseconds(milliseconds: int) -> "Duration":
19
22
  return Duration(__root__=milliseconds)
@@ -1,12 +1,15 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import Handshake as GenHandshake
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class Handshake(GenHandshake, ValidateValuesMixin['Handshake']):
11
+ class Handshake(GenHandshake, S2Message["Handshake"]):
9
12
  class Config(GenHandshake.Config):
10
13
  validate_assignment = True
11
14
 
12
- message_id: uuid.UUID = GenHandshake.__fields__['message_id'].field_info # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenHandshake.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -1,12 +1,15 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import HandshakeResponse as GenHandshakeResponse
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class HandshakeResponse(GenHandshakeResponse, ValidateValuesMixin['HandshakeResponse']):
11
+ class HandshakeResponse(GenHandshakeResponse, S2Message["HandshakeResponse"]):
9
12
  class Config(GenHandshakeResponse.Config):
10
13
  validate_assignment = True
11
14
 
12
- message_id: uuid.UUID = GenHandshakeResponse.__fields__['message_id'].field_info # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenHandshakeResponse.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -1,13 +1,22 @@
1
1
  import uuid
2
2
 
3
- from s2python.generated.gen_s2 import InstructionStatusUpdate as GenInstructionStatusUpdate
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
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
+ )
5
10
 
6
11
 
7
12
  @catch_and_convert_exceptions
8
- class InstructionStatusUpdate(GenInstructionStatusUpdate, ValidateValuesMixin['InstructionStatusUpdate']):
13
+ class InstructionStatusUpdate(
14
+ GenInstructionStatusUpdate, S2Message["InstructionStatusUpdate"]
15
+ ):
9
16
  class Config(GenInstructionStatusUpdate.Config):
10
17
  validate_assignment = True
11
18
 
12
- message_id: uuid.UUID = GenInstructionStatusUpdate.__fields__['message_id'].field_info # type: ignore[assignment]
13
- instruction_id: uuid.UUID = GenInstructionStatusUpdate.__fields__['instruction_id'].field_info # type: ignore[assignment]
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]
@@ -2,26 +2,38 @@ from typing import Any, Dict
2
2
 
3
3
  from pydantic import root_validator
4
4
 
5
- from s2python.validate_values_mixin import ValidateValuesMixin, catch_and_convert_exceptions
5
+ from s2python.validate_values_mixin import (
6
+ S2Message,
7
+ catch_and_convert_exceptions,
8
+ )
6
9
  from s2python.generated.gen_s2 import NumberRange as GenNumberRange
7
10
 
11
+
8
12
  @catch_and_convert_exceptions
9
- class NumberRange(GenNumberRange, ValidateValuesMixin['NumberRange']):
13
+ class NumberRange(GenNumberRange, S2Message["NumberRange"]):
10
14
  class Config(GenNumberRange.Config):
11
15
  validate_assignment = True
12
16
 
13
17
  @root_validator(pre=False)
14
- def validate_start_end_order(cls, values: Dict[str, Any]) -> Dict[str, Any]:
18
+ @classmethod
19
+ def validate_start_end_order( # pylint: disable=duplicate-code
20
+ cls, values: Dict[str, Any]
21
+ ) -> Dict[str, Any]:
15
22
  if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
16
- raise ValueError(cls, 'start_of_range should not be higher than end_of_range')
23
+ raise ValueError(
24
+ cls, "start_of_range should not be higher than end_of_range"
25
+ )
17
26
 
18
27
  return values
19
28
 
20
- def __hash__(self):
21
- return hash(f'{self.start_of_range}|{self.end_of_range}')
29
+ def __hash__(self) -> int:
30
+ return hash(f"{self.start_of_range}|{self.end_of_range}")
22
31
 
23
- def __eq__(self, other):
32
+ def __eq__(self, other: Any) -> bool:
24
33
  if isinstance(other, NumberRange):
25
- return self.start_of_range == other.start_of_range and self.end_of_range == other.end_of_range
26
- else:
27
- return False
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
@@ -1,15 +1,20 @@
1
1
  from typing import List
2
2
  import uuid
3
3
 
4
- from s2python.common import PowerForecastElement
4
+ from s2python.common.power_forecast_element import PowerForecastElement
5
5
  from s2python.generated.gen_s2 import PowerForecast as GenPowerForecast
6
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
6
+ from s2python.validate_values_mixin import (
7
+ catch_and_convert_exceptions,
8
+ S2Message,
9
+ )
7
10
 
8
11
 
9
12
  @catch_and_convert_exceptions
10
- class PowerForecast(GenPowerForecast, ValidateValuesMixin['PowerForecast']):
13
+ class PowerForecast(GenPowerForecast, S2Message["PowerForecast"]):
11
14
  class Config(GenPowerForecast.Config):
12
15
  validate_assignment = True
13
16
 
14
- message_id: uuid.UUID = GenPowerForecast.__fields__['message_id'].field_info # type: ignore[assignment]
15
- elements: List[PowerForecastElement] = GenPowerForecast.__fields__['elements'].field_info # 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]
@@ -1,14 +1,20 @@
1
1
  from typing import List
2
2
 
3
3
  from s2python.generated.gen_s2 import PowerForecastElement as GenPowerForecastElement
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
5
- from s2python.common import Duration, PowerForecastValue
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
8
+ from s2python.common.duration import Duration
9
+ from s2python.common.power_forecast_value import PowerForecastValue
6
10
 
7
11
 
8
12
  @catch_and_convert_exceptions
9
- class PowerForecastElement(GenPowerForecastElement, ValidateValuesMixin['PowerForecastElement']):
13
+ class PowerForecastElement(GenPowerForecastElement, S2Message["PowerForecastElement"]):
10
14
  class Config(GenPowerForecastElement.Config):
11
15
  validate_assignment = True
12
16
 
13
- duration: Duration = GenPowerForecastElement.__fields__['duration'].field_info # type: ignore[assignment]
14
- power_values: List[PowerForecastValue] = GenPowerForecastElement.__fields__['power_values'].field_info # type: ignore[assignment]
17
+ duration: Duration = GenPowerForecastElement.__fields__["duration"].field_info # type: ignore[assignment]
18
+ power_values: List[PowerForecastValue] = GenPowerForecastElement.__fields__[
19
+ "power_values"
20
+ ].field_info # type: ignore[assignment]
@@ -1,8 +1,11 @@
1
1
  from s2python.generated.gen_s2 import PowerForecastValue as GenPowerForecastValue
2
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
2
+ from s2python.validate_values_mixin import (
3
+ catch_and_convert_exceptions,
4
+ S2Message,
5
+ )
3
6
 
4
7
 
5
8
  @catch_and_convert_exceptions
6
- class PowerForecastValue(GenPowerForecastValue, ValidateValuesMixin['PowerForecastValue']):
9
+ class PowerForecastValue(GenPowerForecastValue, S2Message["PowerForecastValue"]):
7
10
  class Config(GenPowerForecastValue.Config):
8
11
  validate_assignment = True
@@ -1,15 +1,18 @@
1
1
  from typing import List
2
2
  import uuid
3
3
 
4
- from s2python.common import PowerValue
4
+ from s2python.common.power_value import PowerValue
5
5
  from s2python.generated.gen_s2 import PowerMeasurement as GenPowerMeasurement
6
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
6
+ from s2python.validate_values_mixin import (
7
+ catch_and_convert_exceptions,
8
+ S2Message,
9
+ )
7
10
 
8
11
 
9
12
  @catch_and_convert_exceptions
10
- class PowerMeasurement(GenPowerMeasurement, ValidateValuesMixin['PowerMeasurement']):
13
+ class PowerMeasurement(GenPowerMeasurement, S2Message["PowerMeasurement"]):
11
14
  class Config(GenPowerMeasurement.Config):
12
15
  validate_assignment = True
13
16
 
14
- message_id: uuid.UUID = GenPowerMeasurement.__fields__['message_id'].field_info # type: ignore[assignment]
15
- values: List[PowerValue] = GenPowerMeasurement.__fields__['values'].field_info # 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]
@@ -3,17 +3,25 @@ from typing import Any, Dict
3
3
  from pydantic import root_validator
4
4
 
5
5
  from s2python.generated.gen_s2 import PowerRange as GenPowerRange
6
- from s2python.validate_values_mixin import ValidateValuesMixin, catch_and_convert_exceptions
6
+ from s2python.validate_values_mixin import (
7
+ S2Message,
8
+ catch_and_convert_exceptions,
9
+ )
7
10
 
8
11
 
9
12
  @catch_and_convert_exceptions
10
- class PowerRange(GenPowerRange, ValidateValuesMixin['PowerRange']):
13
+ class PowerRange(GenPowerRange, S2Message["PowerRange"]):
11
14
  class Config(GenPowerRange.Config):
12
15
  validate_assignment = True
13
16
 
14
17
  @root_validator(pre=False)
15
- def validate_start_end_order(cls, values: Dict[str, Any]) -> Dict[str, Any]:
18
+ @classmethod
19
+ def validate_start_end_order(
20
+ cls, values: Dict[str, Any]
21
+ ) -> Dict[str, Any]: # pylint: disable=duplicate-code
16
22
  if values.get("start_of_range", 0.0) > values.get("end_of_range", 0.0):
17
- raise ValueError(cls, 'start_of_range should not be higher than end_of_range')
23
+ raise ValueError(
24
+ cls, "start_of_range should not be higher than end_of_range"
25
+ )
18
26
 
19
27
  return values
@@ -1,8 +1,11 @@
1
1
  from s2python.generated.gen_s2 import PowerValue as GenPowerValue
2
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
2
+ from s2python.validate_values_mixin import (
3
+ catch_and_convert_exceptions,
4
+ S2Message,
5
+ )
3
6
 
4
7
 
5
8
  @catch_and_convert_exceptions
6
- class PowerValue(GenPowerValue, ValidateValuesMixin['PowerValue']):
9
+ class PowerValue(GenPowerValue, S2Message["PowerValue"]):
7
10
  class Config(GenPowerValue.Config):
8
11
  validate_assignment = True
@@ -1,12 +1,17 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import ReceptionStatus as GenReceptionStatus
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class ReceptionStatus(GenReceptionStatus, ValidateValuesMixin['ReceptionStatus']):
11
+ class ReceptionStatus(GenReceptionStatus, S2Message["ReceptionStatus"]):
9
12
  class Config(GenReceptionStatus.Config):
10
13
  validate_assignment = True
11
14
 
12
- subject_message_id: uuid.UUID = GenReceptionStatus.__fields__['subject_message_id'].field_info # type: ignore[assignment]
15
+ subject_message_id: uuid.UUID = GenReceptionStatus.__fields__[
16
+ "subject_message_id"
17
+ ].field_info # type: ignore[assignment]
@@ -1,17 +1,27 @@
1
1
  from typing import List
2
2
  import uuid
3
3
 
4
- from s2python.common import Duration, Role
5
- from s2python.generated.gen_s2 import ResourceManagerDetails as GenResourceManagerDetails
6
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
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
+ )
7
13
 
8
14
 
9
15
  @catch_and_convert_exceptions
10
- class ResourceManagerDetails(GenResourceManagerDetails, ValidateValuesMixin['ResourceManagerDetails']):
16
+ class ResourceManagerDetails(
17
+ GenResourceManagerDetails, S2Message["ResourceManagerDetails"]
18
+ ):
11
19
  class Config(GenResourceManagerDetails.Config):
12
20
  validate_assignment = True
13
21
 
14
- instruction_processing_delay: Duration = GenResourceManagerDetails.__fields__['instruction_processing_delay'].field_info # type: ignore[assignment]
15
- message_id: uuid.UUID = GenResourceManagerDetails.__fields__['message_id'].field_info # type: ignore[assignment]
16
- resource_id: uuid.UUID = GenResourceManagerDetails.__fields__['resource_id'].field_info # type: ignore[assignment]
17
- roles: List[Role] = GenResourceManagerDetails.__fields__['roles'].field_info # type: ignore[assignment]
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]
@@ -1,13 +1,16 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import RevokeObject as GenRevokeObject
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class RevokeObject(GenRevokeObject, ValidateValuesMixin['RevokeObject']):
11
+ class RevokeObject(GenRevokeObject, S2Message["RevokeObject"]):
9
12
  class Config(GenRevokeObject.Config):
10
13
  validate_assignment = True
11
14
 
12
- message_id: uuid.UUID = GenRevokeObject.__fields__['message_id'].field_info # type: ignore[assignment]
13
- object_id: uuid.UUID = GenRevokeObject.__fields__['object_id'].field_info # type: ignore[assignment]
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]
s2python/common/role.py CHANGED
@@ -1,8 +1,11 @@
1
1
  from s2python.generated.gen_s2 import Role as GenRole
2
- from s2python.validate_values_mixin import ValidateValuesMixin, catch_and_convert_exceptions
2
+ from s2python.validate_values_mixin import (
3
+ S2Message,
4
+ catch_and_convert_exceptions,
5
+ )
3
6
 
4
7
 
5
8
  @catch_and_convert_exceptions
6
- class Role(GenRole, ValidateValuesMixin['Role']):
9
+ class Role(GenRole, S2Message["Role"]):
7
10
  class Config(GenRole.Config):
8
11
  validate_assignment = True
@@ -1,12 +1,15 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import SelectControlType as GenSelectControlType
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class SelectControlType(GenSelectControlType, ValidateValuesMixin['SelectControlType']):
11
+ class SelectControlType(GenSelectControlType, S2Message["SelectControlType"]):
9
12
  class Config(GenSelectControlType.Config):
10
13
  validate_assignment = True
11
14
 
12
- message_id: uuid.UUID = GenSelectControlType.__fields__['message_id'].field_info # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenSelectControlType.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -1,12 +1,15 @@
1
1
  import uuid
2
2
 
3
3
  from s2python.generated.gen_s2 import SessionRequest as GenSessionRequest
4
- from s2python.validate_values_mixin import catch_and_convert_exceptions, ValidateValuesMixin
4
+ from s2python.validate_values_mixin import (
5
+ catch_and_convert_exceptions,
6
+ S2Message,
7
+ )
5
8
 
6
9
 
7
10
  @catch_and_convert_exceptions
8
- class SessionRequest(GenSessionRequest, ValidateValuesMixin['SessionRequest']):
11
+ class SessionRequest(GenSessionRequest, S2Message["SessionRequest"]):
9
12
  class Config(GenSessionRequest.Config):
10
13
  validate_assignment = True
11
14
 
12
- message_id: uuid.UUID = GenSessionRequest.__fields__['message_id'].field_info # type: ignore[assignment]
15
+ message_id: uuid.UUID = GenSessionRequest.__fields__["message_id"].field_info # type: ignore[assignment]
@@ -1,19 +1,27 @@
1
1
  from s2python.common import CommodityQuantity, Commodity
2
2
 
3
3
 
4
- def commodity_has_quantity(commodity: 'Commodity', quantity: CommodityQuantity) -> bool:
4
+ def commodity_has_quantity(commodity: "Commodity", quantity: CommodityQuantity) -> bool:
5
5
  if commodity == Commodity.HEAT:
6
- return quantity in [CommodityQuantity.HEAT_THERMAL_POWER,
7
- CommodityQuantity.HEAT_TEMPERATURE,
8
- CommodityQuantity.HEAT_FLOW_RATE]
6
+ result = quantity in [
7
+ CommodityQuantity.HEAT_THERMAL_POWER,
8
+ CommodityQuantity.HEAT_TEMPERATURE,
9
+ CommodityQuantity.HEAT_FLOW_RATE,
10
+ ]
9
11
  elif commodity == Commodity.ELECTRICITY:
10
- return quantity in [CommodityQuantity.ELECTRIC_POWER_3_PHASE_SYMMETRIC,
11
- CommodityQuantity.ELECTRIC_POWER_L1,
12
- CommodityQuantity.ELECTRIC_POWER_L2,
13
- CommodityQuantity.ELECTRIC_POWER_L3]
12
+ result = quantity in [
13
+ CommodityQuantity.ELECTRIC_POWER_3_PHASE_SYMMETRIC,
14
+ CommodityQuantity.ELECTRIC_POWER_L1,
15
+ CommodityQuantity.ELECTRIC_POWER_L2,
16
+ CommodityQuantity.ELECTRIC_POWER_L3,
17
+ ]
14
18
  elif commodity == Commodity.GAS:
15
- return quantity in [CommodityQuantity.NATURAL_GAS_FLOW_RATE]
19
+ result = quantity in [CommodityQuantity.NATURAL_GAS_FLOW_RATE]
16
20
  elif commodity == Commodity.OIL:
17
- return quantity in [CommodityQuantity.OIL_FLOW_RATE]
21
+ result = quantity in [CommodityQuantity.OIL_FLOW_RATE]
18
22
  else:
19
- raise RuntimeError(f'Unsupported commodity {commodity}. Missing implementation.')
23
+ raise RuntimeError(
24
+ f"Unsupported commodity {commodity}. Missing implementation."
25
+ )
26
+
27
+ return result