The bot will attempt to keep producing groups with entirely unique matches based on the full history of matches until it can't. It'll then step forward and ignore a week of history and try again, ignoring more history until no history is left
20 lines
498 B
Python
20 lines
498 B
Python
"""File operation helpers"""
|
|
import json
|
|
import shutil
|
|
|
|
|
|
def load(file: str) -> dict:
|
|
"""Load a json file directly as a dict"""
|
|
with open(file) as f:
|
|
return json.load(f)
|
|
|
|
|
|
def save(file: str, content: dict):
|
|
"""
|
|
Save out a content dictionary to a file
|
|
Stores it in an intermediary file first incase the dump fails
|
|
"""
|
|
intermediate = file + ".nxt"
|
|
with open(intermediate, "w") as f:
|
|
json.dump(content, f, indent=4)
|
|
shutil.move(intermediate, file)
|