From eb30ef6d8ef030ed9c1ba581798204eb4e1c313b Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Mon, 16 Aug 2010 00:52:42 +0000 Subject: oe.path: added 'recurse' argument to remove() 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 Acked-by: Chris Larson Signed-off-by: Khem Raj --- lib/oe/path.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/oe') diff --git a/lib/oe/path.py b/lib/oe/path.py index f58c0138bb..3d64cfaac1 100644 --- a/lib/oe/path.py +++ b/lib/oe/path.py @@ -43,13 +43,13 @@ def format_display(path, metadata): 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 -- cgit 1.2.3-korg