1
0
Fork 0

Fix read/write of newlines in already_posted.

This commit is contained in:
Casper V. Kristensen 2019-03-10 23:26:43 +01:00
parent de8e447954
commit 30827f9458
Signed by: caspervk
GPG key ID: 289CA03790535054

View file

@ -147,7 +147,7 @@ def generate(post=False, pm_recipients=None) -> None:
def load_already_posted() -> Set[str]:
try:
with DATA_DIR.joinpath("already_posted").open() as file:
return {line.rstrip() for line in file.readlines()}
return {line.rstrip() for line in file}
except FileNotFoundError:
return set()
@ -155,4 +155,4 @@ def load_already_posted() -> Set[str]:
def save_already_posted(already_posted) -> None:
logger.info("Saving already posted to file")
with DATA_DIR.joinpath("already_posted").open("w") as file:
file.writelines(already_posted)
file.writelines(f"{dirname}\n" for dirname in already_posted)