debian/lib/python/debian_linux/utils.py: Add rmtree.
svn path=/dists/trunk/linux-2.6/; revision=7820
This commit is contained in:
parent
231041a957
commit
bed9079aa8
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue