diff --git a/odxtools/diaglayers/diaglayer.py b/odxtools/diaglayers/diaglayer.py index 2f3766fc..e6884d8d 100644 --- a/odxtools/diaglayers/diaglayer.py +++ b/odxtools/diaglayers/diaglayer.py @@ -124,7 +124,7 @@ def _resolve_odxlinks(self, odxlinks: OdxLinkDatabase) -> None: # imported references only apply within this specific # diagnostic layer extended_odxlinks = copy(odxlinks) - extended_odxlinks.update(imported_links) + extended_odxlinks.update(imported_links, overwrite=False) self.diag_layer_raw._resolve_odxlinks(extended_odxlinks) return diff --git a/odxtools/odxlink.py b/odxtools/odxlink.py index 36b66ebb..259be053 100644 --- a/odxtools/odxlink.py +++ b/odxtools/odxlink.py @@ -230,7 +230,7 @@ def resolve_lenient(self, return None - def update(self, new_entries: Dict[OdxLinkId, Any]) -> None: + def update(self, new_entries: Dict[OdxLinkId, Any], *, overwrite: bool = True) -> None: """ Add a bunch of new objects to the ODXLINK database. @@ -244,7 +244,10 @@ def update(self, new_entries: Dict[OdxLinkId, Any]) -> None: if doc_frag not in self._db: self._db[doc_frag] = {} - self._db[doc_frag][odx_id.local_id] = obj + if overwrite: + self._db[doc_frag][odx_id.local_id] = obj + else: + self._db[doc_frag].setdefault(odx_id.local_id, obj) @overload