From 8c7082de0ad2a963b5823834a83723127ddb454e Mon Sep 17 00:00:00 2001 From: Aníbal Limón Date: Fri, 8 May 2015 20:41:29 +0000 Subject: license_class: Generalize license_ok function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add dont_want_licenses as parameter to license_ok function and move it to oe.license module in order to use in other modules. (From OE-Core rev: 243fe3a4583a21ad6c0b2a26196ed18d41740f7a) Signed-off-by: Aníbal Limón Signed-off-by: Richard Purdie --- meta/lib/oe/license.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'meta/lib/oe/license.py') diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index 31ca15b574..bc146a28c4 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py @@ -5,6 +5,20 @@ import ast import re from fnmatch import fnmatchcase as fnmatch +def license_ok(license, dont_want_licenses): + """ Return False if License exist in dont_want_licenses else True """ + for dwl in dont_want_licenses: + # If you want to exclude license named generically 'X', we + # surely want to exclude 'X+' as well. In consequence, we + # will exclude a trailing '+' character from LICENSE in + # case INCOMPATIBLE_LICENSE is not a 'X+' license. + lic = license + if not re.search('\+$', dwl): + lic = re.sub('\+', '', license) + if fnmatch(lic, dwl): + return False + return True + class LicenseError(Exception): pass -- cgit v1.2.3-54-g00ecf