From adafd2d2d6ca02a894277614105d1d46a1c07d47 Mon Sep 17 00:00:00 2001 From: Paul Natsuo Kishimoto Date: Wed, 28 Aug 2024 13:35:17 +0200 Subject: [PATCH] Improve XMLEventReader.maintainable() Handle the case where the existing object is concrete, not an external reference, but has no URN set (e.g. because not given in the source message) by computing a URN. --- sdmx/reader/xml/common.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sdmx/reader/xml/common.py b/sdmx/reader/xml/common.py index d26de88c..929e71d9 100644 --- a/sdmx/reader/xml/common.py +++ b/sdmx/reader/xml/common.py @@ -579,10 +579,13 @@ def maintainable(self, cls, elem, **kwargs): existing = self.get_single(cls, obj.id, version=obj.version) if existing and ( - existing.compare(obj, strict=True) or existing.urn == sdmx.urn.make(obj) + existing.compare(obj, strict=True) + or (existing.urn or sdmx.urn.make(existing)) == sdmx.urn.make(obj) ): if elem is not None: # Previously an external reference, now concrete + # FIXME Handle the case where a MaintainableArtefact is included in a + # StructureMessage, with is_external_reference explicitly True existing.is_external_reference = False # Update `existing` from `obj` to preserve references @@ -616,6 +619,7 @@ def matching_class(cls): def setdefault_attrib(target, elem, *names): + """Update `target` from :py:`elem.attrib` for the given `names`.""" try: for name in names: try: