code: def _repack(h5file):
      
      f1, opened = _openfile(h5file) 
      filename1 = f1.filename
      filename2 = filename1 + '_repack_tmp'
      f2 = h5py.File(filename2, 'w')
      for key in f1.keys():
          # print 'copying', key
          f1.copy(key, f2)
      f1.close()
      f2.close()
      filename_tmp = filename1 + '_repack_rename_tmp'
      os.rename(filename1, filename_tmp)
      os.rename(filename2, filename1) 
      if opened:
          f = None  
      else:
          f = h5py.File(filename1)
      os.remove(filename_tmp)
      return f
docs: Repack archive to remove freespace.
                 
      Returns
      -------
      file : h5py File or None
          If the input is a h5py.File then a h5py File instance of the
          repacked archive is returned. The input File instance will no longer
          be useable.