Index: Lib/dospath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/dospath.py,v retrieving revision 1.13 diff -c -r1.13 dospath.py *** Lib/dospath.py 2000/07/01 10:52:49 1.13 --- Lib/dospath.py 2000/07/12 00:19:29 *************** *** 102,119 **** return split(p)[0] ! def commonprefix(m): ! """Return the longest prefix of all list elements.""" if not m: return '' ! prefix = m[0] ! for item in m: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return prefix # Get size, mtime, atime of files. --- 102,127 ---- return split(p)[0] ! # Return the longest prefix of all list elements. + def commonprefix(m): + "Given a list of pathnames, returns the longest common leading component" if not m: return '' ! n = m[:] ! for i in range(len(n)): ! n[i] = n[i].split(os.sep) ! # if os.sep didn't have any effect, try os.altsep ! if os.altsep and len(n[i]) == 1: ! n[i] = n[i].split(os.altsep) ! ! prefix = n[0] ! for item in n: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return os.sep.join(prefix) # Get size, mtime, atime of files. Index: Lib/macpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/macpath.py,v retrieving revision 1.22 diff -c -r1.22 macpath.py *** Lib/macpath.py 2000/07/01 10:52:26 1.22 --- Lib/macpath.py 2000/07/12 00:19:29 *************** *** 89,94 **** --- 89,117 ---- def basename(s): return split(s)[1] + # Return the longest prefix of all list elements. + # XXX completely untested on Mac!!! + + def commonprefix(m): + "Given a list of pathnames, returns the longest common leading component" + if not m: return '' + n = m[:] + for i in range(len(n)): + n[i] = n[i].split(os.sep) + # if os.sep didn't have any effect, try os.altsep + if os.altsep and len(n[i]) == 1: + n[i] = n[i].split(os.altsep) + + prefix = n[0] + for item in n: + for i in range(len(prefix)): + if prefix[:i+1] <> item[:i+1]: + prefix = prefix[:i] + if i == 0: return '' + break + return os.sep.join(prefix) + + def isdir(s): """Return true if the pathname refers to an existing directory.""" Index: Lib/ntpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/ntpath.py,v retrieving revision 1.24 diff -c -r1.24 ntpath.py *** Lib/ntpath.py 2000/07/01 06:36:51 1.24 --- Lib/ntpath.py 2000/07/12 00:19:30 *************** *** 8,15 **** import os import stat import string - # Normalize the case of a pathname and map slashes to backslashes. # Other normalizations (such as optimizing '../' away) are not done # (this is done by normpath). --- 8,15 ---- import os import stat import string + import copy # Normalize the case of a pathname and map slashes to backslashes. # Other normalizations (such as optimizing '../' away) are not done # (this is done by normpath). *************** *** 158,171 **** def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' ! prefix = m[0] ! for item in m: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return prefix # Get size, mtime, atime of files. --- 158,174 ---- def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' ! n = copy.copy(m) ! for i in range(len(n)): ! n[i] = n[i].split(os.sep) ! prefix = n[0] ! for item in n: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return os.sep.join(prefix) # Get size, mtime, atime of files. Index: Lib/posixpath.py =================================================================== RCS file: /cvsroot/python/python/dist/src/Lib/posixpath.py,v retrieving revision 1.31 diff -c -r1.31 posixpath.py *** Lib/posixpath.py 2000/06/28 14:48:01 1.31 --- Lib/posixpath.py 2000/07/12 00:19:30 *************** *** 118,131 **** def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' ! prefix = m[0] ! for item in m: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return prefix # Get size, mtime, atime of files. --- 118,138 ---- def commonprefix(m): "Given a list of pathnames, returns the longest common leading component" if not m: return '' ! n = m[:] ! for i in range(len(n)): ! n[i] = n[i].split(os.sep) ! # if os.sep didn't have any effect, try os.altsep ! if os.altsep and len(n[i]) == 1: ! n[i] = n[i].split(os.altsep) ! ! prefix = n[0] ! for item in n: for i in range(len(prefix)): if prefix[:i+1] <> item[:i+1]: prefix = prefix[:i] if i == 0: return '' break ! return os.sep.join(prefix) # Get size, mtime, atime of files.