From: Richard Purdie Date: Fri, 2 Jan 2009 17:26:01 +0000 (+0000) Subject: utils.py: Add bb.utils.prune_suffix function X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2ef2baff4ee6071bb2ebb783266e5e26ec2dbb98;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git utils.py: Add bb.utils.prune_suffix function --- diff --git a/ChangeLog b/ChangeLog index a2c9d80801f..c2b4d71817f 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 90ba9ac2e0b..230e06ab953 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