Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Vasudevan, Rama K
pycroscopy
Commits
8dcce107
Commit
8dcce107
authored
Mar 02, 2017
by
Chris Smith
Browse files
Refactor ioHDF5 writing
Changed loops over attributes to use iteritems Skip writing attribute if value is None
parent
691fdf5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
pycroscopy/io/io_hdf5.py
View file @
8dcce107
...
...
@@ -158,8 +158,8 @@ class ioHDF5(object):
# Figuring out if the first item in AFMData tree is file or group
if
data
.
name
is
''
and
data
.
parent
is
'/'
:
# For file we just write the attributes
for
key
in
data
.
attrs
.
iter
key
s
():
f
.
attrs
[
key
]
=
data
.
attrs
[
key
]
for
key
,
val
in
data
.
attrs
.
iter
item
s
():
f
.
attrs
[
key
]
=
val
if
print_log
:
print
(
'Wrote attributes of file {}
\n
'
.
format
(
f
.
name
))
root
=
f
.
name
else
:
...
...
@@ -187,10 +187,10 @@ class ioHDF5(object):
f
.
flush
()
f
.
close
()
raise
for
key
in
data
.
attrs
.
iter
key
s
():
if
data
.
attrs
[
key
]
is
None
:
for
key
,
val
in
data
.
attrs
.
iter
item
s
():
if
val
is
None
:
continue
g
.
attrs
[
key
]
=
data
.
attrs
[
key
]
g
.
attrs
[
key
]
=
val
if
print_log
:
print
(
'Wrote attributes to group: {}
\n
'
.
format
(
data
.
name
))
root
=
g
.
name
...
...
@@ -218,8 +218,11 @@ class ioHDF5(object):
f
.
flush
()
f
.
close
()
raise
for
key
in
child
.
attrs
.
iterkeys
():
itm
.
attrs
[
key
]
=
child
.
attrs
[
key
]
for
key
,
val
in
child
.
attrs
.
iteritems
():
print
key
,
val
if
val
is
None
:
continue
itm
.
attrs
[
key
]
=
val
if
print_log
:
print
(
'Wrote attributes to group {}
\n
'
.
format
(
itm
.
name
))
# here we do the recursive function call
for
ch
in
child
.
children
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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