aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCole Faust <colefaust@google.com>2022-04-13 00:35:14 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-04-13 00:35:14 +0000
commitb5867e2adff1e3665fe129325807da09d81718c7 (patch)
treeee1eb25ae09cda0134fe9275f265934197fec1a2
parent917243e6ff73ad704c5b2576b3c6cc254b07f899 (diff)
parent9cb0c67c72d46d394bea21797755e2bdd99985f9 (diff)
downloadconfigs-b5867e2adff1e3665fe129325807da09d81718c7.tar.gz
Convert kconfig_xml_fixup to python 3 am: 9cb0c67c72
Original change: https://android-review.googlesource.com/c/kernel/configs/+/2061123 Change-Id: I08a078a947955f2602eeb9e0660beae77798a306 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--tools/Android.bp9
-rwxr-xr-xtools/kconfig_xml_fixup.py65
2 files changed, 29 insertions, 45 deletions
diff --git a/tools/Android.bp b/tools/Android.bp
index 4149318..016775a 100644
--- a/tools/Android.bp
+++ b/tools/Android.bp
@@ -10,13 +10,4 @@ python_binary_host {
srcs: [
"kconfig_xml_fixup.py",
],
-
- version: {
- py2: {
- enabled: true,
- },
- py3: {
- enabled: false,
- },
- },
}
diff --git a/tools/kconfig_xml_fixup.py b/tools/kconfig_xml_fixup.py
index d833a1a..bbdbf41 100755
--- a/tools/kconfig_xml_fixup.py
+++ b/tools/kconfig_xml_fixup.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
# The format of the kernel configs in the framework compatibility matrix
# has a couple properties that would make it confusing or cumbersome to
@@ -24,47 +24,40 @@ import re
import sys
def fixup(args):
- source_f = open(args.input) or die ("Could not open %s" % args.input)
-
- # The first line of the conditional xml has the tag containing
- # the kernel min LTS version.
- line = source_f.readline()
- exp_re = re.compile(r"^<kernel minlts=\"(\d+).(\d+).(\d+)\"\s+/>")
- exp_match = re.match(exp_re, line)
- assert exp_match, "Malformatted kernel conditional config file.\n"
-
- major = exp_match.group(1)
- minor = exp_match.group(2)
- tiny = exp_match.group(3)
+ with open(args.input) as source_f:
+ # The first line of the conditional xml has the tag containing
+ # the kernel min LTS version.
+ line = source_f.readline()
+ exp_re = re.compile(r"^<kernel minlts=\"(\d+).(\d+).(\d+)\"\s+/>")
+ exp_match = re.match(exp_re, line)
+ assert exp_match, "Malformatted kernel conditional config file.\n"
- if args.output_version:
- version_f = (open(args.output_version, "w+") or
- die("Could not open version file"))
- version_f.write("{}.{}.{}".format(major, minor, tiny))
- version_f.close()
+ major = exp_match.group(1)
+ minor = exp_match.group(2)
+ tiny = exp_match.group(3)
- if args.output_matrix:
- dest_f = (open(args.output_matrix, "w+") or
- die("Could not open destination file"))
- dest_f.write("<compatibility-matrix version=\"1.0\" type=\"framework\">\n")
+ if args.output_version:
+ with open(args.output_version, "w+") as version_f:
+ version_f.write("{}.{}.{}".format(major, minor, tiny))
- # First <kernel> must not have <condition> for libvintf backwards compatibility.
- dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny))
+ if args.output_matrix:
+ with open(args.output_matrix, "w+") as dest_f:
+ dest_f.write("<compatibility-matrix version=\"1.0\" type=\"framework\">\n")
- line = source_f.readline()
- while line:
- line = line.replace("<value type=\"bool\">",
- "<value type=\"tristate\">")
- line = line.replace("<group>",
- "<kernel version=\"{}.{}.{}\">".format(major, minor, tiny))
- line = line.replace("</group>", "</kernel>")
- dest_f.write(line)
- line = source_f.readline()
+ # First <kernel> must not have <condition> for libvintf backwards compatibility.
+ dest_f.write("<kernel version=\"{}.{}.{}\" />".format(major, minor, tiny))
- dest_f.write("</compatibility-matrix>")
- dest_f.close()
+ line = source_f.readline()
+ while line:
+ line = line.replace("<value type=\"bool\">",
+ "<value type=\"tristate\">")
+ line = line.replace("<group>",
+ "<kernel version=\"{}.{}.{}\">".format(major, minor, tiny))
+ line = line.replace("</group>", "</kernel>")
+ dest_f.write(line)
+ line = source_f.readline()
- source_f.close()
+ dest_f.write("</compatibility-matrix>")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)