Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return staticmethod(_wrapped)
def _wrap_binary_strfunc_reverse(strfunc):
@functools.wraps(strfunc)
def _wrapped(pathobj1, pathobj2, *args):
return strfunc(pathobj2.filesystem, str(pathobj2), str(pathobj1), *args)
return staticmethod(_wrapped)
class _FakeAccessor(pathlib._Accessor): # pylint: disable=protected-access
"""Accessor which forwards some of the functions to FakeFilesystem methods."""
stat = _wrap_strfunc(FakeFilesystem.stat)
lstat = _wrap_strfunc(lambda fs, path: FakeFilesystem.stat(fs, path,
follow_symlinks=False))
listdir = _wrap_strfunc(FakeFilesystem.listdir)
chmod = _wrap_strfunc(FakeFilesystem.chmod)
if sys.version_info >= (3, 6):
scandir = _wrap_strfunc(fake_scandir.scandir)
if hasattr(os, "lchmod"):
lchmod = _wrap_strfunc(lambda fs, path, mode: FakeFilesystem.chmod(
fs, path, mode, follow_symlinks=False))
else:
def lchmod(self, pathobj, mode):
pathobj2.filesystem, str(pathobj2), str(pathobj1), *args)
return staticmethod(_wrapped)
try:
accessor = pathlib._Accessor
except AttributeError:
accessor = object
class _FakeAccessor(accessor):
"""Accessor which forwards some of the functions to FakeFilesystem methods.
"""
stat = _wrap_strfunc(FakeFilesystem.stat)
lstat = _wrap_strfunc(
lambda fs, path: FakeFilesystem.stat(fs, path, follow_symlinks=False))
listdir = _wrap_strfunc(FakeFilesystem.listdir)
chmod = _wrap_strfunc(FakeFilesystem.chmod)
if use_scandir:
scandir = _wrap_strfunc(fake_scandir.scandir)
if hasattr(os, "lchmod"):
lchmod = _wrap_strfunc(lambda fs, path, mode: FakeFilesystem.chmod(
fs, path, mode, follow_symlinks=False))
else:
def lchmod(self, pathobj, mode):
lambda fs, path: FakeFilesystem.stat(fs, path, follow_symlinks=False))
lstat = _wrap_strfunc(lambda fs, path: FakeFilesystem.stat(fs, path,
follow_symlinks=False))