Replace file operations with function

main
bashrc 2026-04-29 13:08:09 +01:00
parent 6ad2e4c212
commit 5a4ff22aed
1 changed files with 7 additions and 7 deletions

View File

@ -510,13 +510,13 @@ def _update_common_reactions(base_dir: str, emoji_content: str) -> None:
if not reaction_found: if not reaction_found:
new_common_reactions.append(str(1).zfill(16) + ' ' + emoji_content) new_common_reactions.append(str(1).zfill(16) + ' ' + emoji_content)
new_common_reactions.sort(reverse=True) new_common_reactions.sort(reverse=True)
try:
with open(common_reactions_filename, 'w+', text = ''
encoding='utf-8') as fp_react:
for line in new_common_reactions: for line in new_common_reactions:
fp_react.write(line + '\n') text += line + '\n'
except OSError: if not save_string(text, common_reactions_filename,
print('EX: error writing common reactions 1') 'EX: error writing common reactions 1 ' +
common_reactions_filename):
return return
else: else:
line = str(1).zfill(16) + ' ' + emoji_content + '\n' line = str(1).zfill(16) + ' ' + emoji_content + '\n'