Here are the examples of the python api mockfs.util.is_dir taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
5 Examples
3
Example 1
Project: mockfs Source File: mfs.py
def read(self, path):
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:
return entry[basename]
except KeyError:
raise _OSError(errno.ENOENT, path)
3
Example 2
def isdir(self, path):
"""
Return True if path is a directory
Implements the :func:`os.path.isdir` interface.
"""
return util.is_dir(self._direntry(path))
3
Example 3
def chdir(self, path):
# Make it absolute
if os.path.isabs(path):
cdpath = path
else:
cdpath = os.path.join(self._cwd, path)
entry = self._mfs._direntry(path)
if entry is None:
raise _OSError(errno.ENOENT, path)
elif not util.is_dir(entry):
raise _OSError(errno.ENOTDIR, path)
self._cwd = _abspath_builtin(cdpath)
0
Example 4
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]
0
Example 5
def rmdir(self, fspath):
"""Remove the entry for a directory path
Implements the :func:`os.rmdir` interface.
"""
path = self.abspath(fspath)
dirname = os.path.dirname(path)
basename = os.path.basename(path)
entry = self._direntry(dirname)
if not util.is_dir(entry):
raise _OSError(errno.ENOENT, path)
try:
direntry = entry[basename]
except KeyError:
raise _OSError(errno.ENOENT, fspath)
if not util.is_dir(direntry):
raise _OSError(errno.ENOTDIR, fspath)
if len(direntry) != 0:
raise _OSError(errno.ENOTEMPTY, fspath)
del entry[basename]