diff options
Diffstat (limited to 'meta/lib/oe/license.py')
-rw-r--r-- | meta/lib/oe/license.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index 8d2fd1709c..ca385d5187 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py | |||
@@ -106,7 +106,8 @@ def is_included(licensestr, whitelist=None, blacklist=None): | |||
106 | license string matches the whitelist and does not match the blacklist. | 106 | license string matches the whitelist and does not match the blacklist. |
107 | 107 | ||
108 | Returns a tuple holding the boolean state and a list of the applicable | 108 | Returns a tuple holding the boolean state and a list of the applicable |
109 | licenses which were excluded (or None, if the state is True) | 109 | licenses that were excluded if state is False, or the licenses that were |
110 | included if the state is True. | ||
110 | """ | 111 | """ |
111 | 112 | ||
112 | def include_license(license): | 113 | def include_license(license): |
@@ -117,10 +118,17 @@ def is_included(licensestr, whitelist=None, blacklist=None): | |||
117 | 118 | ||
118 | def choose_licenses(alpha, beta): | 119 | def choose_licenses(alpha, beta): |
119 | """Select the option in an OR which is the 'best' (has the most | 120 | """Select the option in an OR which is the 'best' (has the most |
120 | included licenses).""" | 121 | included licenses and no excluded licenses).""" |
121 | alpha_weight = len(list(filter(include_license, alpha))) | 122 | # The factor 1000 below is arbitrary, just expected to be much larger |
122 | beta_weight = len(list(filter(include_license, beta))) | 123 | # that the number of licenses actually specified. That way the weight |
123 | if alpha_weight > beta_weight: | 124 | # will be negative if the list of licenses contains an excluded license, |
125 | # but still gives a higher weight to the list with the most included | ||
126 | # licenses. | ||
127 | alpha_weight = (len(list(filter(include_license, alpha))) - | ||
128 | 1000 * (len(list(filter(exclude_license, alpha))) > 0)) | ||
129 | beta_weight = (len(list(filter(include_license, beta))) - | ||
130 | 1000 * (len(list(filter(exclude_license, beta))) > 0)) | ||
131 | if alpha_weight >= beta_weight: | ||
124 | return alpha | 132 | return alpha |
125 | else: | 133 | else: |
126 | return beta | 134 | return beta |