debian/lib/python/debian_linux/utils.py: Add rmtree.

svn path=/dists/trunk/linux-2.6/; revision=7820
This commit is contained in:
Bastian Blank 2006-11-19 12:13:25 +00:00
parent 231041a957
commit bed9079aa8
1 changed files with 14 additions and 0 deletions

View File

@ -138,3 +138,17 @@ class wrap(textwrap.TextWrapper):
r'(\s+|' # any whitespace
r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))') # em-dash
def rmtree(dir):
import os, os.path, stat
for root, dirs, files in os.walk(dir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
for name in dirs:
real = os.path.join(root, name)
mode = os.lstat(real)[stat.ST_MODE]
if stat.S_ISDIR(mode):
os.rmdir(real)
else:
os.remove(real)
os.rmdir(dir)