Skip to content

Commit

Permalink
Replace sys.stdout.write with print
Browse files Browse the repository at this point in the history
  • Loading branch information
corna committed Jan 11, 2018
1 parent 15e8128 commit f8f2fc1
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions me_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
# GNU General Public License for more details.
#

from __future__ import print_function

import argparse
import binascii
import hashlib
Expand Down Expand Up @@ -148,11 +150,11 @@ def remove_modules(f, mod_headers, ftpr_offset, me_end):
flags = unpack("<I", mod_header[0x50:0x54])[0]
comp_type = (flags >> 4) & 7

sys.stdout.write(" {:<16} ({:<7}, ".format(name, comp_str[comp_type]))
print(" {:<16} ({:<7}, ".format(name, comp_str[comp_type]), end="")

if comp_type == 0x00 or comp_type == 0x02:
sys.stdout.write("0x{:06x} - 0x{:06x}): "
.format(offset, offset + size))
print("0x{:06x} - 0x{:06x}): "
.format(offset, offset + size), end="")

if name in unremovable_modules:
end_addr = max(end_addr, offset + size)
Expand All @@ -163,7 +165,7 @@ def remove_modules(f, mod_headers, ftpr_offset, me_end):
print("removed")

elif comp_type == 0x01:
sys.stdout.write("fragmented data ): ")
print("fragmented data ): ", end="")
if not chunks_offsets:
f.seek(offset)
llut = f.read(4)
Expand Down Expand Up @@ -193,8 +195,8 @@ def remove_modules(f, mod_headers, ftpr_offset, me_end):
print("removed")

else:
sys.stdout.write("0x{:06x} - 0x{:06x}): unknown compression, "
"skipping".format(offset, offset + size))
print("0x{:06x} - 0x{:06x}): unknown compression, skipping"
.format(offset, offset + size), end="")

if chunks_offsets:
removable_huff_chunks = []
Expand Down Expand Up @@ -407,8 +409,8 @@ def check_and_remove_modules_me11(f, me_start, me_end, partition_offset,
else:
compression = comp_str[modules[i][2]]

sys.stdout.write(" {:<12} ({:<12}, 0x{:06x} - 0x{:06x}): "
.format(name, compression, offset, end))
print(" {:<12} ({:<12}, 0x{:06x} - 0x{:06x}): "
.format(name, compression, offset, end), end="")

if name.endswith(".man"):
print("NOT removed, partition manif.")
Expand Down Expand Up @@ -688,11 +690,9 @@ def start_end_to_flreg(start, end):
"remove"
.format(part_name, "no data here", part_length))
else:
sys.stdout.write(" {:<4} (0x{:08x} - 0x{:09x}, 0x{:08x} "
"total bytes): ".format(part_name,
part_start,
part_end,
part_length))
print(" {:<4} (0x{:08x} - 0x{:09x}, 0x{:08x} total bytes): "
.format(part_name, part_start, part_end, part_length),
end="")
if part_name in whitelist or (blacklist and
part_name not in blacklist):
unremovable_part_fpt += partition
Expand Down Expand Up @@ -831,13 +831,13 @@ def start_end_to_flreg(start, end):
.format(args.extract_me))
mef_copy = mef.save(args.extract_me, me_end - me_start)

sys.stdout.write("Checking the FTPR RSA signature of the extracted ME "
"image... ")
print("Checking the FTPR RSA signature of the extracted ME image... ",
end="")
print_check_partition_signature(mef_copy, ftpr_offset +
ftpr_mn2_offset - me_start)
mef_copy.close()

sys.stdout.write("Checking the FTPR RSA signature... ")
print("Checking the FTPR RSA signature... ", end="")
print_check_partition_signature(f, ftpr_offset + ftpr_mn2_offset)

f.close()
Expand Down

0 comments on commit f8f2fc1

Please sign in to comment.