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
0ec31262
Kaydet (Commit)
0ec31262
authored
Agu 10, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
added normpath() and splitdrive()
üst
f68ec392
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
39 deletions
+45
-39
macpath.py
Lib/macpath.py
+45
-39
No files found.
Lib/macpath.py
Dosyayı görüntüle @
0ec31262
...
...
@@ -46,48 +46,20 @@ def split(s):
return
s
[:
colon
-
1
],
s
[
colon
:]
# Short interfaces to split()
# Split a pathname into a drive specification and the rest of the
# path. Useful on DOS/Windows/NT; on the Mac, the drive is always
# empty (don't use the volume name -- it doesn't have the same
# syntactic and semantic oddities as DOS drive letters, such as there
# being a separate current directory per drive).
def
dirname
(
s
):
return
split
(
s
)[
0
]
def
basename
(
s
):
return
split
(
s
)[
1
]
def
splitdrive
(
p
):
return
''
,
p
# XXX This is undocumented and may go away!
# Normalize a pathname: get rid of '::' sequences by backing up,
# e.g., 'foo:bar::bletch' becomes 'foo:bletch'.
# Raise the exception norm_error below if backing up is impossible,
# e.g., for '::foo'.
norm_error
=
'macpath.norm_error: path cannot be normalized'
# Short interfaces to split()
def
norm
(
s
):
import
string
if
':'
not
in
s
:
return
':'
+
s
f
=
string
.
splitfields
(
s
,
':'
)
pre
=
[]
post
=
[]
if
not
f
[
0
]:
pre
=
f
[:
1
]
f
=
f
[
1
:]
if
not
f
[
len
(
f
)
-
1
]:
post
=
f
[
-
1
:]
f
=
f
[:
-
1
]
res
=
[]
for
seg
in
f
:
if
seg
:
res
.
append
(
seg
)
else
:
if
not
res
:
raise
norm_error
,
'path starts with ::'
del
res
[
len
(
res
)
-
1
]
if
not
(
pre
or
res
):
raise
norm_error
,
'path starts with volume::'
if
pre
:
res
=
pre
+
res
if
post
:
res
=
res
+
post
s
=
res
[
0
]
for
seg
in
res
[
1
:]:
s
=
s
+
':'
+
seg
return
s
def
dirname
(
s
):
return
split
(
s
)[
0
]
def
basename
(
s
):
return
split
(
s
)[
1
]
# Return true if the pathname refers to an existing directory.
...
...
@@ -127,11 +99,45 @@ def exists(s):
return
1
# Normalize path, removing things like ...:A:..:... (yet to be written)
# Normalize a pathname: get rid of '::' sequences by backing up,
# e.g., 'foo:bar::bletch' becomes 'foo:bletch'.
# Raise the exception norm_error below if backing up is impossible,
# e.g., for '::foo'.
# XXX The Unix version doesn't raise an exception but simply
# returns an unnormalized path. Should do so here too.
norm_error
=
'macpath.norm_error: path cannot be normalized'
def
normpath
(
s
):
import
string
if
':'
not
in
s
:
return
':'
+
s
f
=
string
.
splitfields
(
s
,
':'
)
pre
=
[]
post
=
[]
if
not
f
[
0
]:
pre
=
f
[:
1
]
f
=
f
[
1
:]
if
not
f
[
len
(
f
)
-
1
]:
post
=
f
[
-
1
:]
f
=
f
[:
-
1
]
res
=
[]
for
seg
in
f
:
if
seg
:
res
.
append
(
seg
)
else
:
if
not
res
:
raise
norm_error
,
'path starts with ::'
del
res
[
len
(
res
)
-
1
]
if
not
(
pre
or
res
):
raise
norm_error
,
'path starts with volume::'
if
pre
:
res
=
pre
+
res
if
post
:
res
=
res
+
post
s
=
res
[
0
]
for
seg
in
res
[
1
:]:
s
=
s
+
':'
+
seg
return
s
# Directory tree walk.
# For each directory under top (including top itself),
# func(arg, dirname, filenames) is called, where
...
...
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