in src/scripts/recompress_swu/src/helpers.py [0:0]
def fix_file_list(list_path, strings_to_replace, should_have_sig_file):
with open(list_path, 'r') as list:
lines = list.readlines()
for string in strings_to_replace:
value = f'{string}\n'
if value in lines:
index = lines.index(value)
lines[index] = f'{strings_to_replace[string]}\n'
do_have_sig_file = ('sw-description.sig\n' in lines)
if should_have_sig_file and not do_have_sig_file:
manifest_index = lines.index('sw-description\n')
lines.insert(manifest_index + 1, 'sw-description.sig\n')
elif not should_have_sig_file and do_have_sig_file:
lines.remove('sw-description.sig\n')
with open(list_path, 'w') as list:
lines = list.writelines(lines)