blob: e6933ef145733b922ee10513c865ccee0a146076 [file] [log] [blame]
Description: Port simg_dump to Python 3.
Author: Antonio Russo <antonio.e.russo@gmail.com>
Forwarded: not-needed
Last-Update: 2019-01-05
Origin: https://bugs.debian.org/945646
---
Index: android-platform-tools/system/core/libsparse/simg_dump.py
===================================================================
--- android-platform-tools.orig/system/core/libsparse/simg_dump.py
+++ android-platform-tools/system/core/libsparse/simg_dump.py
@@ -1,4 +1,4 @@
-#! /usr/bin/env python
+#! /usr/bin/env python3
# Copyright (C) 2012 The Android Open Source Project
#
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import print_function
+
import csv
import getopt
import hashlib
@@ -47,7 +47,7 @@ def main():
opts, args = getopt.getopt(sys.argv[1:],
"vsc:",
["verbose", "showhash", "csvfile"])
- except getopt.GetoptError, e:
+ except getopt.GetoptError as e:
print(e)
usage(me)
for o, a in opts:
@@ -66,7 +66,7 @@ def main():
usage(me)
if csvfilename:
- csvfile = open(csvfilename, "wb")
+ csvfile = open(csvfilename, "w", newline='')
csvwriter = csv.writer(csvfile)
output = verbose or csvfilename or showhash
@@ -121,7 +121,7 @@ def main():
"output offset", "output blocks", "type", "hash"])
offset = 0
- for i in xrange(1, total_chunks + 1):
+ for i in range(1, total_chunks + 1):
header_bin = FH.read(12)
header = struct.unpack("<2H2I", header_bin)
chunk_type = header[0]
@@ -160,7 +160,7 @@ def main():
if showhash:
h = hashlib.sha1()
data = fill_bin * (blk_sz / 4);
- for block in xrange(chunk_sz):
+ for block in range(chunk_sz):
h.update(data)
curhash = h.hexdigest()
elif chunk_type == 0xCAC3: