diff options
author | Ross Burton <ross@burtonini.com> | 2021-10-13 16:10:23 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-11-03 11:18:56 +0000 |
commit | 0e3391131391cae16307bd7255311eb528605f25 (patch) | |
tree | c4935382edbb1250c23652ab1b058e33be79ab18 | |
parent | b967cce9f4bab7b3f9bd0551083bd007c4c055db (diff) | |
download | poky-0e3391131391cae16307bd7255311eb528605f25.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: 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>
-rw-r--r-- | meta/lib/oe/license.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/meta/lib/oe/license.py b/meta/lib/oe/license.py index c1274a61de..c4efbe142b 100644 --- a/meta/lib/oe/license.py +++ b/meta/lib/oe/license.py | |||
@@ -81,6 +81,9 @@ class FlattenVisitor(LicenseVisitor): | |||
81 | def visit_Str(self, node): | 81 | def visit_Str(self, node): |
82 | self.licenses.append(node.s) | 82 | self.licenses.append(node.s) |
83 | 83 | ||
84 | def visit_Constant(self, node): | ||
85 | self.licenses.append(node.value) | ||
86 | |||
84 | def visit_BinOp(self, node): | 87 | def visit_BinOp(self, node): |
85 | if isinstance(node.op, ast.BitOr): | 88 | if isinstance(node.op, ast.BitOr): |
86 | left = FlattenVisitor(self.choose_licenses) | 89 | left = FlattenVisitor(self.choose_licenses) |
@@ -234,6 +237,9 @@ class ListVisitor(LicenseVisitor): | |||
234 | def visit_Str(self, node): | 237 | def visit_Str(self, node): |
235 | self.licenses.add(node.s) | 238 | self.licenses.add(node.s) |
236 | 239 | ||
240 | def visit_Constant(self, node): | ||
241 | self.licenses.add(node.value) | ||
242 | |||
237 | def list_licenses(licensestr): | 243 | def list_licenses(licensestr): |
238 | """Simply get a list of all licenses mentioned in a license string. | 244 | """Simply get a list of all licenses mentioned in a license string. |
239 | Binary operators are not applied or taken into account in any way""" | 245 | Binary operators are not applied or taken into account in any way""" |