Commit 74bb7f03 authored by Raymond Hettinger's avatar Raymond Hettinger
parent 9b4dab4d
...@@ -123,16 +123,13 @@ def dirname(p): ...@@ -123,16 +123,13 @@ 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 ''
prefix = m[0] s1 = min(m)
for item in m: s2 = max(m)
for i in range(len(prefix)): n = min(len(s1), len(s2))
if prefix[:i+1] != item[:i+1]: for i in xrange(n):
prefix = prefix[:i] if s1[i] != s2[i]:
if i == 0: return s1[:i]
return '' return s1[:n]
break
return 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