Kaydet (Commit) 1d3dd745 authored tarafından Skip Montanaro's avatar Skip Montanaro

* split on / or \

* case insensitive comparison
üst 802bc5d9
...@@ -8,6 +8,7 @@ module as os.path. ...@@ -8,6 +8,7 @@ module as os.path.
import os import os
import stat import stat
import string import string
import re
# Normalize the case of a pathname and map slashes to backslashes. # Normalize the case of a pathname and map slashes to backslashes.
...@@ -158,9 +159,10 @@ def dirname(p): ...@@ -158,9 +159,10 @@ def dirname(p):
def commonprefix(m): def commonprefix(m):
"Given a list of pathnames, returns the longest common leading component" "Given a list of pathnames, returns the longest common leading component"
if not m: return '' if not m: return ''
n = m[:] n = map(string.lower, m)
for i in range(len(n)): for i in range(len(n)):
n[i] = n[i].split(os.sep) n[i] = re.split(r"[/\\]", n[i])
prefix = n[0] prefix = n[0]
for item in n: for item in n:
for i in range(len(prefix)): for i in range(len(prefix)):
...@@ -168,7 +170,7 @@ def commonprefix(m): ...@@ -168,7 +170,7 @@ def commonprefix(m):
prefix = prefix[:i] prefix = prefix[:i]
if i == 0: return '' if i == 0: return ''
break break
return os.sep.join(prefix) return "\\".join(prefix)
# Get size, mtime, atime of files. # Get size, mtime, atime of files.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment