from __future__ import division

import argparse
import h5py

def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('results_hdf5_fname', type=str)
    parser.add_argument('dset_keys', nargs='*', type=str, default=[])

    args = parser.parse_args()

    f = h5py.File(args.results_hdf5_fname, 'r')
#     import IPython as ipy; ipy.embed()
    for group_key, group in f.items():
        print group_key
        if args.dset_keys:
            for dset_key in args.dset_keys:
                if dset_key in group:
                    print '\t' + dset_key + ':', group[dset_key][()]
        else:
            for dset_key, dset in group.items():
                print '\t' + dset_key + ':', dset[()]

if __name__ == "__main__":
    main()

@@ -187,16 +187,25 @@
 gument('
+group_or_
 dset_key
@@ -326,88 +326,195 @@
 r')%0A
-#
+%0A
     
- import IPython as ipy; ipy.embed()%0A    for group_key, group in f.items():%0A
+def print_group_or_dset(group_or_dset_key, group_or_dset, level=1):%0A        if type(group_or_dset) == h5py.Group:%0A            group_key, group = group_or_dset_key, group_or_dset%0A    
     
@@ -522,16 +522,29 @@
    print
+ '%5Ct'*level +
  group_k
@@ -545,16 +545,22 @@
 roup_key
+ + ':'
 %0A       
@@ -564,98 +564,204 @@
     
-if args.dset_keys:%0A            for 
+    for key, value in group.items():%0A                print_group_or_
 dset
-_key in args.dset_keys:%0A                if 
+(key, value, level=level+1)%0A        elif type(group_or_dset) == h5py.Dataset:%0A            dset_key, dset = group_or_
 dset_key
  in 
@@ -760,25 +760,24 @@
 _key
- in
+,
  group
-:%0A      
+_or_dset%0A
     
@@ -776,34 +776,32 @@
 set%0A            
-  
 print '%5Ct' + dse
@@ -786,32 +786,38 @@
       print '%5Ct'
+*level
  + dset_key + ':
@@ -823,23 +823,12 @@
 :', 
-group%5Bdset_key%5D
+dset
 %5B()%5D
@@ -854,20 +854,114 @@
         
-for 
+raise%0A%0A    for group_key, group in f.items():%0A        print group_key +  ':'%0A        for group_or_
 dset_key
@@ -958,24 +958,33 @@
 r_dset_key, 
+group_or_
 dset in grou
@@ -1010,49 +1010,179 @@
     
-    print '%5Ct' + dset_key + ':', dset%5B()%5D
+if args.group_or_dset_keys and group_or_dset_key not in args.group_or_dset_keys:%0A                continue%0A            print_group_or_dset(group_or_dset_key, group_or_dset)
 %0A%0Aif

Handle nested groups in print_results.py