def open_file(filename, mode="r", title="", root_uep="/", filters=None,
              **kwargs):

    # XXX filename normalization ??

    # Check already opened files
    if _FILE_OPEN_POLICY == 'strict':
        # This policy do not allows to open the same file multiple times
        # even in read-only mode
        if filename in _open_files:
            raise ValueError(
                "The file '%s' is already opened.  "
                "Please close it before reopening.  "
                "HDF5 v.%s, FILE_OPEN_POLICY = '%s'" % (
                    filename, utilsextension.get_hdf5_version(),
                    _FILE_OPEN_POLICY))
    else:
        for filehandle in _open_files.get_handlers_by_name(filename):
            omode = filehandle.mode
            # 'r' is incompatible with everything except 'r' itself
            if mode == 'r' and omode != 'r':
                raise ValueError(
                    "The file '%s' is already opened, but "
                    "not in read-only mode (as requested)." % filename)
            # 'a' and 'r+' are compatible with everything except 'r'
            elif mode in ('a', 'r+') and omode == 'r':
                raise ValueError(
                    "The file '%s' is already opened, but "
                    "in read-only mode.  Please close it before "
                    "reopening in append mode." % filename)
            # 'w' means that we want to destroy existing contents
            elif mode == 'w':
                raise ValueError(
                    "The file '%s' is already opened.  Please "
                    "close it before reopening in write mode." % filename)

    # Finally, create the File instance, and return it
    return File(filename, mode, title, root_uep, filters, **kwargs)



# A dumb class that doesn't keep nothing at all
Open a PyTables (or generic HDF5) file and return a File object.
dataset/ETHPy150Open PyTables/PyTables/tables/file.py/open_file