Skip to content

Commit

Permalink
Use with statements
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Mar 11, 2023
1 parent 515345b commit 0aea03e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions plexanisync/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def int_to_roman_numeral(decimal: int) -> str:


def log_to_file(message: str):
file = open("failed_matches.txt", "a+", encoding="utf-8")
file.write(f"{message}\n")
file.close()
with open("failed_matches.txt", "a+", encoding="utf-8") as file:
file.write(f"{message}\n")


def clean_failed_matches_file():
try:
# create or overwrite the file with empty content
open("failed_matches.txt", 'w', encoding="utf-8").close()
with open("failed_matches.txt", 'w', encoding="utf-8"):
pass
except BaseException:
pass

Expand Down

0 comments on commit 0aea03e

Please sign in to comment.