[oe] [PATCH] oe.path: added 'recurse' argument to remove()

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Mon Aug 16 10:52:42 UTC 2010


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 at sigma-chemnitz.de>
---
 lib/oe/path.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/oe/path.py b/lib/oe/path.py
index f58c013..3d64cfa 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
-- 
1.7.2.1





More information about the Openembedded-devel mailing list