From 285eeb0dfdb2c79338f5af1f70d92cabd66832c2 Mon Sep 17 00:00:00 2001 From: "i.nueske" <i.nueske@indiscale.com> Date: Fri, 22 Nov 2024 08:45:31 +0100 Subject: [PATCH] BUG: to_xml now also filters out TransactionBenchmark tags, root being noscript or TransactionBenchmark does not cause error --- src/linkahead/common/models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/linkahead/common/models.py b/src/linkahead/common/models.py index 0dee8239..6204e119 100644 --- a/src/linkahead/common/models.py +++ b/src/linkahead/common/models.py @@ -3284,7 +3284,7 @@ class Container(list): if add_to_element is None: add_to_element = etree.Element("Entities") - noscript_in_supplied_xml = list(add_to_element.iter("noscript")) + noscript_in_supplied_xml = list(add_to_element.iter("noscript", "TransactionBenchmark")) for m in self.messages: add_to_element.append(m.to_xml()) @@ -3301,10 +3301,12 @@ class Container(list): elem = e.to_xml() add_to_element.append(elem) - # remove noscript elements added by this function - for elem in list(add_to_element.iter("noscript")): + # remove noscript and benchmark elements added by this function + for elem in list(add_to_element.iter("noscript", "TransactionBenchmark")): if elem not in noscript_in_supplied_xml: - elem.getparent().remove(elem) + parent = elem.getparent() + if parent is not None: + parent.remove(elem) return add_to_element -- GitLab