<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def open(self, tid, flags):
 """ File open. ``YTStor`` object associated with this file is initialised and written to ``self.fds``. Parameters tid : str Path to file. Original `path` argument is converted to tuple identifier by ``_pathdec`` decorator. flags : int File open mode. Read-only access is allowed. Returns ------- int New file descriptor """


        pt = self.PathType.get(tid)

        if pt is not self.PathType.file and pt is not self.PathType.ctrl:
            raise FuseOSError(errno.EINVAL)

        if pt is not self.PathType.ctrl and (flags & os.O_WRONLY or flags & os.O_RDWR):
            raise FuseOSError(errno.EPERM)

        if not self.__exists(tid):
            raise FuseOSError(errno.ENOENT)

        try:
            yts = self.searches[tid[0]][tid[1]]

        except KeyError:
            return self.fds.push(None) # for control file no association is needed.

        try:
            obI = yts.obtainInfo() # network may fail
        except ConnectionError:
            raise FuseOSError(errno.ENETDOWN)

        if obI:
            fh = self.fds.push(yts)

            try:
                yts.registerHandler(fh)
            except ConnectionError:
                raise FuseOSError(errno.ENETDOWN)

            return fh
        else:
            raise FuseOSError(errno.EINVAL)