mirror of
https://gitlab.com/veilid/veilid.git
synced 2024-12-26 07:49:22 -05:00
27 lines
480 B
Python
27 lines
480 B
Python
"""Load and save configuration."""
|
|
|
|
import json
|
|
from pathlib import Path
|
|
|
|
KEYFILE = Path(".demokeys")
|
|
|
|
|
|
def read_keys() -> dict:
|
|
"""Load the stored keys from disk."""
|
|
|
|
try:
|
|
keydata = KEYFILE.read_text()
|
|
except FileNotFoundError:
|
|
return {
|
|
"self": None,
|
|
"peers": {},
|
|
}
|
|
|
|
return json.loads(keydata)
|
|
|
|
|
|
def write_keys(keydata: dict):
|
|
"""Save the keys to disk."""
|
|
|
|
KEYFILE.write_text(json.dumps(keydata, indent=2))
|