Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: genericpath.py
"""
[0] Fix | Delete
Path operations common to more than one OS
[1] Fix | Delete
Do not use directly. The OS specific modules import the appropriate
[2] Fix | Delete
functions from this module themselves.
[3] Fix | Delete
"""
[4] Fix | Delete
import os
[5] Fix | Delete
import stat
[6] Fix | Delete
[7] Fix | Delete
__all__ = ['commonprefix', 'exists', 'getatime', 'getctime', 'getmtime',
[8] Fix | Delete
'getsize', 'isdir', 'isfile']
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
try:
[12] Fix | Delete
_unicode = unicode
[13] Fix | Delete
except NameError:
[14] Fix | Delete
# If Python is built without Unicode support, the unicode type
[15] Fix | Delete
# will not exist. Fake one.
[16] Fix | Delete
class _unicode(object):
[17] Fix | Delete
pass
[18] Fix | Delete
[19] Fix | Delete
# Does a path exist?
[20] Fix | Delete
# This is false for dangling symbolic links on systems that support them.
[21] Fix | Delete
def exists(path):
[22] Fix | Delete
"""Test whether a path exists. Returns False for broken symbolic links"""
[23] Fix | Delete
try:
[24] Fix | Delete
os.stat(path)
[25] Fix | Delete
except os.error:
[26] Fix | Delete
return False
[27] Fix | Delete
return True
[28] Fix | Delete
[29] Fix | Delete
[30] Fix | Delete
# This follows symbolic links, so both islink() and isdir() can be true
[31] Fix | Delete
# for the same path on systems that support symlinks
[32] Fix | Delete
def isfile(path):
[33] Fix | Delete
"""Test whether a path is a regular file"""
[34] Fix | Delete
try:
[35] Fix | Delete
st = os.stat(path)
[36] Fix | Delete
except os.error:
[37] Fix | Delete
return False
[38] Fix | Delete
return stat.S_ISREG(st.st_mode)
[39] Fix | Delete
[40] Fix | Delete
[41] Fix | Delete
# Is a path a directory?
[42] Fix | Delete
# This follows symbolic links, so both islink() and isdir()
[43] Fix | Delete
# can be true for the same path on systems that support symlinks
[44] Fix | Delete
def isdir(s):
[45] Fix | Delete
"""Return true if the pathname refers to an existing directory."""
[46] Fix | Delete
try:
[47] Fix | Delete
st = os.stat(s)
[48] Fix | Delete
except os.error:
[49] Fix | Delete
return False
[50] Fix | Delete
return stat.S_ISDIR(st.st_mode)
[51] Fix | Delete
[52] Fix | Delete
[53] Fix | Delete
def getsize(filename):
[54] Fix | Delete
"""Return the size of a file, reported by os.stat()."""
[55] Fix | Delete
return os.stat(filename).st_size
[56] Fix | Delete
[57] Fix | Delete
[58] Fix | Delete
def getmtime(filename):
[59] Fix | Delete
"""Return the last modification time of a file, reported by os.stat()."""
[60] Fix | Delete
return os.stat(filename).st_mtime
[61] Fix | Delete
[62] Fix | Delete
[63] Fix | Delete
def getatime(filename):
[64] Fix | Delete
"""Return the last access time of a file, reported by os.stat()."""
[65] Fix | Delete
return os.stat(filename).st_atime
[66] Fix | Delete
[67] Fix | Delete
[68] Fix | Delete
def getctime(filename):
[69] Fix | Delete
"""Return the metadata change time of a file, reported by os.stat()."""
[70] Fix | Delete
return os.stat(filename).st_ctime
[71] Fix | Delete
[72] Fix | Delete
[73] Fix | Delete
# Return the longest prefix of all list elements.
[74] Fix | Delete
def commonprefix(m):
[75] Fix | Delete
"Given a list of pathnames, returns the longest common leading component"
[76] Fix | Delete
if not m: return ''
[77] Fix | Delete
s1 = min(m)
[78] Fix | Delete
s2 = max(m)
[79] Fix | Delete
for i, c in enumerate(s1):
[80] Fix | Delete
if c != s2[i]:
[81] Fix | Delete
return s1[:i]
[82] Fix | Delete
return s1
[83] Fix | Delete
[84] Fix | Delete
# Split a path in root and extension.
[85] Fix | Delete
# The extension is everything starting at the last dot in the last
[86] Fix | Delete
# pathname component; the root is everything before that.
[87] Fix | Delete
# It is always true that root + ext == p.
[88] Fix | Delete
[89] Fix | Delete
# Generic implementation of splitext, to be parametrized with
[90] Fix | Delete
# the separators
[91] Fix | Delete
def _splitext(p, sep, altsep, extsep):
[92] Fix | Delete
"""Split the extension from a pathname.
[93] Fix | Delete
[94] Fix | Delete
Extension is everything from the last dot to the end, ignoring
[95] Fix | Delete
leading dots. Returns "(root, ext)"; ext may be empty."""
[96] Fix | Delete
[97] Fix | Delete
sepIndex = p.rfind(sep)
[98] Fix | Delete
if altsep:
[99] Fix | Delete
altsepIndex = p.rfind(altsep)
[100] Fix | Delete
sepIndex = max(sepIndex, altsepIndex)
[101] Fix | Delete
[102] Fix | Delete
dotIndex = p.rfind(extsep)
[103] Fix | Delete
if dotIndex > sepIndex:
[104] Fix | Delete
# skip all leading dots
[105] Fix | Delete
filenameIndex = sepIndex + 1
[106] Fix | Delete
while filenameIndex < dotIndex:
[107] Fix | Delete
if p[filenameIndex] != extsep:
[108] Fix | Delete
return p[:dotIndex], p[dotIndex:]
[109] Fix | Delete
filenameIndex += 1
[110] Fix | Delete
[111] Fix | Delete
return p, ''
[112] Fix | Delete
[113] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function