]> code.ossystems Code Review - openembedded-core.git/commitdiff
oe/license: implement ast.NodeVisitor.visit_Constant
authorRoss Burton <ross@burtonini.com>
Wed, 13 Oct 2021 15:10:23 +0000 (16:10 +0100)
committerSteve Sakoman <steve@sakoman.com>
Fri, 29 Oct 2021 14:48:40 +0000 (04:48 -1000)
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.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit abc93390a3f19bc4cc159c5690a478b9e2270906)
Signed-off-by: Steve Sakoman <steve@sakoman.com>
meta/lib/oe/license.py

index c1274a61decc9fd96d5d8d5b70c65ba14a62eb04..c4efbe142bd02cfa5ee6745933ba2ce5b9b58cba 100644 (file)
@@ -81,6 +81,9 @@ class FlattenVisitor(LicenseVisitor):
     def visit_Str(self, node):
         self.licenses.append(node.s)
 
+    def visit_Constant(self, node):
+        self.licenses.append(node.value)
+
     def visit_BinOp(self, node):
         if isinstance(node.op, ast.BitOr):
             left = FlattenVisitor(self.choose_licenses)
@@ -234,6 +237,9 @@ class ListVisitor(LicenseVisitor):
     def visit_Str(self, node):
         self.licenses.add(node.s)
 
+    def visit_Constant(self, node):
+        self.licenses.add(node.value)
+
 def list_licenses(licensestr):
     """Simply get a list of all licenses mentioned in a license string.
        Binary operators are not applied or taken into account in any way"""