From 279ba0eaaf876ab4ba096412470c0b586d601aae Mon Sep 17 00:00:00 2001 From: domna Date: Fri, 19 Jan 2024 13:04:38 +0100 Subject: [PATCH] Properly deal with undocumented @units as discussed w/ @sherjeelshabih --- pynxtools/dataconverter/helpers.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/pynxtools/dataconverter/helpers.py b/pynxtools/dataconverter/helpers.py index 4cfe492b9..c7889e427 100644 --- a/pynxtools/dataconverter/helpers.py +++ b/pynxtools/dataconverter/helpers.py @@ -545,10 +545,15 @@ def try_undocumented(data, nxdl_root: ET.Element): nxdl_path = convert_data_converter_dict_to_nxdl_path(path) if entry_name == "@units": - if ( - path.rsplit("/", 1)[0] in data.get_documented() - and path in data.undocumented - ): + field_path = path.rsplit("/", 1)[0] + if field_path in data.get_documented() and path in data.undocumented: + field_requiredness = get_required_string( + nexus.get_node_at_nxdl_path( + nxdl_path=convert_data_converter_dict_to_nxdl_path(field_path), + elem=nxdl_root, + ) + ) + data[field_requiredness][path] = data.undocumented[path] del data.undocumented[path] continue