From: Ross Burton Date: Fri, 10 Dec 2021 11:08:13 +0000 (+0000) Subject: oe/license: implement ast.NodeVisitor.visit_Constant X-Git-Tag: 2021-10.2~65 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=c96241ac8e18f4ae87ec05b722a0bbfb017df578;p=openembedded-core.git 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. Signed-off-by: Ross Burton Signed-off-by: Anuj Mittal --- 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): 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"""