diff options
author | Skip Montanaro <skip@pobox.com> | 2000-07-17 03:06:58 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2000-07-17 03:06:58 (GMT) |
commit | 1d3dd74574b14364d4e9ab5f5d7e5df99d4a42ac (patch) | |
tree | 88e12613fd4db7086275e1b44f3d60461be9bdb3 | |
parent | 802bc5d9b3d2fa5b75e7c3405932c252142b7965 (diff) | |
download | cpython-1d3dd74574b14364d4e9ab5f5d7e5df99d4a42ac.zip cpython-1d3dd74574b14364d4e9ab5f5d7e5df99d4a42ac.tar.gz cpython-1d3dd74574b14364d4e9ab5f5d7e5df99d4a42ac.tar.bz2 |
* split on / or \
* case insensitive comparison
-rw-r--r-- | Lib/ntpath.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/ntpath.py b/Lib/ntpath.py index 65e1a43..034694d 100644 --- a/Lib/ntpath.py +++ b/Lib/ntpath.py @@ -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. |