def with_read_hdf5(func):
@wraps(func)<EOL>def decorated_func(fobj, *args, **kwargs):<EOL><INDENT>if not isinstance(fobj, h5py.HLObject):<EOL><INDENT>if isinstance(fobj, FILE_LIKE):<EOL><INDENT>fobj = fobj.name<EOL><DEDENT>with h5py.File(fobj, '<STR_LIT:r>') as h5f:<EOL><INDENT>return func(h5f, *args, **kwargs)<EOL><DEDENT><DEDENT>return func(fobj, *args, **kwargs)<EOL><DEDENT>return decorated_func<EOL>
Decorate an HDF5-reading function to open a filepath if needed

    ``func`` should be written to presume an `h5py.Group` as the first
    positional argument.