Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 1 | Description: Port simg_dump to Python 3. |
| 2 | Author: Antonio Russo <antonio.e.russo@gmail.com> |
| 3 | Forwarded: not-needed |
| 4 | Last-Update: 2019-01-05 |
| 5 | Origin: https://bugs.debian.org/945646 |
| 6 | |
| 7 | --- |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame^] | 8 | Upstream-Status: Pending |
| 9 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 10 | Index: android-platform-tools/system/core/libsparse/simg_dump.py |
| 11 | =================================================================== |
| 12 | --- android-platform-tools.orig/system/core/libsparse/simg_dump.py |
| 13 | +++ android-platform-tools/system/core/libsparse/simg_dump.py |
| 14 | @@ -1,4 +1,4 @@ |
| 15 | -#! /usr/bin/env python |
| 16 | +#! /usr/bin/env python3 |
| 17 | |
| 18 | # Copyright (C) 2012 The Android Open Source Project |
| 19 | # |
| 20 | @@ -14,7 +14,7 @@ |
| 21 | # See the License for the specific language governing permissions and |
| 22 | # limitations under the License. |
| 23 | |
| 24 | -from __future__ import print_function |
| 25 | + |
| 26 | import csv |
| 27 | import getopt |
| 28 | import hashlib |
| 29 | @@ -47,7 +47,7 @@ def main(): |
| 30 | opts, args = getopt.getopt(sys.argv[1:], |
| 31 | "vsc:", |
| 32 | ["verbose", "showhash", "csvfile"]) |
| 33 | - except getopt.GetoptError, e: |
| 34 | + except getopt.GetoptError as e: |
| 35 | print(e) |
| 36 | usage(me) |
| 37 | for o, a in opts: |
| 38 | @@ -66,7 +66,7 @@ def main(): |
| 39 | usage(me) |
| 40 | |
| 41 | if csvfilename: |
| 42 | - csvfile = open(csvfilename, "wb") |
| 43 | + csvfile = open(csvfilename, "w", newline='') |
| 44 | csvwriter = csv.writer(csvfile) |
| 45 | |
| 46 | output = verbose or csvfilename or showhash |
| 47 | @@ -121,7 +121,7 @@ def main(): |
| 48 | "output offset", "output blocks", "type", "hash"]) |
| 49 | |
| 50 | offset = 0 |
| 51 | - for i in xrange(1, total_chunks + 1): |
| 52 | + for i in range(1, total_chunks + 1): |
| 53 | header_bin = FH.read(12) |
| 54 | header = struct.unpack("<2H2I", header_bin) |
| 55 | chunk_type = header[0] |
| 56 | @@ -160,7 +160,7 @@ def main(): |
| 57 | if showhash: |
| 58 | h = hashlib.sha1() |
| 59 | data = fill_bin * (blk_sz / 4); |
| 60 | - for block in xrange(chunk_sz): |
| 61 | + for block in range(chunk_sz): |
| 62 | h.update(data) |
| 63 | curhash = h.hexdigest() |
| 64 | elif chunk_type == 0xCAC3: |