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
4d0fdc34
Kaydet (Commit)
4d0fdc34
authored
Agu 16, 1991
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
path.cat --> join
Added splitext
üst
fbe0a8e0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
posixpath.py
Lib/posixpath.py
+27
-5
No files found.
Lib/posixpath.py
Dosyayı görüntüle @
4d0fdc34
...
@@ -4,19 +4,24 @@ import posix
...
@@ -4,19 +4,24 @@ import posix
import
stat
import
stat
#
Intelligent pathname concatenation
.
#
Join two pathnames
.
# Insert
s
a '/' unless the first part is empty or already ends in '/'.
# Insert a '/' unless the first part is empty or already ends in '/'.
# Ignore
s
the first part altogether if the second part is absolute
# Ignore the first part altogether if the second part is absolute
# (begins with '/').
# (begins with '/').
#
#
def
cat
(
a
,
b
):
def
join
(
a
,
b
):
if
b
[:
1
]
=
'/'
:
return
b
if
b
[:
1
]
=
'/'
:
return
b
if
a
=
''
or
a
[
-
1
:]
=
'/'
:
return
a
+
b
if
a
=
''
or
a
[
-
1
:]
=
'/'
:
return
a
+
b
# Note: join('x', '') returns 'x/'; is this what we want?
return
a
+
'/'
+
b
return
a
+
'/'
+
b
cat
=
join
# For compatibility
# Split a path in head (empty or ending in '/') and tail (no '/').
# Split a path in head (empty or ending in '/') and tail (no '/').
# The tail will be empty if the path ends in '/'.
# The tail will be empty if the path ends in '/'.
# It is always true that head+tail = p.
#
#
def
split
(
p
):
def
split
(
p
):
head
,
tail
=
''
,
''
head
,
tail
=
''
,
''
...
@@ -27,6 +32,23 @@ def split(p):
...
@@ -27,6 +32,23 @@ def split(p):
return
head
,
tail
return
head
,
tail
# Split a path in root and extension.
# The extension is everything starting at the first dot in the last
# pathname component; the root is everything before that.
# It is always true that root+ext = p.
#
def
splitext
(
p
):
root
,
ext
=
''
,
''
for
c
in
p
:
if
c
=
'/'
:
root
,
ext
=
root
+
ext
+
c
,
''
elif
c
=
'.'
or
ext
:
ext
=
ext
+
c
else
:
root
=
root
+
c
return
root
,
ext
# Return the tail (basename) part of a path.
# Return the tail (basename) part of a path.
#
#
def
basename
(
p
):
def
basename
(
p
):
...
@@ -120,6 +142,6 @@ def walk(top, func, arg):
...
@@ -120,6 +142,6 @@ def walk(top, func, arg):
exceptions
=
(
'.'
,
'..'
)
exceptions
=
(
'.'
,
'..'
)
for
name
in
names
:
for
name
in
names
:
if
name
not
in
exceptions
:
if
name
not
in
exceptions
:
name
=
cat
(
top
,
name
)
name
=
join
(
top
,
name
)
if
isdir
(
name
):
if
isdir
(
name
):
walk
(
name
,
func
,
arg
)
walk
(
name
,
func
,
arg
)
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