Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
97bc98ae
Kaydet (Commit)
97bc98ae
authored
Tem 12, 2000
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
fixed semantics of commonprefix to work by path elements instead of
characters.
üst
03657cfd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
12 deletions
+53
-12
dospath.py
Lib/dospath.py
+13
-5
macpath.py
Lib/macpath.py
+23
-0
ntpath.py
Lib/ntpath.py
+7
-4
posixpath.py
Lib/posixpath.py
+10
-3
No files found.
Lib/dospath.py
Dosyayı görüntüle @
97bc98ae
...
...
@@ -102,18 +102,26 @@ def dirname(p):
return
split
(
p
)[
0
]
def
commonprefix
(
m
):
"""Return the longest prefix of all list elements."""
# 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
:
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
prefix
return
os
.
sep
.
join
(
prefix
)
# Get size, mtime, atime of files.
...
...
Lib/macpath.py
Dosyayı görüntüle @
97bc98ae
...
...
@@ -89,6 +89,29 @@ 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."""
...
...
Lib/ntpath.py
Dosyayı görüntüle @
97bc98ae
...
...
@@ -8,7 +8,7 @@ module as os.path.
import
os
import
stat
import
string
import
copy
# Normalize the case of a pathname and map slashes to backslashes.
# Other normalizations (such as optimizing '../' away) are not done
...
...
@@ -158,14 +158,17 @@ def dirname(p):
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
:
n
=
copy
.
copy
(
m
)
for
i
in
range
(
len
(
n
)):
n
[
i
]
=
n
[
i
]
.
split
(
os
.
sep
)
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
prefix
return
os
.
sep
.
join
(
prefix
)
# Get size, mtime, atime of files.
...
...
Lib/posixpath.py
Dosyayı görüntüle @
97bc98ae
...
...
@@ -118,14 +118,21 @@ def dirname(p):
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
:
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
prefix
return
os
.
sep
.
join
(
prefix
)
# Get size, mtime, atime of files.
...
...
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