merge_jars.py: Make the code work on Python 3
So far the gerrit build tool chain works as expected on Python 3. The only problems that we are running into in merge_jars.py: * ZipFile.read is returning byte and not string * dict.iteritems() was removed in Python 3 Luckily, those problems can be easily rectified and code can be adjusted to be compatible with both Python version 2 and 3. Bug: Issue 7002 Change-Id: I487253b0e2e6fe4428fe60d57879424f85a198a0
This commit is contained in:
parent
c9266206a4
commit
f2099fa403
@ -17,7 +17,7 @@ from __future__ import print_function
|
||||
import collections
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
import io
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
print('usage: %s <out.zip> <in.zip>...' % sys.argv[0], file=sys.stderr)
|
||||
@ -39,12 +39,14 @@ try:
|
||||
continue
|
||||
elif n.startswith(SERVICES):
|
||||
# Concatenate all provider configuration files.
|
||||
services[n] += inzip.read(n)
|
||||
myfile = inzip.open(n, 'r')
|
||||
myfile = io.TextIOWrapper(myfile, encoding='iso-8859-1', newline='')
|
||||
services[n] += myfile.read()
|
||||
continue
|
||||
outzip.writestr(info, inzip.read(n))
|
||||
seen.add(n)
|
||||
|
||||
for n, v in services.iteritems():
|
||||
for n, v in services.items():
|
||||
outzip.writestr(n, v)
|
||||
except Exception as err:
|
||||
exit('Failed to merge jars: %s' % err)
|
||||
|
Loading…
Reference in New Issue
Block a user