py2to3: update tools/android/*.py to PY3
This is a rollback of commit 91b26dc4f3b327f115787c3ec35278c299480d0c and a
roll-forward of commit ad628ecfb8ed43870fb354e5d8f7da68594f95bd. Original commit
message is below.
Details:
- use six.ensure_str / six.ensure_bytes
- use absl.flags instead of gflags
- put third_party/py/abseil:srcs into @bazel_tools
so the embedded Android tools can also use it
- remove python_version = "PY2" from py_binary and
py_test rules (the default is "PY3"), except in
BUILD.tools, to preserve PY2 compatibility for
running Bazel (its embedded Python tools)
- added srcs_version = "PY2AND3" to BUILD.tools to
make it explicit that these libraries are meant
to be py2 and py3 compatible
See https://github.com/bazelbuild/bazel/issues/10127
PiperOrigin-RevId: 278394040
diff --git a/tools/android/aar_resources_extractor_test.py b/tools/android/aar_resources_extractor_test.py
index bce4a3d..9ec3a99 100644
--- a/tools/android/aar_resources_extractor_test.py
+++ b/tools/android/aar_resources_extractor_test.py
@@ -1,3 +1,4 @@
+# Lint as: python2, python3
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,12 +15,19 @@
"""Tests for aar_resources_extractor."""
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
import io
import os
import shutil
import unittest
import zipfile
+# Do not edit this line. Copybara replaces it with PY2 migration helper.
+import six
+
from tools.android import aar_resources_extractor
@@ -44,8 +52,9 @@
def DirContents(self, d):
return [
- _HostPath(path + "/" + f)
- for (path, _, files) in os.walk(d) for f in files
+ _HostPath(six.ensure_str(path) + "/" + six.ensure_str(f))
+ for (path, _, files) in os.walk(d)
+ for f in files
]
def testNoResources(self):