Merge "Fix python3 incompatiable code" am: 7a048996b7 am: 4d6bc649e8 am: bff0316e3c

Original change: https://android-review.googlesource.com/c/platform/build/+/1886461

Change-Id: I6ab6e845e36caa8c4d3b618ff12ba88250c46832
This commit is contained in:
Tianjie Xu
2021-11-10 17:53:26 +00:00
committed by Automerger Merge Worker

View File

@@ -82,7 +82,7 @@ def rewrite_build_property(original, new):
skip = True skip = True
break break
if not skip: if not skip:
new.write(line) new.write(line.encode())
def trim_install_recovery(original, new): def trim_install_recovery(original, new):
@@ -91,7 +91,7 @@ def trim_install_recovery(original, new):
partition. partition.
""" """
for line in original: for line in original:
new.write(re.sub(r'[0-9a-f]{40}', '0'*40, line)) new.write(re.sub(r'[0-9a-f]{40}', '0'*40, line).encode())
def sort_file(original, new): def sort_file(original, new):
""" """
@@ -101,7 +101,7 @@ def sort_file(original, new):
lines = original.readlines() lines = original.readlines()
lines.sort() lines.sort()
for line in lines: for line in lines:
new.write(line) new.write(line.encode())
# Map files to the functions that will modify them for diffing # Map files to the functions that will modify them for diffing
REWRITE_RULES = { REWRITE_RULES = {
@@ -148,7 +148,7 @@ def diff(name, file1, file2, out_file):
if stdout == 'Binary files %s and %s differ' % (f1, f2): if stdout == 'Binary files %s and %s differ' % (f1, f2):
print("%s: Binary files differ" % name, file=out_file) print("%s: Binary files differ" % name, file=out_file)
else: else:
for line in stdout.strip().split('\n'): for line in stdout.strip().split(b'\n'):
print("%s: %s" % (name, line), file=out_file) print("%s: %s" % (name, line), file=out_file)
def recursiveDiff(prefix, dir1, dir2, out_file): def recursiveDiff(prefix, dir1, dir2, out_file):