Skip to content

Commit

Permalink
Merge pull request #346 from andlaus/fix_diag_layer_docfrags
Browse files Browse the repository at this point in the history
Fix the document fragments for objects not featured by the base diag layer
  • Loading branch information
andlaus authored Sep 21, 2024
2 parents ba81e22 + bf4fb91 commit 2261174
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
8 changes: 7 additions & 1 deletion odxtools/diaglayers/basevariantraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,13 @@ def diag_variables(self) -> NamedItemList[DiagVariable]:
@staticmethod
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "BaseVariantRaw":
kwargs = dataclass_fields_asdict(HierarchyElementRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
her = HierarchyElementRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(her)
doc_frags = her.odx_id.doc_fragments

diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]] = []
if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
Expand Down
8 changes: 7 additions & 1 deletion odxtools/diaglayers/ecushareddataraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ def diag_variables(self) -> NamedItemList[DiagVariable]:
@staticmethod
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "EcuSharedDataRaw":
kwargs = dataclass_fields_asdict(DiagLayerRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
dlr = DiagLayerRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(dlr)
doc_frags = dlr.odx_id.doc_fragments

diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]] = []
if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
Expand Down
8 changes: 7 additions & 1 deletion odxtools/diaglayers/ecuvariantraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,13 @@ def diag_variables(self) -> NamedItemList[DiagVariable]:
@staticmethod
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "EcuVariantRaw":
kwargs = dataclass_fields_asdict(HierarchyElementRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
her = HierarchyElementRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(her)
doc_frags = her.odx_id.doc_fragments

diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]] = []
if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
Expand Down
8 changes: 7 additions & 1 deletion odxtools/diaglayers/functionalgroupraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@ def diag_variables(self) -> NamedItemList[DiagVariable]:
@staticmethod
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "FunctionalGroupRaw":
kwargs = dataclass_fields_asdict(HierarchyElementRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
her = HierarchyElementRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(her)
doc_frags = her.odx_id.doc_fragments

diag_variables_raw: List[Union[DiagVariable, OdxLinkRef]] = []
if (dv_elems := et_element.find("DIAG-VARIABLES")) is not None:
Expand Down
8 changes: 7 additions & 1 deletion odxtools/diaglayers/hierarchyelementraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ class HierarchyElementRaw(DiagLayerRaw):
@staticmethod
def from_et(et_element: ElementTree.Element,
doc_frags: List[OdxDocFragment]) -> "HierarchyElementRaw":
kwargs = dataclass_fields_asdict(DiagLayerRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
dlr = DiagLayerRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(dlr)
doc_frags = dlr.odx_id.doc_fragments

comparam_refs = [
ComparamInstance.from_et(el, doc_frags)
Expand Down
8 changes: 7 additions & 1 deletion odxtools/diaglayers/protocolraw.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ def prot_stack(self) -> Optional[ProtStack]:

@staticmethod
def from_et(et_element: ElementTree.Element, doc_frags: List[OdxDocFragment]) -> "ProtocolRaw":
kwargs = dataclass_fields_asdict(HierarchyElementRaw.from_et(et_element, doc_frags))
# objects contained by diagnostic layers exibit an additional
# document fragment for the diag layer, so we use the document
# fragments of the odx id of the diag layer for IDs of
# contained objects.
her = HierarchyElementRaw.from_et(et_element, doc_frags)
kwargs = dataclass_fields_asdict(her)
doc_frags = her.odx_id.doc_fragments

comparam_spec_ref = OdxLinkRef.from_et(
odxrequire(et_element.find("COMPARAM-SPEC-REF")), doc_frags)
Expand Down

0 comments on commit 2261174

Please sign in to comment.