Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
kmap
xsocs
Commits
7eb6822c
Commit
7eb6822c
authored
Nov 29, 2018
by
Thomas Vincent
Browse files
check if decode is available before calling it
parent
e624fd83
Changes
2
Hide whitespace changes
Inline
Side-by-side
xsocs/gui/project/Hdf5Nodes.py
View file @
7eb6822c
...
...
@@ -59,7 +59,9 @@ def getNodeClass(nodeType, attrs=None):
for
key
,
value
in
attrs
.
items
():
info
=
_registeredAttributes
.
get
(
key
)
if
info
:
klass
=
info
.
get
(
value
.
decode
())
if
hasattr
(
value
,
'decode'
):
value
=
value
.
decode
()
klass
=
info
.
get
(
value
)
if
klass
:
break
if
not
klass
:
...
...
@@ -291,7 +293,7 @@ class H5DatasetNode(H5Base):
ndims
=
len
(
item
.
shape
)
if
ndims
==
0
:
data
=
item
[()]
if
isinstance
(
data
,
(
np
.
string_
,
bytes_type
)
):
if
hasattr
(
data
,
'decode'
):
text
=
data
.
decode
().
replace
(
'
\n
'
,
' '
)
else
:
text
=
str
(
data
)
...
...
xsocs/gui/project/ProjectItem.py
View file @
7eb6822c
...
...
@@ -59,10 +59,10 @@ def projectItemFactory(h5File, h5Path, mode=None):
klass
=
None
with
h5py
.
File
(
h5File
,
mode
=
'r'
)
as
h5f
:
attrs
=
h5f
[
h5Path
].
attrs
# For some reason attrs.get sometimes fails,
# using "in" seems a bit more robust.
if
'XsocsClass'
in
attrs
:
xsocsClass
=
attrs
[
'XsocsClass'
].
decode
()
xsocsClass
=
attrs
[
'XsocsClass'
]
if
hasattr
(
xsocsClass
,
'decode'
):
xsocsClass
=
xsocsClass
.
decode
()
klass
=
getItemClass
(
xsocsClass
)
del
attrs
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment