Pull file operations out to a files.py
This commit is contained in:
parent
96fb77f71f
commit
ed2375386b
6 changed files with 27 additions and 20 deletions
14
files.py
Normal file
14
files.py
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue