aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-04-22 14:13:14 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-04-22 14:13:14 +0000
commit47a3532c84ed77d8eefe3c30f779d81e68e9eae3 (patch)
treee255e8c086869ce8d18f20dff5bc3451ba327823
parent0020f68936c101ebc86b9ee74d75bdb389f348d9 (diff)
parentd879ec808aa795cc7938afaedd1a648e292224dd (diff)
downloadrepohooks-47a3532c84ed77d8eefe3c30f779d81e68e9eae3.tar.gz
Snap for 7304196 from d879ec808aa795cc7938afaedd1a648e292224dd to studio-4.3-releasestudio-4.3.0studio-2020.3.1
Change-Id: I2176b9469b3edda95c69bcea32638cfb0a4c9ef2
-rw-r--r--OWNERS2
-rwxr-xr-xtools/google-java-format-diff.py18
2 files changed, 9 insertions, 11 deletions
diff --git a/OWNERS b/OWNERS
index 2c5ab89..ff38166 100644
--- a/OWNERS
+++ b/OWNERS
@@ -1,3 +1,3 @@
# No changes should be made directly in studio-master-dev
# See b/149406150 for more details.
-vsiva
+vsiva@google.com
diff --git a/tools/google-java-format-diff.py b/tools/google-java-format-diff.py
index b804f30..c398d2f 100755
--- a/tools/google-java-format-diff.py
+++ b/tools/google-java-format-diff.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2.7
+#!/usr/bin/env python3
#
#===- google-java-format-diff.py - google-java-format Diff Reformatter -----===#
#
@@ -24,16 +24,14 @@ Example usage for git/svn users:
import argparse
import difflib
+import io
import os
import platform
import re
-import six
import string
import subprocess
import sys
from distutils.spawn import find_executable
-from io import StringIO
-from six import StringIO
def find_executable_portable(executable):
if platform.system() == 'Windows':
@@ -106,7 +104,7 @@ def main():
['-lines', str(start_line) + ':' + str(end_line)])
# Reformat files containing changes in place.
- for filename, lines in six.iteritems(lines_by_file):
+ for filename, lines in lines_by_file.items():
if args.i and args.verbose:
print('Formatting %s' % filename)
command = [binary]
@@ -131,15 +129,15 @@ def main():
sys.exit(p.returncode);
if not args.i:
- # Open in binary mode to prevent Python from messing with line endings.
- with open(filename, 'rb') as f:
+ # `newline=''` prevents Python from translating line endings.
+ with open(filename, 'r', newline='') as f:
code = f.readlines()
- formatted_code = StringIO(stdout.decode('utf-8')).readlines()
+ formatted_code = io.StringIO(stdout.decode('utf-8')).readlines()
diff = difflib.unified_diff(code, formatted_code,
filename, filename,
'(before formatting)', '(after formatting)')
- diff_string = string.join(diff, '')
- if len(diff_string) > 0:
+ diff_string = ''.join(diff)
+ if diff_string:
sys.stdout.write(diff_string)
if __name__ == '__main__':