Back to index

python3.2  3.2.2
Functions | Variables
os2emxpath Namespace Reference

Functions

def normcase
def join
def splitunc
def basename
def dirname
def ismount
def normpath
def abspath

Variables

list __all__
string curdir = '.'
string pardir = '..'
string extsep = '.'
string sep = '/'
string altsep = '\\'
string pathsep = ';'
string defpath = '.;C:\\bin'
string devnull = 'nul'
 lexists = exists
 realpath = abspath
 supports_unicode_filenames = False

Function Documentation

def os2emxpath.abspath (   path)
Return the absolute version of a path

Definition at line 149 of file os2emxpath.py.

00149 
00150 def abspath(path):
00151     """Return the absolute version of a path"""
00152     if not isabs(path):
00153         path = join(os.getcwd(), path)
00154     return normpath(path)
00155 
# realpath is a no-op on systems without islink support

Here is the call graph for this function:

def os2emxpath.basename (   p)
Returns the final component of a pathname

Definition at line 91 of file os2emxpath.py.

00091 
00092 def basename(p):
00093     """Returns the final component of a pathname"""
00094     return split(p)[1]
00095 
00096 
00097 # Return the head (dirname) part of a path.

Here is the call graph for this function:

def os2emxpath.dirname (   p)
Returns the directory component of a pathname

Definition at line 98 of file os2emxpath.py.

00098 
00099 def dirname(p):
00100     """Returns the directory component of a pathname"""
00101     return split(p)[0]
00102 
00103 
# alias exists to lexists

Here is the call graph for this function:

def os2emxpath.ismount (   path)
Test whether a path is a mount point (defined as root of drive)

Definition at line 112 of file os2emxpath.py.

00112 
00113 def ismount(path):
00114     """Test whether a path is a mount point (defined as root of drive)"""
00115     unc, rest = splitunc(path)
00116     if unc:
00117         return rest in ("", "/", "\\")
00118     p = splitdrive(path)[1]
00119     return len(p) == 1 and p[0] in '/\\'
00120 
00121 
00122 # Normalize a path, e.g. A//B, A/./B and A/foo/../B all become A/B.

Here is the call graph for this function:

def os2emxpath.join (   a,
  p 
)
Join two or more pathname components, inserting sep as needed

Definition at line 47 of file os2emxpath.py.

00047 
00048 def join(a, *p):
00049     """Join two or more pathname components, inserting sep as needed"""
00050     path = a
00051     for b in p:
00052         if isabs(b):
00053             path = b
00054         elif path == '' or path[-1:] in '/\\:':
00055             path = path + b
00056         else:
00057             path = path + '/' + b
00058     return path
00059 
00060 
# Parse UNC paths

Here is the call graph for this function:

Here is the caller graph for this function:

def os2emxpath.normcase (   s)
Normalize case of pathname.

Makes all characters lowercase and all altseps into seps.

Definition at line 35 of file os2emxpath.py.

00035 
00036 def normcase(s):
00037     """Normalize case of pathname.
00038 
00039     Makes all characters lowercase and all altseps into seps."""
00040     if not isinstance(s, (bytes, str)):
00041         raise TypeError("normcase() argument must be str or bytes, "
00042                         "not '{}'".format(s.__class__.__name__))
00043     return s.replace('\\', '/').lower()
00044 
00045 
00046 # Join two (or more) paths.

Here is the caller graph for this function:

def os2emxpath.normpath (   path)
Normalize path, eliminating double slashes, etc.

Definition at line 123 of file os2emxpath.py.

00123 
00124 def normpath(path):
00125     """Normalize path, eliminating double slashes, etc."""
00126     path = path.replace('\\', '/')
00127     prefix, path = splitdrive(path)
00128     while path[:1] == '/':
00129         prefix = prefix + '/'
00130         path = path[1:]
00131     comps = path.split('/')
00132     i = 0
00133     while i < len(comps):
00134         if comps[i] == '.':
00135             del comps[i]
00136         elif comps[i] == '..' and i > 0 and comps[i-1] not in ('', '..'):
00137             del comps[i-1:i+1]
00138             i = i - 1
00139         elif comps[i] == '' and i > 0 and comps[i-1] != '':
00140             del comps[i]
00141         else:
00142             i = i + 1
00143     # If the path is now empty, substitute '.'
00144     if not prefix and not comps:
00145         comps.append('.')
00146     return prefix + '/'.join(comps)
00147 
00148 
# Return an absolute path.

Here is the call graph for this function:

Here is the caller graph for this function:

def os2emxpath.splitunc (   p)
Split a pathname into UNC mount point and relative path specifiers.

Return a 2-tuple (unc, rest); either part may be empty.
If unc is not empty, it has the form '//host/mount' (or similar
using backslashes).  unc+rest is always the input path.
Paths containing drive letters never have an UNC part.

Definition at line 61 of file os2emxpath.py.

00061 
00062 def splitunc(p):
00063     """Split a pathname into UNC mount point and relative path specifiers.
00064 
00065     Return a 2-tuple (unc, rest); either part may be empty.
00066     If unc is not empty, it has the form '//host/mount' (or similar
00067     using backslashes).  unc+rest is always the input path.
00068     Paths containing drive letters never have an UNC part.
00069     """
00070     if p[1:2] == ':':
00071         return '', p # Drive letter present
00072     firstTwo = p[0:2]
00073     if firstTwo == '/' * 2 or firstTwo == '\\' * 2:
00074         # is a UNC path:
00075         # vvvvvvvvvvvvvvvvvvvv equivalent to drive letter
00076         # \\machine\mountpoint\directories...
00077         #           directory ^^^^^^^^^^^^^^^
00078         normp = normcase(p)
00079         index = normp.find('/', 2)
00080         if index == -1:
00081             ##raise RuntimeError, 'illegal UNC path: "' + p + '"'
00082             return ("", p)
00083         index = normp.find('/', index + 1)
00084         if index == -1:
00085             index = len(p)
00086         return p[:index], p[index:]
00087     return '', p
00088 
00089 
00090 # Return the tail (basename) part of a path.

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Initial value:
00001 ["normcase","isabs","join","splitdrive","split","splitext",
00002            "basename","dirname","commonprefix","getsize","getmtime",
00003            "getatime","getctime", "islink","exists","lexists","isdir","isfile",
00004            "ismount","expanduser","expandvars","normpath","abspath",
00005            "splitunc","curdir","pardir","sep","pathsep","defpath","altsep",
00006            "extsep","devnull","realpath","supports_unicode_filenames"]

Definition at line 14 of file os2emxpath.py.

Definition at line 26 of file os2emxpath.py.

Definition at line 22 of file os2emxpath.py.

string os2emxpath.defpath = '.;C:\\bin'

Definition at line 28 of file os2emxpath.py.

Definition at line 29 of file os2emxpath.py.

Definition at line 24 of file os2emxpath.py.

Definition at line 104 of file os2emxpath.py.

Definition at line 23 of file os2emxpath.py.

Definition at line 27 of file os2emxpath.py.

Definition at line 156 of file os2emxpath.py.

Definition at line 25 of file os2emxpath.py.

Definition at line 158 of file os2emxpath.py.