mirror of
https://github.com/python/cpython.git
synced 2025-07-16 07:45:20 +00:00
This commit is contained in:
parent
d3f61a2de6
commit
ae882f7984
11 changed files with 57 additions and 4 deletions
|
@ -150,7 +150,7 @@ def getctime(filename):
|
|||
return os.stat(filename).st_ctime
|
||||
|
||||
def exists(s):
|
||||
"""Return True if the pathname refers to an existing file or directory."""
|
||||
"""Test whether a path exists. Returns False for broken symbolic links"""
|
||||
|
||||
try:
|
||||
st = os.stat(s)
|
||||
|
@ -158,6 +158,18 @@ def exists(s):
|
|||
return False
|
||||
return True
|
||||
|
||||
# Is `stat`/`lstat` a meaningful difference on the Mac? This is safe in any
|
||||
# case.
|
||||
|
||||
def lexists(path):
|
||||
"""Test whether a path exists. Returns True for broken symbolic links"""
|
||||
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
except os.error:
|
||||
return False
|
||||
return True
|
||||
|
||||
# Return the longest prefix of all list elements.
|
||||
|
||||
def commonprefix(m):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue