diff options
Diffstat (limited to 'meta/lib/oe/license.py')
| -rw-r--r-- | meta/lib/oe/license.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index 3543cfe1f6..5914506a42 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py | |||
| @@ -5,13 +5,25 @@ import ast | |||
| 5 | import re | 5 | import re |
| 6 | from fnmatch import fnmatchcase as fnmatch | 6 | from fnmatch import fnmatchcase as fnmatch |
| 7 | 7 | ||
| 8 | class InvalidLicense(StandardError): | 8 | class LicenseError(StandardError): |
| 9 | pass | ||
| 10 | |||
| 11 | class 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 | |||
| 20 | class 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 | ||
| 16 | license_operator = re.compile('([&|() ])') | 28 | license_operator = re.compile('([&|() ])') |
| 17 | license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') | 29 | license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') |
| @@ -59,7 +71,10 @@ class FlattenVisitor(LicenseVisitor): | |||
| 59 | def flattened_licenses(licensestr, choose_licenses): | 71 | def 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 | ||
| 65 | def is_included(licensestr, whitelist=None, blacklist=None): | 80 | def is_included(licensestr, whitelist=None, blacklist=None): |
