summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/license.py
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib/oe/license.py')
-rw-r--r--meta/lib/oe/license.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index bc146a28c4..254279db53 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -44,8 +44,8 @@ license_operator = re.compile('([' + license_operator_chars + '])')
44license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') 44license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$')
45 45
46class LicenseVisitor(ast.NodeVisitor): 46class LicenseVisitor(ast.NodeVisitor):
47 """Syntax tree visitor which can accept OpenEmbedded license strings""" 47 """Get elements based on OpenEmbedded license strings"""
48 def visit_string(self, licensestr): 48 def get_elements(self, licensestr):
49 new_elements = [] 49 new_elements = []
50 elements = filter(lambda x: x.strip(), license_operator.split(licensestr)) 50 elements = filter(lambda x: x.strip(), license_operator.split(licensestr))
51 for pos, element in enumerate(elements): 51 for pos, element in enumerate(elements):
@@ -57,7 +57,16 @@ class LicenseVisitor(ast.NodeVisitor):
57 raise InvalidLicense(element) 57 raise InvalidLicense(element)
58 new_elements.append(element) 58 new_elements.append(element)
59 59
60 self.visit(ast.parse(' '.join(new_elements))) 60 return new_elements
61
62 """Syntax tree visitor which can accept elements previously generated with
63 OpenEmbedded license string"""
64 def visit_elements(self, elements):
65 self.visit(ast.parse(' '.join(elements)))
66
67 """Syntax tree visitor which can accept OpenEmbedded license strings"""
68 def visit_string(self, licensestr):
69 self.visit_elements(self.get_elements(licensestr))
61 70
62class FlattenVisitor(LicenseVisitor): 71class FlattenVisitor(LicenseVisitor):
63 """Flatten a license tree (parsed from a string) by selecting one of each 72 """Flatten a license tree (parsed from a string) by selecting one of each