]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
* split on / or \
authorSkip Montanaro <skip@pobox.com>
Mon, 17 Jul 2000 03:06:58 +0000 (03:06 +0000)
committerSkip Montanaro <skip@pobox.com>
Mon, 17 Jul 2000 03:06:58 +0000 (03:06 +0000)
* case insensitive comparison

Lib/ntpath.py

index 65e1a430096d65b0ef430098a29bcc692d9b8d61..034694ddb00bd54da23e1a77e8b41ec32292c817 100644 (file)
@@ -8,6 +8,7 @@ module as os.path.
 import os
 import stat
 import string
+import re
 
 
 # Normalize the case of a pathname and map slashes to backslashes.
@@ -158,9 +159,10 @@ def dirname(p):
 def commonprefix(m):
     "Given a list of pathnames, returns the longest common leading component"
     if not m: return ''
-    n = m[:]
+    n = map(string.lower, m)
     for i in range(len(n)):
-        n[i] = n[i].split(os.sep)
+        n[i] = re.split(r"[/\\]", n[i])
+            
     prefix = n[0]
     for item in n:
         for i in range(len(prefix)):
@@ -168,7 +170,7 @@ def commonprefix(m):
                 prefix = prefix[:i]
                 if i == 0: return ''
                 break
-    return os.sep.join(prefix)
+    return "\\".join(prefix)
 
 
 # Get size, mtime, atime of files.