From bb3469f9d32ff18cf308a308869c0ae3500b5a15 Mon Sep 17 00:00:00 2001 From: Aníbal Limón Date: Fri, 8 May 2015 20:41:30 +0000 Subject: license: Split visit_string in LicenseVisitor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Create get_elements and visit_elements in LicenseVisitor based on visit_string this allow to do modifications on elements before parsing with AST. (From OE-Core rev: c16cf0a0331d128e4ba7341fe28510a9bfb7ee16) Signed-off-by: Aníbal Limón Signed-off-by: Richard Purdie --- meta/lib/oe/license.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'meta') 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 + '])') license_pattern = re.compile('[a-zA-Z0-9.+_\-]+$') class LicenseVisitor(ast.NodeVisitor): - """Syntax tree visitor which can accept OpenEmbedded license strings""" - def visit_string(self, licensestr): + """Get elements based on OpenEmbedded license strings""" + def get_elements(self, licensestr): new_elements = [] elements = filter(lambda x: x.strip(), license_operator.split(licensestr)) for pos, element in enumerate(elements): @@ -57,7 +57,16 @@ class LicenseVisitor(ast.NodeVisitor): raise InvalidLicense(element) new_elements.append(element) - self.visit(ast.parse(' '.join(new_elements))) + return new_elements + + """Syntax tree visitor which can accept elements previously generated with + OpenEmbedded license string""" + def visit_elements(self, elements): + self.visit(ast.parse(' '.join(elements))) + + """Syntax tree visitor which can accept OpenEmbedded license strings""" + def visit_string(self, licensestr): + self.visit_elements(self.get_elements(licensestr)) class FlattenVisitor(LicenseVisitor): """Flatten a license tree (parsed from a string) by selecting one of each -- cgit 1.2.3-korg inative'>master-uninative OpenEmbedded Core layerGrokmirror user
summaryrefslogtreecommitdiffstats
blob: 03989ab5369ff675ab422fd55d67cc26d69116cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28