Пример #1
0
Файл: mfs.py Проект: ogsy/mockfs
    def isfile(self, path):
        """
        Return True if path is a file

        Implements the :func:`os.path.isfile` interface.

        """
        return util.is_file(self._direntry(path))
Пример #2
0
    def isfile(self, path):
        """
        Return True if path is a file

        Implements the :func:`os.path.isfile` interface.

        """
        return util.is_file(self._direntry(path))
Пример #3
0
Файл: mfs.py Проект: ogsy/mockfs
    def listdir(self, path):
        """
        Return the directory contents of 'path'

        Implements the :func:`os.listdir` interface.
        :param path: filesystem path

        """
        direntry = self._direntry(path)
        if direntry is None:
            raise _OSError(errno.ENOENT, path)
        if util.is_file(direntry):
            raise _OSError(errno.ENOTDIR, path)
        if util.is_dir(direntry):
            return list(sorted(direntry.keys()))
        raise _OSError(errno.EINVAL, path)
Пример #4
0
    def listdir(self, path):
        """
        Return the directory contents of 'path'

        Implements the :func:`os.listdir` interface.
        :param path: filesystem path

        """
        direntry = self._direntry(path)
        if direntry is None:
            raise _OSError(errno.ENOENT, path)
        if util.is_file(direntry):
            raise _OSError(errno.ENOTDIR, path)
        if util.is_dir(direntry):
            return list(sorted(direntry.keys()))
        raise _OSError(errno.EINVAL, path)
Пример #5
0
Файл: mfs.py Проект: ogsy/mockfs
    def remove(self, path):
        """Remove the entry for a file path

        Implements the :func:`os.remove` interface.

        """
        path = self.abspath(path)
        dirname = os.path.dirname(path)
        basename = os.path.basename(path)
        entry = self._direntry(dirname)
        if not util.is_dir(entry):
            raise _OSError(errno.EPERM, path)

        try:
            fsentry = entry[basename]
        except KeyError:
            raise _OSError(errno.ENOENT, path)

        if not util.is_file(fsentry):
            raise _OSError(errno.EPERM, path)

        del entry[basename]
Пример #6
0
    def remove(self, path):
        """Remove the entry for a file path

        Implements the :func:`os.remove` interface.

        """
        path = self.abspath(path)
        dirname = os.path.dirname(path)
        basename = os.path.basename(path)
        entry = self._direntry(dirname)
        if not util.is_dir(entry):
            raise _OSError(errno.EPERM, path)

        try:
            fsentry = entry[basename]
        except KeyError:
            raise _OSError(errno.ENOENT, path)

        if not util.is_file(fsentry):
            raise _OSError(errno.EPERM, path)

        del entry[basename]