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
2fc01093
Kaydet (Commit)
2fc01093
authored
Agu 06, 2000
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Rewrite of normpath() by Corran Webster, so trailing :s are removed
(except for : and volume:, where they are needed).
üst
2afffd42
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
32 deletions
+23
-32
macpath.py
Lib/macpath.py
+23
-32
No files found.
Lib/macpath.py
Dosyayı görüntüle @
2fc01093
...
@@ -179,39 +179,30 @@ def expanduser(path):
...
@@ -179,39 +179,30 @@ def expanduser(path):
norm_error
=
'macpath.norm_error: path cannot be normalized'
norm_error
=
'macpath.norm_error: path cannot be normalized'
def
normpath
(
s
):
def
normpath
(
s
):
"""Normalize a pathname: get rid of '::' sequences by backing up,
"""Normalize a pathname. Will return the same result for
e.g., 'foo:bar::bletch' becomes 'foo:bletch'.
equivalent paths."""
Raise the exception norm_error below if backing up is impossible,
e.g., for '::foo'."""
if
":"
not
in
s
:
# XXX The Unix version doesn't raise an exception but simply
return
":"
+
s
# returns an unnormalized path. Should do so here too.
comps
=
string
.
splitfields
(
s
,
":"
)
import
string
i
=
1
if
':'
not
in
s
:
while
i
<
len
(
comps
)
-
1
:
return
':'
+
s
if
comps
[
i
]
==
""
and
comps
[
i
-
1
]
!=
""
:
f
=
string
.
splitfields
(
s
,
':'
)
if
i
>
1
:
pre
=
[]
del
comps
[
i
-
1
:
i
+
1
]
post
=
[]
i
=
i
-
1
if
not
f
[
0
]:
else
:
pre
=
f
[:
1
]
# best way to handle this is to raise an exception
f
=
f
[
1
:]
raise
norm_error
,
'Cannot use :: immedeately after volume name'
if
not
f
[
len
(
f
)
-
1
]:
post
=
f
[
-
1
:]
f
=
f
[:
-
1
]
res
=
[]
for
seg
in
f
:
if
seg
:
res
.
append
(
seg
)
else
:
else
:
if
not
res
:
raise
norm_error
,
'path starts with ::'
i
=
i
+
1
del
res
[
len
(
res
)
-
1
]
if
not
(
pre
or
res
):
s
=
string
.
join
(
comps
,
":"
)
raise
norm_error
,
'path starts with volume::'
if
pre
:
res
=
pre
+
res
# remove trailing ":" except for ":" and "Volume:"
if
post
:
res
=
res
+
post
if
s
[
-
1
]
==
":"
and
len
(
comps
)
>
2
and
s
!=
":"
*
len
(
s
):
s
=
res
[
0
]
s
=
s
[:
-
1
]
for
seg
in
res
[
1
:]:
s
=
s
+
':'
+
seg
return
s
return
s
...
...
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