summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2012-01-09 21:48:33 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-17 14:53:19 (GMT)
commit19247e44a388a58ea03cc91decb8b18e022efd52 (patch)
treedf6091d530c23ac5ddb49b1fece31c2f62def0db /meta/lib
parent7ce97336aad5e6ecefb5e735a13e345d1b8bd8fb (diff)
downloadpoky-19247e44a388a58ea03cc91decb8b18e022efd52.tar.gz
oe.license: avoid the need to catch SyntaxError
(From OE-Core rev: cace9ddc0edd654877d968643960fa4343472b58) Signed-off-by: Christopher Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/license.py23
1 files changed, 19 insertions, 4 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 3543cfe..5914506 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -5,13 +5,25 @@ import ast
5import re 5import re
6from fnmatch import fnmatchcase as fnmatch 6from fnmatch import fnmatchcase as fnmatch
7 7
8class InvalidLicense(StandardError): 8class LicenseError(StandardError):
9 pass
10
11class LicenseSyntaxError(LicenseError):
12 def __init__(self, licensestr, exc):
13 self.licensestr = licensestr
14 self.exc = exc
15 LicenseError.__init__(self)
16
17 def __str__(self):
18 return "error in '%s': %s" % (self.licensestr, self.exc)
19
20class InvalidLicense(LicenseError):
9 def __init__(self, license): 21 def __init__(self, license):
10 self.license = license 22 self.license = license
11 StandardError.__init__(self) 23 LicenseError.__init__(self)
12 24
13 def __str__(self): 25 def __str__(self):
14 return "invalid license '%s'" % self.license 26 return "invalid characters in license '%s'" % self.license
15 27
16license_operator = re.compile('([&|() ])') 28license_operator = re.compile('([&|() ])')
17license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') 29license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$')
@@ -59,7 +71,10 @@ class FlattenVisitor(LicenseVisitor):
59def flattened_licenses(licensestr, choose_licenses): 71def flattened_licenses(licensestr, choose_licenses):
60 """Given a license string and choose_licenses function, return a flat list of licenses""" 72 """Given a license string and choose_licenses function, return a flat list of licenses"""
61 flatten = FlattenVisitor(choose_licenses) 73 flatten = FlattenVisitor(choose_licenses)
62 flatten.visit_string(licensestr) 74 try:
75 flatten.visit_string(licensestr)
76 except SyntaxError as exc:
77 raise LicenseSyntaxError(licensestr, exc)
63 return flatten.licenses 78 return flatten.licenses
64 79
65def is_included(licensestr, whitelist=None, blacklist=None): 80def is_included(licensestr, whitelist=None, blacklist=None):