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
018dfae2
Kaydet (Commit)
018dfae2
authored
Tem 19, 2000
tarafından
Skip Montanaro
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
added rewritten normpath from Moshe Zadka that does the right thing with
paths containing ..
üst
7cb15245
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
23 deletions
+18
-23
posixpath.py
Lib/posixpath.py
+18
-23
No files found.
Lib/posixpath.py
Dosyayı görüntüle @
018dfae2
...
...
@@ -346,30 +346,25 @@ are left unchanged"""
def
normpath
(
path
):
"""Normalize path, eliminating double slashes, etc."""
if
path
==
''
:
return
'.'
import
string
# Treat initial slashes specially
slashes
=
''
while
path
[:
1
]
==
'/'
:
slashes
=
slashes
+
'/'
path
=
path
[
1
:]
comps
=
string
.
splitfields
(
path
,
'/'
)
i
=
0
while
i
<
len
(
comps
):
if
comps
[
i
]
==
'.'
:
del
comps
[
i
]
while
i
<
len
(
comps
)
and
comps
[
i
]
==
''
:
del
comps
[
i
]
elif
comps
[
i
]
==
'..'
and
i
>
0
and
comps
[
i
-
1
]
not
in
(
''
,
'..'
):
del
comps
[
i
-
1
:
i
+
1
]
i
=
i
-
1
elif
comps
[
i
]
==
''
and
i
>
0
and
comps
[
i
-
1
]
<>
''
:
del
comps
[
i
]
else
:
i
=
i
+
1
# If the path is now empty, substitute '.'
if
not
comps
and
not
slashes
:
comps
.
append
(
'.'
)
return
slashes
+
string
.
joinfields
(
comps
,
'/'
)
initial_slash
=
(
path
[
0
]
==
'/'
)
comps
=
string
.
split
(
path
,
'/'
)
new_comps
=
[]
for
comp
in
comps
:
if
comp
in
(
''
,
'.'
):
continue
if
(
comp
!=
'..'
or
(
not
initial_slash
and
not
new_comps
)
or
(
new_comps
and
new_comps
[
-
1
]
==
'..'
)):
new_comps
.
append
(
comp
)
elif
new_comps
:
new_comps
.
pop
()
comps
=
new_comps
path
=
string
.
join
(
comps
,
'/'
)
if
initial_slash
:
path
=
'/'
+
path
return
path
or
'.'
def
abspath
(
path
):
...
...
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