瀏覽代碼

utils.py: Add bb.utils.prune_suffix function

Richard Purdie 15 年之前
父節點
當前提交
2ef2baff4e
共有 2 個文件被更改,包括 13 次插入0 次删除
  1. 1 0
      ChangeLog
  2. 12 0
      lib/bb/utils.py

+ 1 - 0
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

+ 12 - 0
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