From f414df38cae91779c400efc8d9136696143e48ed Mon Sep 17 00:00:00 2001 From: Jan Range Date: Mon, 11 Nov 2024 17:49:51 +0100 Subject: [PATCH] transfer #30 to new branch --- easyDataverse/dataverse.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/easyDataverse/dataverse.py b/easyDataverse/dataverse.py index 89473d4..a0c9104 100644 --- a/easyDataverse/dataverse.py +++ b/easyDataverse/dataverse.py @@ -479,13 +479,19 @@ def _extract_data(self, fields: List, tree: Node): data = {} for field in fields: - node = findall_by_attr(tree, field.typeName, "typeName")[0] - name = node.name - dvtype = node.typeClass + result = findall_by_attr(tree, field.typeName, "typeName") - if dvtype.lower() == "compound": - data[name] = self._process_compound(field.value, tree) + if len(result) > 0: + node = result[0] + name = node.name + dvtype = node.typeClass + + if dvtype.lower() == "compound": + data[name] = self._process_compound(field.value, tree) + else: + data[name] = field.value else: + name = field.typeName data[name] = field.value return data