Add remove() to sysutils

This adds the remove() function, which works a lot like rm -rf - if you
remove() a file, it uses os.unlink, and if you remove() a directory it
uses shutils.rmtree().
This commit is contained in:
Will Woods 2011-05-09 10:24:15 -04:00
parent 421e4c3a00
commit 1e550f8227

View File

@ -135,3 +135,9 @@ def cpfile(src, dst):
dst = joinpaths(dst, os.path.basename(src))
return dst
def remove(target):
if os.path.isdir(target):
shutil.rmtree(target)
else:
os.unlink(target)