diff options
author | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2018-10-04 16:38:37 +0200 |
---|---|---|
committer | Picca Frédéric-Emmanuel <picca@synchrotron-soleil.fr> | 2018-10-04 16:38:37 +0200 |
commit | 0858ae05ae7039b281bd6460c91455b3c1e88eeb (patch) | |
tree | 3657ea543253de8bc1b2d276694562322a3facc1 | |
parent | f58bd7c3ab3bd5c81d9b0a8ffc3841dd482a04eb (diff) |
fix a python3 issue with numpy bytes array
-rw-r--r-- | binoculars/backends/sixs.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/binoculars/backends/sixs.py b/binoculars/backends/sixs.py index afe7bf8..f635b73 100644 --- a/binoculars/backends/sixs.py +++ b/binoculars/backends/sixs.py @@ -203,19 +203,23 @@ def get_nxclass(hfile, nxclass, path="/"): """ for node in hfile.walk_nodes(path): try: - if nxclass == node._v_attrs['NX_class']: + if nxclass == as_string(node._v_attrs['NX_class']): return node except KeyError: pass return None +def as_string(text): + if hasattr(text, "decode"): + text = text.decode() + return text -def as_string(node): +def node_as_string(node): if node.shape == (): - return str(node.read()) + content = node.read().tostring() else: - return node[0] - + content = node[0] + return as_string(content) Diffractometer = namedtuple('Diffractometer', ['name', # name of the hkl diffractometer @@ -227,7 +231,7 @@ def get_diffractometer(hfile): """ Construct a Diffractometer from a NeXus file """ node = get_nxclass(hfile, 'NXdiffractometer') - name = as_string(node.type) + name = node_as_string(node.type) # remove the last "\n" char name = name[:-1] |