s2-python 0.0.1__py3-none-any.whl → 0.2.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 (53) hide show
  1. {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/METADATA +22 -4
  2. s2_python-0.2.0.dist-info/RECORD +54 -0
  3. {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/WHEEL +1 -1
  4. s2python/__init__.py +1 -1
  5. s2python/common/__init__.py +1 -1
  6. s2python/common/duration.py +5 -5
  7. s2python/common/handshake.py +5 -5
  8. s2python/common/handshake_response.py +5 -5
  9. s2python/common/instruction_status_update.py +6 -10
  10. s2python/common/number_range.py +17 -21
  11. s2python/common/power_forecast.py +7 -9
  12. s2python/common/power_forecast_element.py +9 -10
  13. s2python/common/power_forecast_value.py +4 -6
  14. s2python/common/power_measurement.py +7 -7
  15. s2python/common/power_range.py +11 -13
  16. s2python/common/power_value.py +4 -4
  17. s2python/common/reception_status.py +5 -7
  18. s2python/common/resource_manager_details.py +11 -12
  19. s2python/common/revoke_object.py +6 -6
  20. s2python/common/role.py +4 -4
  21. s2python/common/select_control_type.py +5 -5
  22. s2python/common/session_request.py +5 -5
  23. s2python/common/support.py +6 -4
  24. s2python/common/timer.py +6 -6
  25. s2python/common/transition.py +12 -14
  26. s2python/frbc/frbc_actuator_description.py +53 -74
  27. s2python/frbc/frbc_actuator_status.py +10 -12
  28. s2python/frbc/frbc_fill_level_target_profile.py +10 -14
  29. s2python/frbc/frbc_fill_level_target_profile_element.py +7 -9
  30. s2python/frbc/frbc_instruction.py +8 -8
  31. s2python/frbc/frbc_leakage_behaviour.py +8 -10
  32. s2python/frbc/frbc_leakage_behaviour_element.py +6 -8
  33. s2python/frbc/frbc_operation_mode.py +19 -29
  34. s2python/frbc/frbc_operation_mode_element.py +11 -13
  35. s2python/frbc/frbc_storage_description.py +6 -8
  36. s2python/frbc/frbc_storage_status.py +5 -5
  37. s2python/frbc/frbc_system_description.py +10 -13
  38. s2python/frbc/frbc_timer_status.py +7 -7
  39. s2python/frbc/frbc_usage_forecast.py +7 -9
  40. s2python/frbc/frbc_usage_forecast_element.py +5 -7
  41. s2python/frbc/rm.py +0 -0
  42. s2python/generated/gen_s2.py +1150 -1130
  43. s2python/reception_status_awaiter.py +60 -0
  44. s2python/s2_connection.py +470 -0
  45. s2python/s2_control_type.py +56 -0
  46. s2python/s2_parser.py +113 -0
  47. s2python/s2_validation_error.py +7 -5
  48. s2python/utils.py +7 -2
  49. s2python/validate_values_mixin.py +32 -89
  50. s2python/version.py +2 -0
  51. s2_python-0.0.1.dist-info/RECORD +0 -49
  52. {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/entry_points.txt +0 -0
  53. {s2_python-0.0.1.dist-info → s2_python-0.2.0.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,13 @@
1
+ from dataclasses import dataclass
2
+ from typing import Union, Type, Optional
3
+
1
4
  from pydantic import ValidationError
5
+ from pydantic.v1.error_wrappers import ValidationError as ValidationErrorV1
2
6
 
3
7
 
8
+ @dataclass
4
9
  class S2ValidationError(Exception):
10
+ class_: Optional[Type]
5
11
  obj: object
6
12
  msg: str
7
- pydantic_validation_error: "ValidationError | TypeError | None"
8
-
9
- def __init__(self, obj: object, msg: str):
10
- self.obj = obj
11
- self.msg = msg
13
+ pydantic_validation_error: Union[ValidationErrorV1, ValidationError, TypeError, None]
s2python/utils.py CHANGED
@@ -1,3 +1,8 @@
1
- def pairwise(arr: list):
1
+ from typing import Generator, Tuple, List, TypeVar
2
+
3
+ P = TypeVar("P")
4
+
5
+
6
+ def pairwise(arr: List[P]) -> Generator[Tuple[P, P], None, None]:
2
7
  for i in range(max(len(arr) - 1, 0)):
3
- yield (arr[i], arr[i + 1])
8
+ yield arr[i], arr[i + 1]
@@ -1,104 +1,40 @@
1
- from typing import (
2
- TypeVar,
3
- Generic,
4
- Protocol,
5
- Type,
6
- Tuple,
7
- Optional,
8
- Callable,
9
- cast,
10
- Any,
11
- Union,
12
- AbstractSet,
13
- Mapping,
14
- List,
15
- Dict,
16
- )
17
-
18
- from pydantic import BaseModel, StrBytes, Protocol as PydanticProtocol, ValidationError
1
+ from typing import TypeVar, Generic, Type, Callable, Any, Union, AbstractSet, Mapping, List, Dict
2
+
3
+ from pydantic import BaseModel, ValidationError # pylint: disable=no-name-in-module
4
+ from pydantic.v1.error_wrappers import display_errors # pylint: disable=no-name-in-module
19
5
 
20
6
  from s2python.s2_validation_error import S2ValidationError
21
7
 
22
- B = TypeVar("B", bound=BaseModel, covariant=True)
8
+ B_co = TypeVar("B_co", bound=BaseModel, covariant=True)
23
9
 
24
10
  IntStr = Union[int, str]
25
11
  AbstractSetIntStr = AbstractSet[IntStr]
26
12
  MappingIntStrAny = Mapping[IntStr, Any]
27
13
 
28
14
 
29
- class SupportsValidation(Protocol[B]):
30
- # ValidateValuesMixin methods
31
- def to_json(self) -> str:
32
- ...
33
-
34
- def to_dict(self) -> dict:
35
- ...
36
-
37
- @classmethod
38
- def from_json(cls, json_str: str) -> B:
39
- ...
40
-
41
- # Pydantic methods
42
- def json(
43
- self,
44
- *,
45
- include: Optional[Union["AbstractSetIntStr", "MappingIntStrAny"]] = None,
46
- exclude: Optional[Union["AbstractSetIntStr", "MappingIntStrAny"]] = None,
47
- by_alias: bool = False,
48
- skip_defaults: Optional[bool] = None,
49
- exclude_unset: bool = False,
50
- exclude_defaults: bool = False,
51
- exclude_none: bool = False,
52
- encoder: Optional[Callable[[Any], Any]] = None,
53
- models_as_dict: bool = True,
54
- **dumps_kwargs: Any,
55
- ) -> str:
56
- ...
57
-
58
- def dict(
59
- self,
60
- *,
61
- include: Optional[Union["AbstractSetIntStr", "MappingIntStrAny"]] = None,
62
- exclude: Optional[Union["AbstractSetIntStr", "MappingIntStrAny"]] = None,
63
- by_alias: bool = False,
64
- skip_defaults: Optional[bool] = None,
65
- exclude_unset: bool = False,
66
- exclude_defaults: bool = False,
67
- exclude_none: bool = False,
68
- ) -> Dict[str, Any]:
69
- ...
70
-
71
- @classmethod
72
- def parse_raw(
73
- cls,
74
- b: StrBytes,
75
- *,
76
- content_type: str = ...,
77
- encoding: str = ...,
78
- proto: PydanticProtocol = ...,
79
- allow_pickle: bool = ...,
80
- ) -> B:
81
- ...
82
-
83
-
84
- C = TypeVar("C", bound="SupportsValidation")
15
+ C = TypeVar("C", bound="BaseModel")
85
16
 
86
17
 
87
- class ValidateValuesMixin(Generic[C]):
18
+ class S2Message(BaseModel, Generic[C]):
88
19
  def to_json(self: C) -> str:
89
20
  try:
90
- return self.json(by_alias=True, exclude_none=True)
21
+ return self.model_dump_json(by_alias=True, exclude_none=True)
91
22
  except (ValidationError, TypeError) as e:
92
23
  raise S2ValidationError(
93
- self, "Pydantic raised a format validation error."
24
+ type(self), self, "Pydantic raised a format validation error.", e
94
25
  ) from e
95
26
 
96
- def to_dict(self: C) -> dict:
97
- return self.dict()
27
+ def to_dict(self: C) -> Dict:
28
+ return self.model_dump()
98
29
 
99
30
  @classmethod
100
31
  def from_json(cls: Type[C], json_str: str) -> C:
101
- gen_model: C = cls.parse_raw(json_str)
32
+ gen_model: C = cls.model_validate_json(json_str)
33
+ return gen_model
34
+
35
+ @classmethod
36
+ def from_dict(cls: Type[C], json_dict: dict) -> C:
37
+ gen_model: C = cls.model_validate(json_dict)
102
38
  return gen_model
103
39
 
104
40
 
@@ -106,10 +42,16 @@ def convert_to_s2exception(f: Callable) -> Callable:
106
42
  def inner(*args: List[Any], **kwargs: Dict[str, Any]) -> Any:
107
43
  try:
108
44
  return f(*args, **kwargs)
109
- except (ValidationError, TypeError) as e:
110
- raise S2ValidationError(
111
- args, "Pydantic raised a format validation error."
112
- ) from e
45
+ except ValidationError as e:
46
+ if isinstance(args[0], BaseModel):
47
+ class_type = type(args[0])
48
+ args = args[1:]
49
+ else:
50
+ class_type = None
51
+
52
+ raise S2ValidationError(class_type, args, display_errors(e.errors()), e) from e # type: ignore[arg-type]
53
+ except TypeError as e:
54
+ raise S2ValidationError(None, args, str(e), e) from e
113
55
 
114
56
  inner.__doc__ = f.__doc__
115
57
  inner.__annotations__ = f.__annotations__
@@ -117,11 +59,12 @@ def convert_to_s2exception(f: Callable) -> Callable:
117
59
  return inner
118
60
 
119
61
 
120
- def catch_and_convert_exceptions(
121
- input_class: Type[SupportsValidation[B]],
122
- ) -> Type[SupportsValidation[B]]:
62
+ def catch_and_convert_exceptions(input_class: Type[S2Message[B_co]]) -> Type[S2Message[B_co]]:
123
63
  input_class.__init__ = convert_to_s2exception(input_class.__init__) # type: ignore[method-assign]
124
64
  input_class.__setattr__ = convert_to_s2exception(input_class.__setattr__) # type: ignore[method-assign]
125
- input_class.parse_raw = convert_to_s2exception(input_class.parse_raw) # type: ignore[method-assign]
65
+ input_class.model_validate_json = convert_to_s2exception( # type: ignore[method-assign]
66
+ input_class.model_validate_json
67
+ )
68
+ input_class.model_validate = convert_to_s2exception(input_class.model_validate) # type: ignore[method-assign]
126
69
 
127
70
  return input_class
s2python/version.py CHANGED
@@ -1 +1,3 @@
1
1
  VERSION = "0.2.0"
2
+
3
+ S2_VERSION = "0.0.2-beta"
@@ -1,49 +0,0 @@
1
- s2python/__init__.py,sha256=aLCMCipFsPGFEsc8ritsDiYDSUBTW5kA34N_3po08p8,352
2
- s2python/s2_validation_error.py,sha256=Veij_ReS0VCTC8fCRhxTgmZVVMCUiBu2VmtzYjJ6NBc,266
3
- s2python/utils.py,sha256=YJw3-i4fD_ud7rbm68VWE3PRjp-EgsnS_YtMxf6UnhA,102
4
- s2python/validate_values_mixin.py,sha256=CfRXeSkAOBBcS8zy4eNl3dx-01Sm6Wgn0bgTEhsdZks,3448
5
- s2python/version.py,sha256=w9Iw7QVvd8lme2wKwEbCo5IgetVjSfFBOOYAcA_Q0Ns,18
6
- s2python/common/__init__.py,sha256=fVJ0n13kRzzAtJcOxZHz3CEDexWXnyueJMcEXGdq_88,1345
7
- s2python/common/duration.py,sha256=-0_llJYXD5Z6Sx96XgY_unH3vcyCfhddxERAM7-8CGg,681
8
- s2python/common/handshake.py,sha256=v1JoZaYIk1faZFCAuf8sINq0xR_W03RaHhjkLODYLg4,460
9
- s2python/common/handshake_response.py,sha256=0o7miKQCWJ8cXFtvblQM81nUznyxZ2zrNrI22XAzTJg,516
10
- s2python/common/instruction_status_update.py,sha256=AzhgyIdcgtwbCAqNtUamFDttrMbyoMEqGD3qB-bFAgc,714
11
- s2python/common/number_range.py,sha256=b9KQ2XDyrcyqiHzN2rI7ldG-rsNk3b5os1BLDZOqTf4,1115
12
- s2python/common/power_forecast.py,sha256=zrFzR7Apg8OBkP_GQo4kseT2ZMjlinYRnh_KXe1e8vw,697
13
- s2python/common/power_forecast_element.py,sha256=MU6ndeMAkubJDrLfFON4IwyykCWHHqloQ_GvZp1Y-bo,756
14
- s2python/common/power_forecast_value.py,sha256=UP3IoyZVpkVhYrpN4CZvQHC8EQq7H_Q_S9BTs5us1KU,401
15
- s2python/common/power_measurement.py,sha256=Tiyb8ROub8m-tGCBQuZ8JTYV3d4HlyhqapP5Upvssms,683
16
- s2python/common/power_range.py,sha256=EQgFppktiusyZ6Ib7CKhx1-C167YQddgvVeu49xVY7o,751
17
- s2python/common/power_value.py,sha256=rqKXBrBwNCRpF13fl8zVhacxUQYPYPC2WbeP0OXZwdM,347
18
- s2python/common/reception_status.py,sha256=Vkj6ZzTkl-WYprszRStBuHIyKfoJW-gYp6NK6MuEwRo,532
19
- s2python/common/resource_manager_details.py,sha256=tDbR8hfaQ4Nz8po954HNm0YSJW95C7JomwTW1t5q33A,1029
20
- s2python/common/revoke_object.py,sha256=0KHb8klzsREE5oB1XwdXxBP_MIb3cQUDAz8V-Uv3moQ,587
21
- s2python/common/role.py,sha256=Vk732JKk05jOb6wPkG18me34kFT1MngKnLg1a8VWq5I,311
22
- s2python/common/select_control_type.py,sha256=bgZw9oePLBLAN7TEWwNsqMvO2zQMj3PdFUZ-KuqZfJk,516
23
- s2python/common/session_request.py,sha256=iDjW5HwDbAuwaJmpJROQAW3vqgNJddsLOKejWDPdbVc,495
24
- s2python/common/support.py,sha256=L08puzgMLvslKRqVQAnXH_Q5YRT5HTOPj8vDDNyzNYc,988
25
- s2python/common/timer.py,sha256=o2L48hefqC8cu6FAgjavjWMMnI8OxOHizP5zfL1abHY,558
26
- s2python/common/transition.py,sha256=k34bSvf8eU1Ys9SZkZKSye-NcxdSAqKjoWCNiT-8uxM,1107
27
- s2python/frbc/__init__.py,sha256=ROV3qZoldPkdgVFfMQr5Mf3GDfBzXaMfhNNCuXY6T0s,1104
28
- s2python/frbc/frbc_actuator_description.py,sha256=v2pWCUSGaw4IftMhNOjeLXE8B86XZNCyiZr3dQkziuo,6699
29
- s2python/frbc/frbc_actuator_status.py,sha256=Y8VUF0AA52tCG32qVb6jn93DMq0GPeaA9T5UPOm3m1c,999
30
- s2python/frbc/frbc_fill_level_target_profile.py,sha256=s-SqjWCEFc9oDm4zUW4RiFEnyWXh6HNlZgSF5P9kHHc,868
31
- s2python/frbc/frbc_fill_level_target_profile_element.py,sha256=0R2rJ8-rm-2igLgIdZI0SXMt450Ah0i54CBzehVxyI0,852
32
- s2python/frbc/frbc_instruction.py,sha256=uXKec7nUsQBmAkS6slBiyZ_1lo2i6cpuljRC_eV7LK8,829
33
- s2python/frbc/frbc_leakage_behaviour.py,sha256=4TnFHsP-wdtHGpWJ1xauE3H2Q_N5FLflG6YJvuKYpcA,771
34
- s2python/frbc/frbc_leakage_behaviour_element.py,sha256=Z7d8rELLnQDx-qGAVVtuoNnWHyj1CUYG_FOliBOpqwk,656
35
- s2python/frbc/frbc_operation_mode.py,sha256=DlQa4cRQKmPRoWmabpa9j3A8U0dBQRkEQHG5r7Y4VoM,2023
36
- s2python/frbc/frbc_operation_mode_element.py,sha256=8Cfp7sTHT4n0KQmFdnWCdzUgPW09NDUm3NL3RBBl2Uc,1099
37
- s2python/frbc/frbc_storage_description.py,sha256=AMuVZpRk5Pvxx6SnKg9WyELD8kqRJbAmJ1JL5tT0gdk,621
38
- s2python/frbc/frbc_storage_status.py,sha256=zMgdLYrAgv6Jne5oKWgGMFhUIbJegX501Rskaz_a5-g,516
39
- s2python/frbc/frbc_system_description.py,sha256=SGxtRNTlBw3-SU5A8J6Y2cxdYLSZiztR2RdrstUwCSc,935
40
- s2python/frbc/frbc_timer_status.py,sha256=RxbnLzAFJy-OXwwFbQ0QpzRcJ2awmysLcapzjDEU0K8,722
41
- s2python/frbc/frbc_usage_forecast.py,sha256=-bm6XSDq_wkbGeBj_d1i-C1RdaZpIfD1yJqZ6mWX4bw,735
42
- s2python/frbc/frbc_usage_forecast_element.py,sha256=bgFG01udYSizOyoGZPIPom0vj_dB3qokffU8hZ7BbC8,600
43
- s2python/generated/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
44
- s2python/generated/gen_s2.py,sha256=DXLCNE1gUS7XnRTgWlBpy73szr5HrHcrN0TZXvq8N_g,61928
45
- s2_python-0.0.1.dist-info/METADATA,sha256=7PixoPcZdw86h9LfGGX2ithyEEhyipz2IlP0-b3LWmw,2855
46
- s2_python-0.0.1.dist-info/WHEEL,sha256=yQN5g4mg4AybRjkgi-9yy4iQEFibGQmlz78Pik5Or-A,92
47
- s2_python-0.0.1.dist-info/entry_points.txt,sha256=feX-xmgJZgSe5-jxMgFKPKCJz4Ys3eQcGrsXsirNZyM,61
48
- s2_python-0.0.1.dist-info/top_level.txt,sha256=OLFq0oDhr77Mp-EYLEcWk5P3jvooOt4IHkTI5KYJMc8,9
49
- s2_python-0.0.1.dist-info/RECORD,,