<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def with_write_hdf5(func):
 """Decorate an HDF5-writing function to open a filepath if needed ``func`` should be written to take the object to be written as the first argument, and then presume an `h5py.Group` as the second. This method uses keywords ``append`` and ``overwrite`` as follows if the output file already exists: - ``append=False, overwrite=False``: raise `~exceptions.IOError` - ``append=True``: open in mode ``a`` - ``append=False, overwrite=True``: open in mode ``w`` """

    @wraps(func)
    def decorated_func(obj, fobj, *args, **kwargs):
        # pylint: disable=missing-docstring
        if not isinstance(fobj, h5py.HLObject):
            append = kwargs.get('append', False)
            overwrite = kwargs.get('overwrite', False)
            if os.path.exists(fobj) and not (overwrite or append):
                raise IOError("File exists: %s" % fobj)
            with h5py.File(fobj, 'a' if append else 'w') as h5f:
                return func(obj, h5f, *args, **kwargs)
        return func(obj, fobj, *args, **kwargs)

    return decorated_func