This makes it possible to specify whether the equivalent of 'rm -rf' or
only this of 'rm -f' is wanted. Due to backward compatibility it
defaults to the recursive variant.
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Acked-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
else:
return rel
-def remove(path):
+def remove(path, recurse=True):
"""Equivalent to rm -f or rm -rf"""
import os, errno, shutil
try:
os.unlink(path)
except OSError, exc:
- if exc.errno == errno.EISDIR:
+ if recurse and exc.errno == errno.EISDIR:
shutil.rmtree(path)
elif exc.errno != errno.ENOENT:
raise