33"""
+ 34
+ 35 @return true if string is an absolute path or protocoladdress
+ 36 for addresses beginning in http:// or ftp:// or ldap:// -
+ 37 they are considered "absolute" paths.
+ 38 """
+ 39ifprotocolPattern.match(string):
+ 40returnTrue
+ 41returnos.path.isabs(string)
+
44""" converts a relative path to an absolute path.
+ 45
+ 46 @param path the path to convert - if already absolute, is returned
+ 47 without conversion.
+ 48 @param base - optional. Defaults to the current directory.
+ 49 The base is intelligently concatenated to the given relative path.
+ 50 @return the relative path of path from base
+ 51 """
+ 52ifisabs(path):
+ 53returnpath
+ 54ifbaseisNone:
+ 55base=os.curdir
+ 56retval=os.path.join(base,path)
+ 57returnos.path.abspath(retval)
+
96""" @return a relative path from base to path.
+ 97
+ 98 base can be absolute, or relative to curdir, or defaults
+ 99 to curdir.
+100 """
+101ifprotocolPattern.match(path):
+102returnpath
+103ifbaseisNone:
+104base=os.curdir
+105base=rel2abs(base)
+106path=rel2abs(path)# redundant - should already be absolute
+107returnrelpath(base,path)
+
111"""
+112 Returns the common prefix base on the path components.
+113 """
+114iflen(paths)==0:
+115return''
+116iflen(paths)==1:
+117returnpaths[0]
+118
+119def_commonprefix_internal(p1,p2):
+120c=commonpath(pathsplit(p1),pathsplit(p2))[0]
+121iflen(c)==0:
+122return''
+123returnos.path.join(*c)
+