From 1e550f822747b4b1390d68e60ea4ce33f3f14285 Mon Sep 17 00:00:00 2001 From: Will Woods Date: Mon, 9 May 2011 10:24:15 -0400 Subject: [PATCH] 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(). --- src/pylorax/sysutils.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pylorax/sysutils.py b/src/pylorax/sysutils.py index 1813ec2e..cde3c85d 100644 --- a/src/pylorax/sysutils.py +++ b/src/pylorax/sysutils.py @@ -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)