🧑‍💻 Fix RLE script for infille == outfile (#26795)

This commit is contained in:
ellensp 2024-03-17 07:37:42 +13:00 committed by GitHub
parent bca40e07e3
commit d36b3fbf9d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -10,6 +10,8 @@ import sys,struct
import re import re
def addCompressedData(input_file, output_file): def addCompressedData(input_file, output_file):
input_lines = input_file.readlines()
input_file.close()
ofile = open(output_file, 'wt') ofile = open(output_file, 'wt')
datatype = "uint8_t" datatype = "uint8_t"
@ -18,8 +20,7 @@ def addCompressedData(input_file, output_file):
arrname = '' arrname = ''
c_data_section = False ; c_skip_data = False ; c_footer = False c_data_section = False ; c_skip_data = False ; c_footer = False
while True: for line in input_lines:
line = input_file.readline()
if not line: break if not line: break
if not c_footer: if not c_footer:
@ -56,8 +57,6 @@ def addCompressedData(input_file, output_file):
arrname = line.split('[')[0].split(' ')[-1] arrname = line.split('[')[0].split(' ')[-1]
print("Found data array", arrname) print("Found data array", arrname)
input_file.close()
#print("\nRaw Bitmap Data", raw_data) #print("\nRaw Bitmap Data", raw_data)
# #
@ -190,11 +189,11 @@ if len(sys.argv) <= 2:
print('Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE') print('Usage: rle_compress_bitmap.py INPUT_FILE OUTPUT_FILE')
exit(1) exit(1)
output_cpp = sys.argv[2] output_h = sys.argv[2]
inname = sys.argv[1].replace('//', '/') inname = sys.argv[1].replace('//', '/')
try: try:
input_cpp = open(inname) input_h = open(inname)
print("Processing", inname, "...") print("Processing", inname, "...")
addCompressedData(input_cpp, output_cpp) addCompressedData(input_h, output_h)
except OSError: except OSError:
print("Can't find input file", inname) print("Can't find input file", inname)