aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-01-02 17:26:01 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-01-02 17:26:01 +0000
commit2ef2baff4ee6071bb2ebb783266e5e26ec2dbb98 (patch)
tree8797667c367e052a86bced3a6b0d65ac90ca019f
parentf2cef98d8be009580b87a9b6e1b526444a86ee63 (diff)
downloadbitbake-2ef2baff4ee6071bb2ebb783266e5e26ec2dbb98.tar.gz
utils.py: Add bb.utils.prune_suffix function
-rw-r--r--ChangeLog1
-rw-r--r--lib/bb/utils.py12
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a2c9d8080..c2b4d7181 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -169,6 +169,7 @@ Changes in Bitbake 1.9.x:
proxies to work better. (from Poky)
- Also allow user and pswd options in SRC_URIs globally (from Poky)
- Improve proxy handling when using mirrors (from Poky)
+ - Add bb.utils.prune_suffix function
Changes in Bitbake 1.8.0:
- Release 1.7.x as a stable series
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 90ba9ac2e..230e06ab9 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -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