Skip to content

Commit 964f58b

Browse files
authored
Merge pull request #625 from FAIRmat-NFDI/update-defs
2 parents 1013f99 + 32f5a85 commit 964f58b

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

src/pynxtools/dataconverter/writer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,12 @@ def __nxdl_to_attrs(self, path: str = "/") -> dict:
230230
del elem.attrib["name"]
231231

232232
# Fetch values for required attributes requested by the NXDL
233-
for attr_name in elem.findall(f"{self.nxs_namespace}attribute"):
234-
key = f"{path}/@{attr_name.get('name')}"
233+
for attr in elem.findall(f"{self.nxs_namespace}attribute"):
234+
name = attr.get("name")
235+
key = f"{path}/@{name}"
235236
if key in self.data:
236-
elem.attrib[attr_name.get("name")] = self.data[key]
237+
value = self.data[key]
238+
elem.attrib[name] = str(value) if isinstance(value, list) else value
237239

238240
return elem.attrib
239241

src/pynxtools/definitions

Submodule definitions updated 42 files

src/pynxtools/nexus-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v2024.02-1926-g297e81c8
1+
v2024.02-1960-g526d415a

src/pynxtools/nomad/schema.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -914,22 +914,22 @@ def _create_class_section(xml_node: ET.Element) -> Section:
914914

915915
if nx_category == "application" or (nx_category == "base" and nx_name == "NXroot"):
916916
nomad_base_sec_cls = (
917-
[NexusMeasurement] if xml_attrs["extends"] == "NXobject" else []
917+
[NexusMeasurement]
918+
if xml_attrs.get("extends") == "NXobject" or nx_name == "NXroot"
919+
else []
918920
)
919921
else:
920922
nomad_base_sec_cls = BASESECTIONS_MAP.get(nx_name, [NexusBaseSection])
921923

922-
nx_name = _rename_nx_for_nomad(nx_name)
923-
class_section: Section = to_section(
924-
nx_name, nx_kind=nx_type, nx_category=nx_category
925-
)
924+
name = _rename_nx_for_nomad(nx_name)
925+
class_section: Section = to_section(name, nx_kind=nx_type, nx_category=nx_category)
926926

927927
if "extends" in xml_attrs:
928928
nx_base_sec = to_section(_rename_nx_for_nomad(xml_attrs["extends"]))
929929
class_section.base_sections = [nx_base_sec] + [
930930
cls.m_def for cls in nomad_base_sec_cls
931931
]
932-
elif _rename_nx_for_nomad(nx_name) == "Object":
932+
elif name == "Object" or name == "Root":
933933
class_section.base_sections = [cls.m_def for cls in nomad_base_sec_cls]
934934

935935
_add_common_properties(xml_node, class_section)

0 commit comments

Comments
 (0)