mirror of
https://github.com/python/cpython.git
synced 2025-08-24 10:45:53 +00:00
gh-118507 : Refactor nt._path_is*
to improve applicability for other cases (GH-118755)
This commit is contained in:
parent
de8f530841
commit
b64182550f
6 changed files with 528 additions and 440 deletions
|
@ -288,21 +288,6 @@ def dirname(p):
|
|||
return split(p)[0]
|
||||
|
||||
|
||||
# Is a path a junction?
|
||||
|
||||
if hasattr(os.stat_result, 'st_reparse_tag'):
|
||||
def isjunction(path):
|
||||
"""Test whether a path is a junction"""
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except (OSError, ValueError, AttributeError):
|
||||
return False
|
||||
return st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
|
||||
else:
|
||||
# Use genericpath.isjunction as imported above
|
||||
pass
|
||||
|
||||
|
||||
# Is a path a mount point?
|
||||
# Any drive letter root (eg c:\)
|
||||
# Any share UNC (eg \\server\share)
|
||||
|
@ -911,13 +896,15 @@ def commonpath(paths):
|
|||
|
||||
|
||||
try:
|
||||
# The isdir(), isfile(), islink() and exists() implementations in
|
||||
# genericpath use os.stat(). This is overkill on Windows. Use simpler
|
||||
# The isdir(), isfile(), islink(), exists() and lexists() implementations
|
||||
# in genericpath use os.stat(). This is overkill on Windows. Use simpler
|
||||
# builtin functions if they are available.
|
||||
from nt import _path_isdir as isdir
|
||||
from nt import _path_isfile as isfile
|
||||
from nt import _path_islink as islink
|
||||
from nt import _path_isjunction as isjunction
|
||||
from nt import _path_exists as exists
|
||||
from nt import _path_lexists as lexists
|
||||
except ImportError:
|
||||
# Use genericpath.* as imported above
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue