utils.py: Add bb.utils.prune_suffix function
authorRichard Purdie <rpurdie@linux.intel.com>
Fri, 2 Jan 2009 17:26:01 +0000 (17:26 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Fri, 2 Jan 2009 17:26:01 +0000 (17:26 +0000)
ChangeLog
lib/bb/utils.py

index 8f5b4ae..9fe3bf3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 Changes in BitBake 1.8.x:
-
+       - Add bb.utils.prune_suffix function
 Changes in BitBake 1.8.12:
        - Fix -f (force) in conjunction with -b
        - Fix exit code for build failures in --continue mode
index 5015779..2469bd7 100644 (file)
@@ -394,3 +394,14 @@ def prunedir(topdir):
                 os.rmdir(os.path.join(root, name))
     os.rmdir(topdir)
 
+#
+# Could also use return re.compile("(%s)" % "|".join(map(re.escape, suffixes))).sub(lambda mo: "", var)
+# but thats possibly insane and suffixes is probably going to be small
+#
+def prune_suffix(var, suffixes, d):
+    # See if var ends with any of the suffixes listed and 
+    # remove it if found
+    for suffix in suffixes:
+        if var.endswith(suffix):
+            return var.replace(suffix, "")
+    return var