diff options
author | Nice Zombies <nineteendo19d0@gmail.com> | 2024-03-25 23:55:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-25 22:55:11 +0000 |
commit | 0821923aa979a72464c5da8dfa53a719bba5801c (patch) | |
tree | 1486b42a70c2cfbbc230ee56a9812b164754ea66 /Lib/genericpath.py | |
parent | c2276176d543a2fc2d57709c2787f99850fbb073 (diff) | |
download | cpython-0821923aa979a72464c5da8dfa53a719bba5801c.tar.gz cpython-0821923aa979a72464c5da8dfa53a719bba5801c.zip |
gh-117114: Make os.path.isdevdrive available on all platforms (GH-117115)
Diffstat (limited to 'Lib/genericpath.py')
-rw-r--r-- | Lib/genericpath.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Lib/genericpath.py b/Lib/genericpath.py index 1bd5b3897c3..ba7b0a13c7f 100644 --- a/Lib/genericpath.py +++ b/Lib/genericpath.py @@ -7,8 +7,8 @@ import os import stat __all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime', - 'getsize', 'isdir', 'isfile', 'islink', 'samefile', 'sameopenfile', - 'samestat'] + 'getsize', 'isdevdrive', 'isdir', 'isfile', 'isjunction', 'islink', + 'lexists', 'samefile', 'sameopenfile', 'samestat'] # Does a path exist? @@ -22,6 +22,15 @@ def exists(path): return True +# Being true for dangling symbolic links is also useful. +def lexists(path): + """Test whether a path exists. Returns True for broken symbolic links""" + try: + os.lstat(path) + except (OSError, ValueError): + return False + return True + # This follows symbolic links, so both islink() and isdir() can be true # for the same path on systems that support symlinks def isfile(path): @@ -57,6 +66,21 @@ def islink(path): return stat.S_ISLNK(st.st_mode) +# Is a path a junction? +def isjunction(path): + """Test whether a path is a junction + Junctions are not supported on the current platform""" + os.fspath(path) + return False + + +def isdevdrive(path): + """Determines whether the specified path is on a Windows Dev Drive. + Dev Drives are not supported on the current platform""" + os.fspath(path) + return False + + def getsize(filename): """Return the size of a file, reported by os.stat().""" return os.stat(filename).st_size |