mirror of
https://git.yoctoproject.org/poky
synced 2026-04-23 09:32:17 +02:00
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: 18f10a51387cdee7c7058a3cb3f7c8c24c57c36a) 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> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
committed by
Richard Purdie
parent
b967cce9f4
commit
0e33911313
@@ -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"""
|
||||
|
||||
Reference in New Issue
Block a user