Use os.walk instead of _get_leaf_paths.
@@ -31,19 +31,11 @@ def load_results(dataset, count, definitions):
yield definition, f
f.close()
-def _get_leaf_paths(path):
- if os.path.isdir(path):
- for fragment in os.listdir(path):
- for i in _get_leaf_paths(os.path.join(path, fragment)):
- yield i
- elif os.path.isfile(path):
- yield path
-
def load_all_results():
- import re
- for fn in _get_leaf_paths("results/"):
+ for root, _, files in os.walk("results/"):
+ for fn in files:
try:
- f = h5py.File(fn)
+ f = h5py.File(os.path.join(root, fn))
yield f
f.close()
except:
