Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python2....
File: os2emxpath.py
# Module 'os2emxpath' -- common operations on OS/2 pathnames
[0] Fix | Delete
"""Common pathname manipulations, OS/2 EMX version.
[1] Fix | Delete
[2] Fix | Delete
Instead of importing this module directly, import os and refer to this
[3] Fix | Delete
module as os.path.
[4] Fix | Delete
"""
[5] Fix | Delete
[6] Fix | Delete
import os
[7] Fix | Delete
import stat
[8] Fix | Delete
from genericpath import *
[9] Fix | Delete
from genericpath import _unicode
[10] Fix | Delete
from ntpath import (expanduser, expandvars, isabs, islink, splitdrive,
[11] Fix | Delete
splitext, split, walk)
[12] Fix | Delete
[13] Fix | Delete
__all__ = ["normcase","isabs","join","splitdrive","split","splitext",
[14] Fix | Delete
"basename","dirname","commonprefix","getsize","getmtime",
[15] Fix | Delete
"getatime","getctime", "islink","exists","lexists","isdir","isfile",
[16] Fix | Delete
"ismount","walk","expanduser","expandvars","normpath","abspath",
[17] Fix | Delete
"splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
[18] Fix | Delete
"extsep","devnull","realpath","supports_unicode_filenames"]
[19] Fix | Delete
[20] Fix | Delete
# strings representing various path-related bits and pieces
[21] Fix | Delete
curdir = '.'
[22] Fix | Delete
pardir = '..'
[23] Fix | Delete
extsep = '.'
[24] Fix | Delete
sep = '/'
[25] Fix | Delete
altsep = '\\'
[26] Fix | Delete
pathsep = ';'
[27] Fix | Delete
defpath = '.;C:\\bin'
[28] Fix | Delete
devnull = 'nul'
[29] Fix | Delete
[30] Fix | Delete
# Normalize the case of a pathname and map slashes to backslashes.
[31] Fix | Delete
# Other normalizations (such as optimizing '../' away) are not done
[32] Fix | Delete
# (this is done by normpath).
[33] Fix | Delete
[34] Fix | Delete
def normcase(s):
[35] Fix | Delete
"""Normalize case of pathname.
[36] Fix | Delete
[37] Fix | Delete
Makes all characters lowercase and all altseps into seps."""
[38] Fix | Delete
return s.replace('\\', '/').lower()
[39] Fix | Delete
[40] Fix | Delete
[41] Fix | Delete
# Join two (or more) paths.
[42] Fix | Delete
[43] Fix | Delete
def join(a, *p):
[44] Fix | Delete
"""Join two or more pathname components, inserting sep as needed"""
[45] Fix | Delete
path = a
[46] Fix | Delete
for b in p:
[47] Fix | Delete
if isabs(b):
[48] Fix | Delete
path = b
[49] Fix | Delete
elif path == '' or path[-1:] in '/\\:':
[50] Fix | Delete
path = path + b
[51] Fix | Delete
else:
[52] Fix | Delete
path = path + '/' + b
[53] Fix | Delete
return path
[54] Fix | Delete
[55] Fix | Delete
[56] Fix | Delete
# Parse UNC paths
[57] Fix | Delete
def splitunc(p):
[58] Fix | Delete
"""Split a pathname into UNC mount point and relative path specifiers.
[59] Fix | Delete
[60] Fix | Delete
Return a 2-tuple (unc, rest); either part may be empty.
[61] Fix | Delete
If unc is not empty, it has the form '//host/mount' (or similar
[62] Fix | Delete
using backslashes). unc+rest is always the input path.
[63] Fix | Delete
Paths containing drive letters never have a UNC part.
[64] Fix | Delete
"""
[65] Fix | Delete
if p[1:2] == ':':
[66] Fix | Delete
return '', p # Drive letter present
[67] Fix | Delete
firstTwo = p[0:2]
[68] Fix | Delete
if firstTwo == '/' * 2 or firstTwo == '\\' * 2:
[69] Fix | Delete
# is a UNC path:
[70] Fix | Delete
# vvvvvvvvvvvvvvvvvvvv equivalent to drive letter
[71] Fix | Delete
# \\machine\mountpoint\directories...
[72] Fix | Delete
# directory ^^^^^^^^^^^^^^^
[73] Fix | Delete
normp = normcase(p)
[74] Fix | Delete
index = normp.find('/', 2)
[75] Fix | Delete
if index == -1:
[76] Fix | Delete
##raise RuntimeError, 'illegal UNC path: "' + p + '"'
[77] Fix | Delete
return ("", p)
[78] Fix | Delete
index = normp.find('/', index + 1)
[79] Fix | Delete
if index == -1:
[80] Fix | Delete
index = len(p)
[81] Fix | Delete
return p[:index], p[index:]
[82] Fix | Delete
return '', p
[83] Fix | Delete
[84] Fix | Delete
[85] Fix | Delete
# Return the tail (basename) part of a path.
[86] Fix | Delete
[87] Fix | Delete
def basename(p):
[88] Fix | Delete
"""Returns the final component of a pathname"""
[89] Fix | Delete
return split(p)[1]
[90] Fix | Delete
[91] Fix | Delete
[92] Fix | Delete
# Return the head (dirname) part of a path.
[93] Fix | Delete
[94] Fix | Delete
def dirname(p):
[95] Fix | Delete
"""Returns the directory component of a pathname"""
[96] Fix | Delete
return split(p)[0]
[97] Fix | Delete
[98] Fix | Delete
[99] Fix | Delete
# alias exists to lexists
[100] Fix | Delete
lexists = exists
[101] Fix | Delete
[102] Fix | Delete
[103] Fix | Delete
# Is a path a directory?
[104] Fix | Delete
[105] Fix | Delete
# Is a path a mount point? Either a root (with or without drive letter)
[106] Fix | Delete
# or a UNC path with at most a / or \ after the mount point.
[107] Fix | Delete
[108] Fix | Delete
def ismount(path):
[109] Fix | Delete
"""Test whether a path is a mount point (defined as root of drive)"""
[110] Fix | Delete
unc, rest = splitunc(path)
[111] Fix | Delete
if unc:
[112] Fix | Delete
return rest in ("", "/", "\\")
[113] Fix | Delete
p = splitdrive(path)[1]
[114] Fix | Delete
return len(p) == 1 and p[0] in '/\\'
[115] Fix | Delete
[116] Fix | Delete
[117] Fix | Delete
# Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B.
[118] Fix | Delete
[119] Fix | Delete
def normpath(path):
[120] Fix | Delete
"""Normalize path, eliminating double slashes, etc."""
[121] Fix | Delete
path = path.replace('\\', '/')
[122] Fix | Delete
prefix, path = splitdrive(path)
[123] Fix | Delete
while path[:1] == '/':
[124] Fix | Delete
prefix = prefix + '/'
[125] Fix | Delete
path = path[1:]
[126] Fix | Delete
comps = path.split('/')
[127] Fix | Delete
i = 0
[128] Fix | Delete
while i < len(comps):
[129] Fix | Delete
if comps[i] == '.':
[130] Fix | Delete
del comps[i]
[131] Fix | Delete
elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
[132] Fix | Delete
del comps[i-1:i+1]
[133] Fix | Delete
i = i - 1
[134] Fix | Delete
elif comps[i] == '' and i > 0 and comps[i-1] != '':
[135] Fix | Delete
del comps[i]
[136] Fix | Delete
else:
[137] Fix | Delete
i = i + 1
[138] Fix | Delete
# If the path is now empty, substitute '.'
[139] Fix | Delete
if not prefix and not comps:
[140] Fix | Delete
comps.append('.')
[141] Fix | Delete
return prefix + '/'.join(comps)
[142] Fix | Delete
[143] Fix | Delete
[144] Fix | Delete
# Return an absolute path.
[145] Fix | Delete
def abspath(path):
[146] Fix | Delete
"""Return the absolute version of a path"""
[147] Fix | Delete
if not isabs(path):
[148] Fix | Delete
if isinstance(path, _unicode):
[149] Fix | Delete
cwd = os.getcwdu()
[150] Fix | Delete
else:
[151] Fix | Delete
cwd = os.getcwd()
[152] Fix | Delete
path = join(cwd, path)
[153] Fix | Delete
return normpath(path)
[154] Fix | Delete
[155] Fix | Delete
# realpath is a no-op on systems without islink support
[156] Fix | Delete
realpath = abspath
[157] Fix | Delete
[158] Fix | Delete
supports_unicode_filenames = False
[159] Fix | Delete
[160] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function