summaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/license.py
diff options
context:
space:
mode:
authorRoss Burton <ross@burtonini.com>2021-10-13 16:10:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-10-14 22:32:50 +0100
commitb6611957cc19b70c51e49af8552f81e0a347a393 (patch)
tree42d8440a62c027cb4479f85ceeb87d7464d2b239 /meta/lib/oe/license.py
parent47d033595a2120749424494781a66a70311732dc (diff)
downloadpoky-b6611957cc19b70c51e49af8552f81e0a347a393.tar.gz
oe/license: implement ast.NodeVisitor.visit_Constant
Since Python 3.8 visit_Num(), visit_Str() and so on are all deprecated and replaced with visit_Constant. We can't yet remove the deprecated functions until we require 3.8, but we can implement visit_Constant to silence the deprecation warnings. (From OE-Core rev: abc93390a3f19bc4cc159c5690a478b9e2270906) Signed-off-by: Ross Burton <ross.burton@arm.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/license.py')
-rw-r--r--meta/lib/oe/license.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py
index 665d32ecbb..b5d378a549 100644
--- a/meta/lib/oe/license.py
+++ b/meta/lib/oe/license.py
@@ -74,6 +74,9 @@ class FlattenVisitor(LicenseVisitor):
74 def visit_Str(self, node): 74 def visit_Str(self, node):
75 self.licenses.append(node.s) 75 self.licenses.append(node.s)
76 76
77 def visit_Constant(self, node):
78 self.licenses.append(node.value)
79
77 def visit_BinOp(self, node): 80 def visit_BinOp(self, node):
78 if isinstance(node.op, ast.BitOr): 81 if isinstance(node.op, ast.BitOr):
79 left = FlattenVisitor(self.choose_licenses) 82 left = FlattenVisitor(self.choose_licenses)
@@ -227,6 +230,9 @@ class ListVisitor(LicenseVisitor):
227 def visit_Str(self, node): 230 def visit_Str(self, node):
228 self.licenses.add(node.s) 231 self.licenses.add(node.s)
229 232
233 def visit_Constant(self, node):
234 self.licenses.add(node.value)
235
230def list_licenses(licensestr): 236def list_licenses(licensestr):
231 """Simply get a list of all licenses mentioned in a license string. 237 """Simply get a list of all licenses mentioned in a license string.
232 Binary operators are not applied or taken into account in any way""" 238 Binary operators are not applied or taken into account in any way"""