From 5344227db45e48963d0a1a283ded7dcff1b3c68e Mon Sep 17 00:00:00 2001 From: Antonio Russo Date: Wed, 11 Jan 2023 08:19:44 +0000 Subject: [PATCH] Port simg_dump to Python 3. Forwarded: not-needed Last-Update: 2019-01-05 Origin: https://bugs.debian.org/945646 Gbp-Pq: Topic system/core Gbp-Pq: Name simg_dump-python3.patch --- system/core/libsparse/simg_dump.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/system/core/libsparse/simg_dump.py b/system/core/libsparse/simg_dump.py index 82a03ad9..6fed2660 100755 --- a/system/core/libsparse/simg_dump.py +++ b/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: -- 2.30.2