]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Add bb.utils.prune_suffix()
authorRichard Purdie <rpurdie@linux.intel.com>
Wed, 31 Dec 2008 22:58:57 +0000 (22:58 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Wed, 31 Dec 2008 22:58:57 +0000 (22:58 +0000)
bitbake-dev/lib/bb/utils.py
bitbake/lib/bb/utils.py

index 90ba9ac2e0b0f1610386f6bf60a8a591c52bac67..230e06ab953327d42e9fcba20290855c74982645 100644 (file)
@@ -393,3 +393,15 @@ def prunedir(topdir):
             else:
                 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
index 5015779f8d2342ad329ba73126ae284920762bd2..2469bd7ee288db30cb0bb761e31b335140e16e95 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