]> 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)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 14 Oct 2021 21:31:56 +0000 (22:31 +0100)
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>
meta/lib/oe/license.py

index 665d32ecbb1a5298011d73204248e5da39fc78fe..b5d378a549be8348ac48ca96cb36aea5de76fe62 100644 (file)
@@ -74,6 +74,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)
@@ -227,6 +230,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"""