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
d7673291
Kaydet (Commit)
d7673291
authored
Şub 06, 1998
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added rmtree(), to recursively remove a directory tree.
Code by David Ascher (docstring by me).
üst
a0fec2b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
shutil.py
Lib/shutil.py
+32
-0
No files found.
Lib/shutil.py
Dosyayı görüntüle @
d7673291
...
...
@@ -93,3 +93,35 @@ def copytree(src, dst, symlinks=0):
# XXX What about devices, sockets etc.?
except
(
IOError
,
os
.
error
),
why
:
print
"Can't copy
%
s to
%
s:
%
s"
%
(
`srcname`
,
`dstname`
,
str
(
why
))
def
rmtree
(
path
,
ignore_errors
=
0
,
onerror
=
None
):
"""Recursively delete a directory tree.
If ignore_errors is set, errors are ignored; otherwise, if
onerror is set, it is called to handle the error; otherwise, an
exception is raised.
"""
cmdtuples
=
[]
_build_cmdtuple
(
path
,
cmdtuples
)
for
cmd
in
cmdtuples
:
try
:
apply
(
cmd
[
0
],
(
cmd
[
1
],))
except
:
exc
=
sys
.
exc_info
()
if
ignore_errors
:
pass
elif
onerror
:
onerror
(
cmd
[
0
],
cmd
[
1
],
exc
)
else
:
raise
exc
[
0
],
(
exc
[
1
][
0
],
exc
[
1
][
1
]
+
' removing '
+
cmd
[
1
])
# Helper for rmtree()
def
_build_cmdtuple
(
path
,
cmdtuples
):
for
f
in
os
.
listdir
(
path
):
real_f
=
os
.
path
.
join
(
path
,
f
)
if
os
.
path
.
isdir
(
real_f
)
and
not
os
.
path
.
islink
(
real_f
):
_build_cmdtuple
(
real_f
,
cmdtuples
)
else
:
cmdtuples
.
append
(
os
.
remove
,
real_f
)
cmdtuples
.
append
(
os
.
rmdir
,
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