Replace file operations with function

main
bashrc 2026-04-29 13:13:36 +01:00
parent 5a4ff22aed
commit 721907ca4d
1 changed files with 6 additions and 8 deletions

View File

@ -160,13 +160,11 @@ def question_update_votes(base_dir: str, nickname: str, domain: str,
else: else:
newlines.append(vote_line) newlines.append(vote_line)
if save_voters_file: if save_voters_file:
try: text = ''
with open(voters_filename, 'w+',
encoding='utf-8') as fp_voters:
for vote_line in newlines: for vote_line in newlines:
fp_voters.write(vote_line) text += vote_line
except OSError: save_string(text, voters_filename,
print('EX: unable to write voters file2 ' + 'EX: unable to write voters file2 ' +
voters_filename) voters_filename)
else: else:
return None, None return None, None