Skip to content

Commit

Permalink
Merge pull request #283 from FAIRmat-NFDI/convert_binary_strings
Browse files Browse the repository at this point in the history
decode binary strings in nxdl_utils.py
  • Loading branch information
lukaspie authored Sep 11, 2024
2 parents 05df4f0 + bbf8060 commit 7f0c0c8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion dev_tools/utils/nxdl_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@
from lxml.etree import ParseError as xmlER


def decode_or_not(elem):
"""Decodes a byte array to string if necessary"""
if isinstance(elem, bytes):
elem = elem.decode("UTF-8")
return elem


def remove_namespace_from_tag(tag):
"""Helper function to remove the namespace from an XML tag."""

Expand Down Expand Up @@ -770,7 +777,7 @@ def get_best_child(nxdl_elem, hdf_node, hdf_name, hdf_class_name, nexus_type):
and nxdl_elem.attrib["name"] == "NXdata"
and hdf_node is not None
and hdf_node.parent is not None
and hdf_node.parent.attrs.get("NX_class") == "NXdata"
and decode_or_not(hdf_node.parent.attrs.get("NX_class")) == "NXdata"
):
(fnd_child, fit) = get_best_nxdata_child(nxdl_elem, hdf_node, hdf_name)
if fnd_child is not None:
Expand Down

0 comments on commit 7f0c0c8

Please sign in to comment.