oe.path: added 'recurse' argument to remove()
authorEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
Mon, 16 Aug 2010 00:52:42 +0000 (00:52 +0000)
committerKhem Raj <raj.khem@gmail.com>
Mon, 27 Sep 2010 23:49:52 +0000 (16:49 -0700)
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>
lib/oe/path.py

index f58c013..3d64cfa 100644 (file)
@@ -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