Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
03c06ee7
Commit
03c06ee7
authored
Aug 23, 2000
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Restored commonprefix() semantics.
parent
a48b5267
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
23 deletions
+13
-23
Lib/macpath.py
Lib/macpath.py
+13
-23
No files found.
Lib/macpath.py
View file @
03c06ee7
...
...
@@ -89,29 +89,6 @@ def dirname(s): return split(s)[0]
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."""
...
...
@@ -166,6 +143,19 @@ def exists(s):
return
0
return
1
# 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
''
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
def
expandvars
(
path
):
"""Dummy to retain interface-compatibility with other operating systems."""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment