Skip to content
Snippets Groups Projects
Commit 91bf4fa4 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Fix converting list of paths to nested dicts

parent 6f4b561b
No related branches found
No related tags found
1 merge request!527HDF5 copy except function
......@@ -2,9 +2,10 @@ import h5py
def paths_to_tree(paths):
"""Convert paths to a nested-dict tree, with True at leaves"""
tree = tree_part = {}
tree = {}
for path in paths:
tree_part = tree
path_names = path.strip('/').split('/')
for name in path_names[:-1]:
tree_part = tree_part.setdefault(name, {})
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment