summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe
diff options
context:
space:
mode:
authorChristopher Larson <chris_larson@mentor.com>2012-01-09 15:48:33 -0600
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-01-17 14:53:19 +0000
commit19247e44a388a58ea03cc91decb8b18e022efd52 (patch)
treedf6091d530c23ac5ddb49b1fece31c2f62def0db /meta/lib/oe
parent7ce97336aad5e6ecefb5e735a13e345d1b8bd8fb (diff)
downloadast2050-yocto-poky-19247e44a388a58ea03cc91decb8b18e022efd52.zip
ast2050-yocto-poky-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/oe')
-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
import re
from fnmatch import fnmatchcase as fnmatch
-class InvalidLicense(StandardError):
+class LicenseError(StandardError):
+ pass
+
+class LicenseSyntaxError(LicenseError):
+ def __init__(self, licensestr, exc):
+ self.licensestr = licensestr
+ self.exc = exc
+ LicenseError.__init__(self)
+
+ def __str__(self):
+ return "error in '%s': %s" % (self.licensestr, self.exc)
+
+class InvalidLicense(LicenseError):
def __init__(self, license):
self.license = license
- StandardError.__init__(self)
+ LicenseError.__init__(self)
def __str__(self):
- return "invalid license '%s'" % self.license
+ return "invalid characters in license '%s'" % self.license
license_operator = re.compile('([&|() ])')
license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$')
@@ -59,7 +71,10 @@ class FlattenVisitor(LicenseVisitor):
def flattened_licenses(licensestr, choose_licenses):
"""Given a license string and choose_licenses function, return a flat list of licenses"""
flatten = FlattenVisitor(choose_licenses)
- flatten.visit_string(licensestr)
+ try:
+ flatten.visit_string(licensestr)
+ except SyntaxError as exc:
+ raise LicenseSyntaxError(licensestr, exc)
return flatten.licenses
def is_included(licensestr, whitelist=None, blacklist=None):
OpenPOWER on IntegriCloud