diff options
author | Bastian Blank <waldi@debian.org> | 2006-11-19 12:13:25 +0000 |
---|---|---|
committer | Bastian Blank <waldi@debian.org> | 2006-11-19 12:13:25 +0000 |
commit | bed9079aa86c7d9524d7f6c3c6519a78fb225a4b (patch) | |
tree | 0ecb554f5050517e1a70ab9ac498aaa5555e1c62 /debian/lib/python/debian_linux/utils.py | |
parent | 231041a957e283bd61b63477dcf1695762daed65 (diff) | |
download | kernel_replicant_linux-bed9079aa86c7d9524d7f6c3c6519a78fb225a4b.tar.gz kernel_replicant_linux-bed9079aa86c7d9524d7f6c3c6519a78fb225a4b.tar.bz2 kernel_replicant_linux-bed9079aa86c7d9524d7f6c3c6519a78fb225a4b.zip |
debian/lib/python/debian_linux/utils.py: Add rmtree.
svn path=/dists/trunk/linux-2.6/; revision=7820
Diffstat (limited to 'debian/lib/python/debian_linux/utils.py')
-rw-r--r-- | debian/lib/python/debian_linux/utils.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/debian/lib/python/debian_linux/utils.py b/debian/lib/python/debian_linux/utils.py index 8fb7b5351b05..47b01914022f 100644 --- a/debian/lib/python/debian_linux/utils.py +++ b/debian/lib/python/debian_linux/utils.py @@ -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) + |