mirror of
https://github.com/python/cpython.git
synced 2025-08-12 21:11:35 +00:00
GH-127381: pathlib ABCs: remove ReadablePath.exists()
and is_*()
(#130520)
Remove `ReadablePath` methods duplicated by `ReadablePath.info`. To be specific, we remove `exists()`, `is_dir()`, `is_file()` and `is_symlink()`. The public `Path` class retains these methods.
This commit is contained in:
parent
5181ddb29f
commit
a55dffd66d
3 changed files with 89 additions and 130 deletions
|
@ -219,38 +219,6 @@ class ReadablePath(JoinablePath):
|
|||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def exists(self, *, follow_symlinks=True):
|
||||
"""
|
||||
Whether this path exists.
|
||||
|
||||
This method normally follows symlinks; to check whether a symlink exists,
|
||||
add the argument follow_symlinks=False.
|
||||
"""
|
||||
info = self.joinpath().info
|
||||
return info.exists(follow_symlinks=follow_symlinks)
|
||||
|
||||
def is_dir(self, *, follow_symlinks=True):
|
||||
"""
|
||||
Whether this path is a directory.
|
||||
"""
|
||||
info = self.joinpath().info
|
||||
return info.is_dir(follow_symlinks=follow_symlinks)
|
||||
|
||||
def is_file(self, *, follow_symlinks=True):
|
||||
"""
|
||||
Whether this path is a regular file (also True for symlinks pointing
|
||||
to regular files).
|
||||
"""
|
||||
info = self.joinpath().info
|
||||
return info.is_file(follow_symlinks=follow_symlinks)
|
||||
|
||||
def is_symlink(self):
|
||||
"""
|
||||
Whether this path is a symbolic link.
|
||||
"""
|
||||
info = self.joinpath().info
|
||||
return info.is_symlink()
|
||||
|
||||
@abstractmethod
|
||||
def __open_rb__(self, buffering=-1):
|
||||
"""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue