diff options
author | Akira Baruah <akira.baruah@gmail.com> | 2017-12-18 10:09:44 -0800 |
---|---|---|
committer | Copybara-Service <copybara-piper@google.com> | 2017-12-18 10:11:52 -0800 |
commit | 408ea37852ab0b85175d375042073b1891a26e24 (patch) | |
tree | 8315bed5c851244f7f7543eef0deb1cdf73ee19e /tools/android | |
parent | 2040c60206bb1ea9c6f603f5ef1290227bffe36a (diff) |
Update tools/ modules for compatibility with python 3.
Fixes #4097.
Fixes part of #4310.
Closes #4265.
PiperOrigin-RevId: 179437184
Diffstat (limited to 'tools/android')
-rw-r--r-- | tools/android/aar_embedded_jars_extractor.py | 2 | ||||
-rw-r--r-- | tools/android/aar_native_libs_zip_creator.py | 4 | ||||
-rw-r--r-- | tools/android/merge_manifests.py | 4 | ||||
-rw-r--r-- | tools/android/merge_manifests_test.py | 9 | ||||
-rw-r--r-- | tools/android/resource_extractor.py | 4 | ||||
-rw-r--r-- | tools/android/stubify_manifest.py | 4 |
6 files changed, 16 insertions, 11 deletions
diff --git a/tools/android/aar_embedded_jars_extractor.py b/tools/android/aar_embedded_jars_extractor.py index a46dd43b6f..393d3f4c5c 100644 --- a/tools/android/aar_embedded_jars_extractor.py +++ b/tools/android/aar_embedded_jars_extractor.py @@ -62,7 +62,7 @@ def _Main(input_aar, if not output_dir_orig: output_dir_orig = output_dir with zipfile.ZipFile(input_aar, "r") as aar: - with open(output_singlejar_param_file, "wb") as singlejar_param_file: + with open(output_singlejar_param_file, "w") as singlejar_param_file: ExtractEmbeddedJars(aar, singlejar_param_file, output_dir, output_dir_orig) diff --git a/tools/android/aar_native_libs_zip_creator.py b/tools/android/aar_native_libs_zip_creator.py index 0195d01cad..88b9db3216 100644 --- a/tools/android/aar_native_libs_zip_creator.py +++ b/tools/android/aar_native_libs_zip_creator.py @@ -63,8 +63,8 @@ def Main(input_aar_path, output_zip_path, cpu, input_aar_path_for_error_msg): try: CreateNativeLibsZip(input_aar, cpu, native_libs_zip) except UnsupportedArchitectureException: - print("AAR " + input_aar_path_for_error_msg + - " missing native libs for requested architecture: " + cpu) + print(("AAR " + input_aar_path_for_error_msg + + " missing native libs for requested architecture: " + cpu)) sys.exit(1) diff --git a/tools/android/merge_manifests.py b/tools/android/merge_manifests.py index 880c55f850..a12e53836c 100644 --- a/tools/android/merge_manifests.py +++ b/tools/android/merge_manifests.py @@ -15,6 +15,8 @@ """Merges two android manifest xml files.""" +from __future__ import print_function + import re import sys import xml.dom.minidom @@ -449,7 +451,7 @@ def main(): if FLAGS.exclude_permission: warning = _ValidateAndWarnPermissions(FLAGS.exclude_permission) if warning: - print warning + print(warning) merged_manifests = MergeManifests(_ReadFile(FLAGS.merger), _ReadFiles(FLAGS.mergee), diff --git a/tools/android/merge_manifests_test.py b/tools/android/merge_manifests_test.py index 62d0474e15..dd5a205fb0 100644 --- a/tools/android/merge_manifests_test.py +++ b/tools/android/merge_manifests_test.py @@ -532,12 +532,12 @@ class MergeManifestsTest(unittest.TestCase): ['android.permission.READ_LOGS']) result = merger.Merge() expected = xml.dom.minidom.parseString(MANUALLY_MERGED).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result)) + self.assertEqual(Reformat(expected), Reformat(result)) def testReformat(self): text = ' a\n b\n\n\n \t c' expected = 'a\nb\nc' - self.assertEquals(expected, Reformat(text)) + self.assertEqual(expected, Reformat(text)) def testValidateAndWarnPermissions(self): permissions = ['android.permission.VIBRATE', 'android.permission.LAUGH'] @@ -589,7 +589,7 @@ class MergeManifestsTest(unittest.TestCase): ['all']) result = merger.Merge() expected = xml.dom.minidom.parseString(VALID_MANIFEST).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result)) + self.assertEqual(Reformat(expected), Reformat(result)) def testMergeWithNoApplication(self): merger = merge_manifests.MergeManifests( @@ -609,7 +609,7 @@ class MergeManifestsTest(unittest.TestCase): MERGED_MANIFEST_WITH_EXTRA_NAMESPACE).toprettyxml() # Make sure the result is valid xml (not missing xmlns declarations) result_reparsed = xml.dom.minidom.parseString(result).toprettyxml() - self.assertEquals(Reformat(expected), Reformat(result_reparsed)) + self.assertEqual(Reformat(expected), Reformat(result_reparsed)) def testMergeConflictingNamespaces(self): self.maxDiff = None @@ -625,4 +625,3 @@ class MergeManifestsTest(unittest.TestCase): if __name__ == '__main__': unittest.main() - diff --git a/tools/android/resource_extractor.py b/tools/android/resource_extractor.py index 2cd11d907c..7c21f7107f 100644 --- a/tools/android/resource_extractor.py +++ b/tools/android/resource_extractor.py @@ -22,6 +22,8 @@ Usage: python resource_extractor.py <input jar> <output zip> """ +from __future__ import print_function + import sys import zipfile @@ -95,7 +97,7 @@ def ExtractResources(input_jar, output_zip): def main(argv): if len(argv) != 3: - print USAGE + print(USAGE) sys.exit(1) with zipfile.ZipFile(argv[1], 'r') as input_jar: with zipfile.ZipFile(argv[2], 'w') as output_zip: diff --git a/tools/android/stubify_manifest.py b/tools/android/stubify_manifest.py index f415774938..a51d3bbcf5 100644 --- a/tools/android/stubify_manifest.py +++ b/tools/android/stubify_manifest.py @@ -24,6 +24,8 @@ usage: %s [input manifest] [output manifest] [file for old application class] Writes the old application class into the file designated by the third argument. """ +from __future__ import print_function + import sys from xml.etree import ElementTree @@ -164,5 +166,5 @@ if __name__ == "__main__": try: main() except BadManifestException as e: - print e + print(e) sys.exit(1) |