Pull file operations out to a files.py

This commit is contained in:
Marc Di Luzio 2024-08-10 10:58:31 +01:00
parent 96fb77f71f
commit ed2375386b
6 changed files with 27 additions and 20 deletions

14
files.py Normal file
View file

@ -0,0 +1,14 @@
"""File operation helpers"""
import json
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"""
with open(file, "w") as f:
json.dump(content, f, indent=4)