Replace appends with functions

main
bashrc 2026-04-25 20:13:55 +01:00
parent 412e053abd
commit be4a809f42
1 changed files with 14 additions and 18 deletions

View File

@ -1740,24 +1740,20 @@ def import_blocking_file(base_dir: str, nickname: str, domain: str,
if not append_blocks: if not append_blocks:
return True return True
try: text = ''
with open(blocking_filename, 'a+', encoding='utf-8') as fp_blocks: for new_block in append_blocks:
for new_block in append_blocks: text += new_block + '\n'
fp_blocks.write(new_block + '\n') append_string(text, blocking_filename,
except OSError: 'EX: ' +
print('EX: ' + 'unable to append imported blocks to ' +
'unable to append imported blocks to ' + blocking_filename)
blocking_filename) text = ''
for new_reason in append_reasons:
try: text += new_reason + '\n'
with open(blocking_reasons_filename, 'a+', append_string(text, blocking_reasons_filename,
encoding='utf-8') as fp_blocks: 'EX: ' +
for new_reason in append_reasons: 'unable to append imported block reasons to ' +
fp_blocks.write(new_reason + '\n') blocking_reasons_filename)
except OSError:
print('EX: ' +
'unable to append imported block reasons to ' +
blocking_reasons_filename)
return True return True