[OE-core] [PATCH 1/2] utils: add helper to perform the union of two string lists

Matt Madison matt at madison.systems
Fri May 22 12:18:03 UTC 2015


On Fri, 2015-05-22 at 12:38 +0100, Ross Burton wrote:
> Signed-off-by: Ross Burton <ross.burton at intel.com>
> ---
>  meta/lib/oe/utils.py | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> index b8224de..f70bd86 100644
> --- a/meta/lib/oe/utils.py
> +++ b/meta/lib/oe/utils.py
> @@ -55,6 +55,21 @@ def both_contain(variable1, variable2, checkvalue, d):
>      else:
>          return ""
>  
> +def set_union(variable1, variable2, d):
> +    """
> +    Expand both variables, interpret them as lists of strings, and return the
> +    union as a flattened string.


This function is returning the intersection of the two sets, not the
union.  Maybe change the name and the comment here?


> +
> +    For example:
> +    s1 = "a b c"
> +    s2 = "b c d"
> +    s3 = set_union(s1, s2)
> +    => s3 = "b c"
> +    """
> +    val1 = set(d.getVar(variable1, True).split())
> +    val2 = set(d.getVar(variable2, True).split())
> +    return " ".join(val1 & val2)
> +
>  def prune_suffix(var, suffixes, d):
>      # See if var ends with any of the suffixes listed and
>      # remove it if found
> -- 
> 2.1.4
> 

-Matt




More information about the Openembedded-core mailing list