diff options
author | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 17:26:01 +0000 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2009-01-02 17:26:01 +0000 |
commit | 98fc3ff703bbf65d4c29ffe788511c17e132a0fd (patch) | |
tree | ff67d867d8501caa8c401c1ee62175fcd11ace48 /lib | |
parent | d411dbed96a7af631859fd29a70e720a99abdb36 (diff) | |
download | bitbake-98fc3ff703bbf65d4c29ffe788511c17e132a0fd.tar.gz |
utils.py: Add bb.utils.prune_suffix function
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bb/utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py index 5015779f8..2469bd7ee 100644 --- a/lib/bb/utils.py +++ b/lib/bb/utils.py @@ -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 |