From 91573855719a397f9487e1f69e9b0d53e37ba5ec Mon Sep 17 00:00:00 2001 From: Rasmus Wriedt Larsen Date: Wed, 22 Jul 2020 17:40:59 +0200 Subject: [PATCH] Python: CG trace: XML can export list of dataclass --- .../recorded-call-graph-metrics/src/cg_trace/exporter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/tools/recorded-call-graph-metrics/src/cg_trace/exporter.py b/python/tools/recorded-call-graph-metrics/src/cg_trace/exporter.py index b6051a01a16..93874c4b306 100644 --- a/python/tools/recorded-call-graph-metrics/src/cg_trace/exporter.py +++ b/python/tools/recorded-call-graph-metrics/src/cg_trace/exporter.py @@ -11,6 +11,10 @@ def dataclass_to_xml(obj, parent): value = getattr(obj, field.name) if isinstance(value, (str, int)) or value is None: field_elem.text = str(value) + elif isinstance(value, list): + for list_elem in value: + assert dataclasses.is_dataclass(list_elem) + dataclass_to_xml(list_elem, field_elem) elif dataclasses.is_dataclass(value): dataclass_to_xml(value, field_elem) else: