class _NormalAccessor(_Accessor):
- def _wrap_strfunc(strfunc):
- @functools.wraps(strfunc)
- def wrapped(pathobj, *args):
- return strfunc(str(pathobj), *args)
- return staticmethod(wrapped)
+ stat = os.stat
- def _wrap_binary_strfunc(strfunc):
- @functools.wraps(strfunc)
- def wrapped(pathobjA, pathobjB, *args):
- return strfunc(str(pathobjA), str(pathobjB), *args)
- return staticmethod(wrapped)
+ lstat = os.lstat
- stat = _wrap_strfunc(os.stat)
+ open = os.open
- lstat = _wrap_strfunc(os.lstat)
+ listdir = os.listdir
- open = _wrap_strfunc(os.open)
+ scandir = os.scandir
- listdir = _wrap_strfunc(os.listdir)
-
- scandir = _wrap_strfunc(os.scandir)
-
- chmod = _wrap_strfunc(os.chmod)
+ chmod = os.chmod
if hasattr(os, "lchmod"):
- lchmod = _wrap_strfunc(os.lchmod)
+ lchmod = os.lchmod
else:
def lchmod(self, pathobj, mode):
raise NotImplementedError("lchmod() not available on this system")
- mkdir = _wrap_strfunc(os.mkdir)
+ mkdir = os.mkdir
- unlink = _wrap_strfunc(os.unlink)
+ unlink = os.unlink
- rmdir = _wrap_strfunc(os.rmdir)
+ rmdir = os.rmdir
- rename = _wrap_binary_strfunc(os.rename)
+ rename = os.rename
- replace = _wrap_binary_strfunc(os.replace)
+ replace = os.replace
if nt:
if supports_symlinks:
- symlink = _wrap_binary_strfunc(os.symlink)
+ symlink = os.symlink
else:
def symlink(a, b, target_is_directory):
raise NotImplementedError("symlink() not available on this system")
# Under POSIX, os.symlink() takes two args
@staticmethod
def symlink(a, b, target_is_directory):
- return os.symlink(str(a), str(b))
+ return os.symlink(a, b)
- utime = _wrap_strfunc(os.utime)
+ utime = os.utime
# Helper for resolve()
def readlink(self, path):
def __bytes__(self):
"""Return the bytes representation of the path. This is only
recommended to use under Unix."""
- return os.fsencode(str(self))
+ return os.fsencode(self)
def __repr__(self):
return "{}({!r})".format(self.__class__.__name__, self.as_posix())
"""
if self._closed:
self._raise_closed()
- return io.open(str(self), mode, buffering, encoding, errors, newline,
+ return io.open(self, mode, buffering, encoding, errors, newline,
opener=self._opener)
def read_bytes(self):