odxtools 9.7.0__py3-none-any.whl → 10.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 (193) hide show
  1. odxtools/additionalaudience.py +7 -7
  2. odxtools/admindata.py +14 -13
  3. odxtools/audience.py +17 -17
  4. odxtools/basecomparam.py +9 -8
  5. odxtools/basevariantpattern.py +9 -10
  6. odxtools/basicstructure.py +15 -15
  7. odxtools/cli/_print_utils.py +34 -22
  8. odxtools/cli/browse.py +8 -8
  9. odxtools/cli/compare.py +24 -24
  10. odxtools/cli/decode.py +3 -4
  11. odxtools/cli/find.py +4 -5
  12. odxtools/cli/list.py +6 -6
  13. odxtools/cli/main.py +2 -2
  14. odxtools/cli/snoop.py +3 -3
  15. odxtools/codec.py +3 -3
  16. odxtools/commrelation.py +18 -17
  17. odxtools/companydata.py +13 -13
  18. odxtools/companydocinfo.py +15 -17
  19. odxtools/companyrevisioninfo.py +9 -9
  20. odxtools/companyspecificinfo.py +11 -13
  21. odxtools/comparam.py +8 -7
  22. odxtools/comparaminstance.py +14 -14
  23. odxtools/comparamspec.py +10 -11
  24. odxtools/comparamsubset.py +17 -25
  25. odxtools/complexcomparam.py +14 -14
  26. odxtools/complexdop.py +1 -1
  27. odxtools/compositecodec.py +8 -8
  28. odxtools/compumethods/compucodecompumethod.py +7 -7
  29. odxtools/compumethods/compuconst.py +5 -6
  30. odxtools/compumethods/compudefaultvalue.py +2 -3
  31. odxtools/compumethods/compuinternaltophys.py +13 -12
  32. odxtools/compumethods/compumethod.py +10 -9
  33. odxtools/compumethods/compuphystointernal.py +13 -12
  34. odxtools/compumethods/compurationalcoeffs.py +7 -7
  35. odxtools/compumethods/compuscale.py +15 -16
  36. odxtools/compumethods/createanycompumethod.py +12 -13
  37. odxtools/compumethods/identicalcompumethod.py +4 -5
  38. odxtools/compumethods/limit.py +14 -14
  39. odxtools/compumethods/linearcompumethod.py +5 -5
  40. odxtools/compumethods/linearsegment.py +10 -11
  41. odxtools/compumethods/ratfunccompumethod.py +6 -6
  42. odxtools/compumethods/ratfuncsegment.py +7 -8
  43. odxtools/compumethods/scalelinearcompumethod.py +9 -9
  44. odxtools/compumethods/scaleratfunccompumethod.py +7 -7
  45. odxtools/compumethods/tabintpcompumethod.py +10 -13
  46. odxtools/compumethods/texttablecompumethod.py +6 -6
  47. odxtools/createanycomparam.py +5 -7
  48. odxtools/createanydiagcodedtype.py +7 -8
  49. odxtools/database.py +34 -31
  50. odxtools/dataobjectproperty.py +19 -20
  51. odxtools/decodestate.py +5 -5
  52. odxtools/description.py +9 -9
  53. odxtools/determinenumberofitems.py +8 -7
  54. odxtools/diagcodedtype.py +10 -10
  55. odxtools/diagcomm.py +29 -30
  56. odxtools/diagdatadictionaryspec.py +36 -36
  57. odxtools/diaglayercontainer.py +35 -34
  58. odxtools/diaglayers/basevariant.py +14 -12
  59. odxtools/diaglayers/basevariantraw.py +22 -23
  60. odxtools/diaglayers/diaglayer.py +24 -22
  61. odxtools/diaglayers/diaglayerraw.py +43 -52
  62. odxtools/diaglayers/diaglayertype.py +1 -2
  63. odxtools/diaglayers/ecushareddata.py +9 -9
  64. odxtools/diaglayers/ecushareddataraw.py +15 -16
  65. odxtools/diaglayers/ecuvariant.py +15 -13
  66. odxtools/diaglayers/ecuvariantraw.py +21 -22
  67. odxtools/diaglayers/functionalgroup.py +12 -11
  68. odxtools/diaglayers/functionalgroupraw.py +17 -18
  69. odxtools/diaglayers/hierarchyelement.py +48 -54
  70. odxtools/diaglayers/hierarchyelementraw.py +10 -11
  71. odxtools/diaglayers/protocol.py +7 -7
  72. odxtools/diaglayers/protocolraw.py +13 -14
  73. odxtools/diagnostictroublecode.py +15 -17
  74. odxtools/diagservice.py +28 -27
  75. odxtools/diagvariable.py +24 -25
  76. odxtools/docrevision.py +18 -17
  77. odxtools/dopbase.py +13 -14
  78. odxtools/dtcconnector.py +8 -7
  79. odxtools/dtcdop.py +24 -20
  80. odxtools/dynamicendmarkerfield.py +10 -9
  81. odxtools/dynamiclengthfield.py +10 -9
  82. odxtools/dyndefinedspec.py +10 -10
  83. odxtools/dynenddopref.py +9 -9
  84. odxtools/dyniddefmodeinfo.py +21 -21
  85. odxtools/ecuvariantpattern.py +8 -10
  86. odxtools/element.py +12 -13
  87. odxtools/encodestate.py +11 -11
  88. odxtools/encoding.py +2 -3
  89. odxtools/endofpdufield.py +9 -10
  90. odxtools/envdataconnector.py +8 -8
  91. odxtools/environmentdata.py +7 -9
  92. odxtools/environmentdatadescription.py +18 -17
  93. odxtools/exceptions.py +5 -5
  94. odxtools/externalaccessmethod.py +4 -6
  95. odxtools/externaldoc.py +6 -6
  96. odxtools/field.py +15 -15
  97. odxtools/functionalclass.py +9 -9
  98. odxtools/inputparam.py +11 -10
  99. odxtools/internalconstr.py +10 -11
  100. odxtools/isotp_state_machine.py +12 -11
  101. odxtools/leadinglengthinfotype.py +4 -6
  102. odxtools/library.py +9 -8
  103. odxtools/linkeddtcdop.py +9 -8
  104. odxtools/loadfile.py +5 -6
  105. odxtools/matchingbasevariantparameter.py +5 -6
  106. odxtools/matchingparameter.py +10 -10
  107. odxtools/message.py +1 -1
  108. odxtools/minmaxlengthtype.py +6 -7
  109. odxtools/modification.py +7 -6
  110. odxtools/multiplexer.py +54 -18
  111. odxtools/multiplexercase.py +13 -13
  112. odxtools/multiplexerdefaultcase.py +11 -10
  113. odxtools/multiplexerswitchkey.py +8 -8
  114. odxtools/nameditemlist.py +13 -13
  115. odxtools/negoutputparam.py +8 -8
  116. odxtools/obd.py +1 -2
  117. odxtools/odxcategory.py +14 -26
  118. odxtools/odxdoccontext.py +16 -0
  119. odxtools/odxlink.py +23 -25
  120. odxtools/odxtypes.py +18 -15
  121. odxtools/outputparam.py +9 -8
  122. odxtools/parameterinfo.py +1 -1
  123. odxtools/parameters/codedconstparameter.py +10 -10
  124. odxtools/parameters/createanyparameter.py +15 -16
  125. odxtools/parameters/dynamicparameter.py +5 -7
  126. odxtools/parameters/lengthkeyparameter.py +10 -10
  127. odxtools/parameters/matchingrequestparameter.py +6 -7
  128. odxtools/parameters/nrcconstparameter.py +13 -13
  129. odxtools/parameters/parameter.py +17 -18
  130. odxtools/parameters/parameterwithdop.py +13 -13
  131. odxtools/parameters/physicalconstantparameter.py +8 -7
  132. odxtools/parameters/reservedparameter.py +6 -8
  133. odxtools/parameters/systemparameter.py +5 -7
  134. odxtools/parameters/tableentryparameter.py +8 -8
  135. odxtools/parameters/tablekeyparameter.py +17 -17
  136. odxtools/parameters/tablestructparameter.py +11 -11
  137. odxtools/parameters/valueparameter.py +11 -11
  138. odxtools/paramlengthinfotype.py +10 -9
  139. odxtools/parentref.py +15 -13
  140. odxtools/physicaldimension.py +15 -15
  141. odxtools/physicaltype.py +5 -6
  142. odxtools/posresponsesuppressible.py +11 -12
  143. odxtools/preconditionstateref.py +11 -11
  144. odxtools/progcode.py +11 -10
  145. odxtools/protstack.py +10 -9
  146. odxtools/relateddiagcommref.py +5 -6
  147. odxtools/relateddoc.py +11 -10
  148. odxtools/request.py +18 -19
  149. odxtools/response.py +19 -20
  150. odxtools/scaleconstr.py +8 -9
  151. odxtools/servicebinner.py +5 -5
  152. odxtools/singleecujob.py +16 -15
  153. odxtools/snrefcontext.py +3 -3
  154. odxtools/specialdata.py +8 -7
  155. odxtools/specialdatagroup.py +17 -17
  156. odxtools/specialdatagroupcaption.py +7 -6
  157. odxtools/standardlengthtype.py +14 -22
  158. odxtools/state.py +7 -6
  159. odxtools/statechart.py +12 -11
  160. odxtools/statemachine.py +4 -3
  161. odxtools/statetransition.py +9 -9
  162. odxtools/statetransitionref.py +19 -19
  163. odxtools/staticfield.py +9 -7
  164. odxtools/structure.py +5 -6
  165. odxtools/subcomponent.py +20 -18
  166. odxtools/subcomponentparamconnector.py +10 -9
  167. odxtools/subcomponentpattern.py +9 -9
  168. odxtools/swvariable.py +6 -7
  169. odxtools/table.py +25 -26
  170. odxtools/tablediagcommconnector.py +9 -8
  171. odxtools/tablerow.py +64 -43
  172. odxtools/tablerowconnector.py +8 -8
  173. odxtools/teammember.py +16 -15
  174. odxtools/templates/macros/printParentRef.xml.jinja2 +3 -1
  175. odxtools/text.py +4 -5
  176. odxtools/uds.py +2 -3
  177. odxtools/unit.py +14 -13
  178. odxtools/unitgroup.py +11 -10
  179. odxtools/unitspec.py +18 -19
  180. odxtools/utils.py +3 -3
  181. odxtools/variablegroup.py +5 -6
  182. odxtools/variantmatcher.py +10 -10
  183. odxtools/variantpattern.py +5 -6
  184. odxtools/version.py +2 -2
  185. odxtools/writepdxfile.py +5 -24
  186. odxtools/xdoc.py +13 -12
  187. {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/METADATA +4 -5
  188. odxtools-10.1.0.dist-info/RECORD +265 -0
  189. {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/WHEEL +1 -1
  190. odxtools-9.7.0.dist-info/RECORD +0 -264
  191. {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/entry_points.txt +0 -0
  192. {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/licenses/LICENSE +0 -0
  193. {odxtools-9.7.0.dist-info → odxtools-10.1.0.dist-info}/top_level.txt +0 -0
@@ -1,9 +1,8 @@
1
1
  # SPDX-License-Identifier: MIT
2
- from typing import List
3
2
  from xml.etree import ElementTree
4
3
 
5
4
  from ..exceptions import odxraise, odxrequire
6
- from ..odxlink import OdxDocFragment
5
+ from ..odxdoccontext import OdxDocContext
7
6
  from ..odxtypes import DataType
8
7
  from .compucodecompumethod import CompuCodeCompuMethod
9
8
  from .compumethod import CompuMethod
@@ -16,38 +15,38 @@ from .tabintpcompumethod import TabIntpCompuMethod
16
15
  from .texttablecompumethod import TexttableCompuMethod
17
16
 
18
17
 
19
- def create_any_compu_method_from_et(et_element: ElementTree.Element,
20
- doc_frags: List[OdxDocFragment], *, internal_type: DataType,
18
+ def create_any_compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
19
+ internal_type: DataType,
21
20
  physical_type: DataType) -> CompuMethod:
22
21
  compu_category = odxrequire(et_element.findtext("CATEGORY"))
23
22
 
24
23
  if compu_category == "IDENTICAL":
25
24
  return IdenticalCompuMethod.compu_method_from_et(
26
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
25
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
27
26
  elif compu_category == "LINEAR":
28
27
  return LinearCompuMethod.compu_method_from_et(
29
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
28
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
30
29
  elif compu_category == "SCALE-LINEAR":
31
30
  return ScaleLinearCompuMethod.compu_method_from_et(
32
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
31
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
33
32
  elif compu_category == "RAT-FUNC":
34
33
  return RatFuncCompuMethod.compu_method_from_et(
35
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
34
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
36
35
  elif compu_category == "SCALE-RAT-FUNC":
37
36
  return ScaleRatFuncCompuMethod.compu_method_from_et(
38
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
37
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
39
38
  elif compu_category == "TEXTTABLE":
40
39
  return TexttableCompuMethod.compu_method_from_et(
41
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
40
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
42
41
  elif compu_category == "COMPUCODE":
43
42
  return CompuCodeCompuMethod.compu_method_from_et(
44
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
43
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
45
44
  elif compu_category == "TAB-INTP":
46
45
  return TabIntpCompuMethod.compu_method_from_et(
47
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
46
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
48
47
 
49
48
  # TODO: Implement all categories (never instantiate the CompuMethod base class!)
50
49
  odxraise(f"Warning: Computation category {compu_category} is not implemented!")
51
50
 
52
51
  return IdenticalCompuMethod.compu_method_from_et(
53
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
52
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
@@ -1,16 +1,15 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List
4
3
  from xml.etree import ElementTree
5
4
 
6
5
  from ..exceptions import odxassert
7
- from ..odxlink import OdxDocFragment
6
+ from ..odxdoccontext import OdxDocContext
8
7
  from ..odxtypes import AtomicOdxType, DataType
9
8
  from ..utils import dataclass_fields_asdict
10
9
  from .compumethod import CompuMethod
11
10
 
12
11
 
13
- @dataclass
12
+ @dataclass(kw_only=True)
14
13
  class IdenticalCompuMethod(CompuMethod):
15
14
  """Identical compu methods just pass through the internal value.
16
15
 
@@ -18,11 +17,11 @@ class IdenticalCompuMethod(CompuMethod):
18
17
  """
19
18
 
20
19
  @staticmethod
21
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
20
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
22
21
  internal_type: DataType,
23
22
  physical_type: DataType) -> "IdenticalCompuMethod":
24
23
  cm = CompuMethod.compu_method_from_et(
25
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
24
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
26
25
  kwargs = dataclass_fields_asdict(cm)
27
26
 
28
27
  odxassert(
@@ -1,39 +1,39 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Optional, overload
3
+ from typing import Optional, overload
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import odxraise
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType, compare_odx_values
9
9
  from .intervaltype import IntervalType
10
10
 
11
11
 
12
- @dataclass
12
+ @dataclass(kw_only=True)
13
13
  class Limit:
14
- value_raw: Optional[str]
15
- value_type: Optional[DataType]
16
- interval_type: Optional[IntervalType]
14
+ value_raw: str | None = None
15
+ value_type: DataType | None = None
16
+ interval_type: IntervalType | None = None
17
17
 
18
18
  @property
19
- def value(self) -> Optional[AtomicOdxType]:
19
+ def value(self) -> AtomicOdxType | None:
20
20
  return self._value
21
21
 
22
22
  @staticmethod
23
23
  @overload
24
- def limit_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment],
25
- value_type: Optional[DataType]) -> "Limit":
24
+ def limit_from_et(et_element: ElementTree.Element, context: OdxDocContext,
25
+ value_type: DataType | None) -> "Limit":
26
26
  ...
27
27
 
28
28
  @staticmethod
29
29
  @overload
30
- def limit_from_et(et_element: None, doc_frags: List[OdxDocFragment],
31
- value_type: Optional[DataType]) -> None:
30
+ def limit_from_et(et_element: None, context: OdxDocContext,
31
+ value_type: DataType | None) -> None:
32
32
  ...
33
33
 
34
34
  @staticmethod
35
- def limit_from_et(et_element: Optional[ElementTree.Element], doc_frags: List[OdxDocFragment],
36
- value_type: Optional[DataType]) -> Optional["Limit"]:
35
+ def limit_from_et(et_element: ElementTree.Element | None, context: OdxDocContext,
36
+ value_type: DataType | None) -> Optional["Limit"]:
37
37
 
38
38
  if et_element is None:
39
39
  return None
@@ -50,7 +50,7 @@ class Limit:
50
50
  return Limit(value_raw=value_raw, interval_type=interval_type, value_type=value_type)
51
51
 
52
52
  def __post_init__(self) -> None:
53
- self._value: Optional[AtomicOdxType] = None
53
+ self._value: AtomicOdxType | None = None
54
54
 
55
55
  if self.value_type is not None:
56
56
  self.set_value_type(self.value_type)
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType
9
9
  from ..utils import dataclass_fields_asdict
10
10
  from .compucategory import CompuCategory
@@ -12,7 +12,7 @@ from .compumethod import CompuMethod
12
12
  from .linearsegment import LinearSegment
13
13
 
14
14
 
15
- @dataclass
15
+ @dataclass(kw_only=True)
16
16
  class LinearCompuMethod(CompuMethod):
17
17
  """A compu method which does linear interpoation
18
18
 
@@ -30,11 +30,11 @@ class LinearCompuMethod(CompuMethod):
30
30
  return self._segment
31
31
 
32
32
  @staticmethod
33
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
33
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
34
34
  internal_type: DataType,
35
35
  physical_type: DataType) -> "LinearCompuMethod":
36
36
  cm = CompuMethod.compu_method_from_et(
37
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
37
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
38
38
  kwargs = dataclass_fields_asdict(cm)
39
39
 
40
40
  return LinearCompuMethod(**kwargs)
@@ -1,6 +1,5 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import Optional, Union
4
3
 
5
4
  from ..exceptions import odxraise, odxrequire
6
5
  from ..odxtypes import AtomicOdxType, DataType
@@ -8,7 +7,7 @@ from .compuscale import CompuScale
8
7
  from .limit import Limit
9
8
 
10
9
 
11
- @dataclass
10
+ @dataclass(kw_only=True)
12
11
  class LinearSegment:
13
12
  """Helper class to represent a segment of a piecewise-linear interpolation.
14
13
 
@@ -24,20 +23,20 @@ class LinearSegment:
24
23
  offset: float
25
24
  factor: float
26
25
  denominator: float
27
- internal_lower_limit: Optional[Limit]
28
- internal_upper_limit: Optional[Limit]
26
+ internal_lower_limit: Limit | None = None
27
+ internal_upper_limit: Limit | None = None
29
28
 
30
- inverse_value: Union[int, float] # value used as inverse if factor is 0
29
+ inverse_value: int | float # value used as inverse if factor is 0
31
30
 
32
31
  internal_type: DataType
33
32
  physical_type: DataType
34
33
 
35
34
  @property
36
- def physical_lower_limit(self) -> Optional[Limit]:
35
+ def physical_lower_limit(self) -> Limit | None:
37
36
  return self._physical_lower_limit
38
37
 
39
38
  @property
40
- def physical_upper_limit(self) -> Optional[Limit]:
39
+ def physical_upper_limit(self) -> Limit | None:
41
40
  return self._physical_upper_limit
42
41
 
43
42
  @staticmethod
@@ -52,7 +51,7 @@ class LinearSegment:
52
51
  if len(coeffs.denominators) > 0:
53
52
  denominator = coeffs.denominators[0]
54
53
 
55
- inverse_value: Union[int, float] = 0
54
+ inverse_value: int | float = 0
56
55
  if scale.compu_inverse_value is not None:
57
56
  x = odxrequire(scale.compu_inverse_value).value
58
57
  if not isinstance(x, (int, float)):
@@ -75,7 +74,7 @@ class LinearSegment:
75
74
  def __post_init__(self) -> None:
76
75
  self.__compute_physical_limits()
77
76
 
78
- def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> Union[float, int]:
77
+ def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> float | int:
79
78
  if not isinstance(internal_value, (int, float)):
80
79
  odxraise(f"Internal values of linear compumethods must "
81
80
  f"either be int or float (is: {type(internal_value).__name__})")
@@ -90,7 +89,7 @@ class LinearSegment:
90
89
 
91
90
  return result
92
91
 
93
- def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> Union[float, int]:
92
+ def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> float | int:
94
93
  if not isinstance(physical_value, (int, float)):
95
94
  odxraise(f"Physical values of linear compumethods must "
96
95
  f"either be int or float (is: {type(physical_value).__name__})")
@@ -115,7 +114,7 @@ class LinearSegment:
115
114
  This method is called by `__post_init__()`.
116
115
  """
117
116
 
118
- def convert_internal_to_physical_limit(internal_limit: Optional[Limit]) -> Optional[Limit]:
117
+ def convert_internal_to_physical_limit(internal_limit: Limit | None) -> Limit | None:
119
118
  """Helper method to convert a single internal limit
120
119
  """
121
120
  if internal_limit is None or internal_limit.value_raw is None:
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Optional, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType
9
9
  from ..utils import dataclass_fields_asdict
10
10
  from .compucategory import CompuCategory
@@ -12,7 +12,7 @@ from .compumethod import CompuMethod
12
12
  from .ratfuncsegment import RatFuncSegment
13
13
 
14
14
 
15
- @dataclass
15
+ @dataclass(kw_only=True)
16
16
  class RatFuncCompuMethod(CompuMethod):
17
17
  """A compu method using a rational function
18
18
 
@@ -30,15 +30,15 @@ class RatFuncCompuMethod(CompuMethod):
30
30
  return self._int_to_phys_segment
31
31
 
32
32
  @property
33
- def phys_to_int_segment(self) -> Optional[RatFuncSegment]:
33
+ def phys_to_int_segment(self) -> RatFuncSegment | None:
34
34
  return self._phys_to_int_segment
35
35
 
36
36
  @staticmethod
37
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
37
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
38
38
  internal_type: DataType,
39
39
  physical_type: DataType) -> "RatFuncCompuMethod":
40
40
  cm = CompuMethod.compu_method_from_et(
41
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
41
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
42
42
  kwargs = dataclass_fields_asdict(cm)
43
43
 
44
44
  return RatFuncCompuMethod(**kwargs)
@@ -1,6 +1,5 @@
1
1
  # SPDX-License-Identifier: MIT
2
- from dataclasses import dataclass
3
- from typing import List, Optional, Union
2
+ from dataclasses import dataclass, field
4
3
 
5
4
  from ..exceptions import odxraise, odxrequire
6
5
  from ..odxtypes import AtomicOdxType, DataType
@@ -8,17 +7,17 @@ from .compuscale import CompuScale
8
7
  from .limit import Limit
9
8
 
10
9
 
11
- @dataclass
10
+ @dataclass(kw_only=True)
12
11
  class RatFuncSegment:
13
12
  """Helper class to represent a segment of a piecewise rational function.
14
13
  """
15
14
  value_type: DataType
16
15
 
17
- numerator_coeffs: List[Union[int, float]]
18
- denominator_coeffs: List[Union[int, float]]
16
+ numerator_coeffs: list[int | float] = field(default_factory=list)
17
+ denominator_coeffs: list[int | float] = field(default_factory=list)
19
18
 
20
- lower_limit: Optional[Limit]
21
- upper_limit: Optional[Limit]
19
+ lower_limit: Limit | None = None
20
+ upper_limit: Limit | None = None
22
21
 
23
22
  @staticmethod
24
23
  def from_compu_scale(scale: CompuScale, value_type: DataType) -> "RatFuncSegment":
@@ -39,7 +38,7 @@ class RatFuncSegment:
39
38
  upper_limit=upper_limit,
40
39
  value_type=scale.range_type)
41
40
 
42
- def convert(self, value: AtomicOdxType) -> Union[float, int]:
41
+ def convert(self, value: AtomicOdxType) -> float | int:
43
42
  if not isinstance(value, (int, float)):
44
43
  odxraise(f"Internal values of linear compumethods must "
45
44
  f"either be int or float (is: {type(value).__name__})")
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Union, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType
9
9
  from ..utils import dataclass_fields_asdict
10
10
  from .compucategory import CompuCategory
@@ -13,7 +13,7 @@ from .intervaltype import IntervalType
13
13
  from .linearsegment import LinearSegment
14
14
 
15
15
 
16
- @dataclass
16
+ @dataclass(kw_only=True)
17
17
  class ScaleLinearCompuMethod(CompuMethod):
18
18
  """A piecewise linear compu method which may feature discontinuities.
19
19
 
@@ -21,21 +21,21 @@ class ScaleLinearCompuMethod(CompuMethod):
21
21
  """
22
22
 
23
23
  @property
24
- def segments(self) -> List[LinearSegment]:
24
+ def segments(self) -> list[LinearSegment]:
25
25
  return self._segments
26
26
 
27
27
  @staticmethod
28
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
28
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
29
29
  internal_type: DataType,
30
30
  physical_type: DataType) -> "ScaleLinearCompuMethod":
31
31
  cm = CompuMethod.compu_method_from_et(
32
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
32
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
33
33
  kwargs = dataclass_fields_asdict(cm)
34
34
 
35
35
  return ScaleLinearCompuMethod(**kwargs)
36
36
 
37
37
  def __post_init__(self) -> None:
38
- self._segments: List[LinearSegment] = []
38
+ self._segments: list[LinearSegment] = []
39
39
 
40
40
  odxassert(self.category == CompuCategory.SCALE_LINEAR,
41
41
  "ScaleLinearCompuMethod must exibit SCALE-LINEAR category")
@@ -111,7 +111,7 @@ class ScaleLinearCompuMethod(CompuMethod):
111
111
  self._is_invertible = False
112
112
  break
113
113
 
114
- def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> Union[float, int]:
114
+ def convert_physical_to_internal(self, physical_value: AtomicOdxType) -> float | int:
115
115
  if not self._is_invertible:
116
116
  odxraise(
117
117
  f"Trying to encode value {physical_value!r} using a non-invertible "
@@ -128,7 +128,7 @@ class ScaleLinearCompuMethod(CompuMethod):
128
128
 
129
129
  return seg.convert_physical_to_internal(physical_value)
130
130
 
131
- def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> Union[float, int]:
131
+ def convert_internal_to_physical(self, internal_value: AtomicOdxType) -> float | int:
132
132
  applicable_segments = [
133
133
  seg for seg in self._segments if seg.internal_applies(internal_value)
134
134
  ]
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Optional, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType
9
9
  from ..utils import dataclass_fields_asdict
10
10
  from .compucategory import CompuCategory
@@ -12,7 +12,7 @@ from .compumethod import CompuMethod
12
12
  from .ratfuncsegment import RatFuncSegment
13
13
 
14
14
 
15
- @dataclass
15
+ @dataclass(kw_only=True)
16
16
  class ScaleRatFuncCompuMethod(CompuMethod):
17
17
  """A compu method using a piecewise rational function
18
18
 
@@ -20,19 +20,19 @@ class ScaleRatFuncCompuMethod(CompuMethod):
20
20
  """
21
21
 
22
22
  @property
23
- def int_to_phys_segments(self) -> List[RatFuncSegment]:
23
+ def int_to_phys_segments(self) -> list[RatFuncSegment]:
24
24
  return self._int_to_phys_segments
25
25
 
26
26
  @property
27
- def phys_to_int_segments(self) -> Optional[List[RatFuncSegment]]:
27
+ def phys_to_int_segments(self) -> list[RatFuncSegment] | None:
28
28
  return self._phys_to_int_segments
29
29
 
30
30
  @staticmethod
31
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
31
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
32
32
  internal_type: DataType,
33
33
  physical_type: DataType) -> "ScaleRatFuncCompuMethod":
34
34
  cm = CompuMethod.compu_method_from_et(
35
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
35
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
36
36
  kwargs = dataclass_fields_asdict(cm)
37
37
 
38
38
  return ScaleRatFuncCompuMethod(**kwargs)
@@ -1,10 +1,9 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, Union
4
3
  from xml.etree import ElementTree
5
4
 
6
5
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
7
- from ..odxlink import OdxDocFragment
6
+ from ..odxdoccontext import OdxDocContext
8
7
  from ..odxtypes import AtomicOdxType, DataType
9
8
  from ..utils import dataclass_fields_asdict
10
9
  from .compucategory import CompuCategory
@@ -13,7 +12,7 @@ from .intervaltype import IntervalType
13
12
  from .limit import Limit
14
13
 
15
14
 
16
- @dataclass
15
+ @dataclass(kw_only=True)
17
16
  class TabIntpCompuMethod(CompuMethod):
18
17
  """A table-based interpolated compu method provides a continuous
19
18
  transfer function based on piecewise linear interpolation.
@@ -37,11 +36,11 @@ class TabIntpCompuMethod(CompuMethod):
37
36
  """
38
37
 
39
38
  @property
40
- def internal_points(self) -> List[Union[float, int]]:
39
+ def internal_points(self) -> list[float | int]:
41
40
  return self._internal_points
42
41
 
43
42
  @property
44
- def physical_points(self) -> List[Union[float, int]]:
43
+ def physical_points(self) -> list[float | int]:
45
44
  return self._physical_points
46
45
 
47
46
  @property
@@ -61,11 +60,11 @@ class TabIntpCompuMethod(CompuMethod):
61
60
  return self._physical_upper_limit
62
61
 
63
62
  @staticmethod
64
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
63
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
65
64
  internal_type: DataType,
66
65
  physical_type: DataType) -> "TabIntpCompuMethod":
67
66
  cm = CompuMethod.compu_method_from_et(
68
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
67
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
69
68
  kwargs = dataclass_fields_asdict(cm)
70
69
 
71
70
  return TabIntpCompuMethod(**kwargs)
@@ -74,8 +73,8 @@ class TabIntpCompuMethod(CompuMethod):
74
73
  odxassert(self.category == CompuCategory.TAB_INTP,
75
74
  "TabIntpCompuMethod must exibit TAB-INTP category")
76
75
 
77
- self._internal_points: List[Union[int, float]] = []
78
- self._physical_points: List[Union[int, float]] = []
76
+ self._internal_points: list[int | float] = []
77
+ self._physical_points: list[int | float] = []
79
78
  for scale in odxrequire(self.compu_internal_to_phys).compu_scales:
80
79
  internal_point = odxrequire(scale.lower_limit).value
81
80
  physical_point = odxrequire(scale.compu_const).value
@@ -130,10 +129,8 @@ class TabIntpCompuMethod(CompuMethod):
130
129
  ], "Physical data type of TAB-INTP compumethod must be one of"
131
130
  " [A_INT32, A_UINT32, A_FLOAT32, A_FLOAT64]")
132
131
 
133
- def __piecewise_linear_interpolate(self, x: Union[int, float],
134
- range_samples: List[Union[int, float]],
135
- domain_samples: List[Union[int,
136
- float]]) -> Union[float, None]:
132
+ def __piecewise_linear_interpolate(self, x: int | float, range_samples: list[int | float],
133
+ domain_samples: list[int | float]) -> float | None:
137
134
  for i in range(0, len(range_samples) - 1):
138
135
  if (x0 := range_samples[i]) <= x and x <= (x1 := range_samples[i + 1]):
139
136
  y0 = domain_samples[i]
@@ -1,10 +1,10 @@
1
1
  # SPDX-License-Identifier: MIT
2
2
  from dataclasses import dataclass
3
- from typing import List, cast
3
+ from typing import cast
4
4
  from xml.etree import ElementTree
5
5
 
6
6
  from ..exceptions import DecodeError, EncodeError, odxassert, odxraise, odxrequire
7
- from ..odxlink import OdxDocFragment
7
+ from ..odxdoccontext import OdxDocContext
8
8
  from ..odxtypes import AtomicOdxType, DataType
9
9
  from ..utils import dataclass_fields_asdict
10
10
  from .compucategory import CompuCategory
@@ -12,7 +12,7 @@ from .compumethod import CompuMethod
12
12
  from .compuscale import CompuScale
13
13
 
14
14
 
15
- @dataclass
15
+ @dataclass(kw_only=True)
16
16
  class TexttableCompuMethod(CompuMethod):
17
17
  """Text table compute methods translate numbers to human readable
18
18
  textual descriptions.
@@ -22,11 +22,11 @@ class TexttableCompuMethod(CompuMethod):
22
22
  """
23
23
 
24
24
  @staticmethod
25
- def compu_method_from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment], *,
25
+ def compu_method_from_et(et_element: ElementTree.Element, context: OdxDocContext, *,
26
26
  internal_type: DataType,
27
27
  physical_type: DataType) -> "TexttableCompuMethod":
28
28
  cm = CompuMethod.compu_method_from_et(
29
- et_element, doc_frags, internal_type=internal_type, physical_type=physical_type)
29
+ et_element, context, internal_type=internal_type, physical_type=physical_type)
30
30
  kwargs = dataclass_fields_asdict(cm)
31
31
 
32
32
  return TexttableCompuMethod(**kwargs)
@@ -95,7 +95,7 @@ class TexttableCompuMethod(CompuMethod):
95
95
  scales = []
96
96
  if (citp := self.compu_internal_to_phys) is not None:
97
97
  scales = citp.compu_scales
98
- matching_scales: List[CompuScale] = [x for x in scales if x.applies(internal_value)]
98
+ matching_scales: list[CompuScale] = [x for x in scales if x.applies(internal_value)]
99
99
 
100
100
  if len(matching_scales) == 0:
101
101
  if self._compu_physical_default_value is None:
@@ -1,17 +1,15 @@
1
- from typing import List, Union
2
1
  from xml.etree import ElementTree
3
2
 
4
3
  from .comparam import Comparam
5
4
  from .complexcomparam import ComplexComparam
6
- from .odxlink import OdxDocFragment
5
+ from .odxdoccontext import OdxDocContext
7
6
 
8
7
 
9
- def create_any_comparam_from_et(
10
- et_element: ElementTree.Element,
11
- doc_frags: List[OdxDocFragment]) -> Union[Comparam, ComplexComparam]:
8
+ def create_any_comparam_from_et(et_element: ElementTree.Element,
9
+ context: OdxDocContext) -> Comparam | ComplexComparam:
12
10
  if et_element.tag == "COMPARAM":
13
- return Comparam.from_et(et_element, doc_frags)
11
+ return Comparam.from_et(et_element, context)
14
12
  elif et_element.tag == "COMPLEX-COMPARAM":
15
- return ComplexComparam.from_et(et_element, doc_frags)
13
+ return ComplexComparam.from_et(et_element, context)
16
14
 
17
15
  raise RuntimeError(f"Unhandled communication parameter type {et_element.tag}")
@@ -1,5 +1,4 @@
1
1
  # SPDX-License-Identifier: MIT
2
- from typing import List
3
2
  from xml.etree import ElementTree
4
3
 
5
4
  from .diagcodedtype import DiagCodedType
@@ -7,22 +6,22 @@ from .exceptions import odxraise
7
6
  from .globals import xsi
8
7
  from .leadinglengthinfotype import LeadingLengthInfoType
9
8
  from .minmaxlengthtype import MinMaxLengthType
10
- from .odxlink import OdxDocFragment
9
+ from .odxdoccontext import OdxDocContext
11
10
  from .paramlengthinfotype import ParamLengthInfoType
12
11
  from .standardlengthtype import StandardLengthType
13
12
 
14
13
 
15
14
  def create_any_diag_coded_type_from_et(et_element: ElementTree.Element,
16
- doc_frags: List[OdxDocFragment]) -> DiagCodedType:
15
+ context: OdxDocContext) -> DiagCodedType:
17
16
  dct_type = et_element.get(f"{xsi}type")
18
17
  if dct_type == "LEADING-LENGTH-INFO-TYPE":
19
- return LeadingLengthInfoType.from_et(et_element, doc_frags)
18
+ return LeadingLengthInfoType.from_et(et_element, context)
20
19
  elif dct_type == "MIN-MAX-LENGTH-TYPE":
21
- return MinMaxLengthType.from_et(et_element, doc_frags)
20
+ return MinMaxLengthType.from_et(et_element, context)
22
21
  elif dct_type == "PARAM-LENGTH-INFO-TYPE":
23
- return ParamLengthInfoType.from_et(et_element, doc_frags)
22
+ return ParamLengthInfoType.from_et(et_element, context)
24
23
  elif dct_type == "STANDARD-LENGTH-TYPE":
25
- return StandardLengthType.from_et(et_element, doc_frags)
24
+ return StandardLengthType.from_et(et_element, context)
26
25
 
27
26
  odxraise(f"Unknown DIAG-CODED-TYPE {dct_type}", NotImplementedError)
28
- return DiagCodedType.from_et(et_element, doc_frags)
27
+ return DiagCodedType.from_et(et_element, context)