mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-30618: add readlink to pathlib.Path (GH-8285)
This adds a "readlink" method to pathlib.Path objects that calls through to os.readlink. https://bugs.python.org/issue30618 Automerge-Triggered-By: @gpshead
This commit is contained in:
parent
01659ca62c
commit
a01ba333af
5 changed files with 41 additions and 0 deletions
|
@ -1244,6 +1244,15 @@ class Path(PurePath):
|
|||
with self.open(mode='w', encoding=encoding, errors=errors) as f:
|
||||
return f.write(data)
|
||||
|
||||
def readlink(self):
|
||||
"""
|
||||
Return the path to which the symbolic link points.
|
||||
"""
|
||||
path = self._accessor.readlink(self)
|
||||
obj = self._from_parts((path,), init=False)
|
||||
obj._init(template=self)
|
||||
return obj
|
||||
|
||||
def touch(self, mode=0o666, exist_ok=True):
|
||||
"""
|
||||
Create this file with the given access mode, if it doesn't exist.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue