You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

22 lines
602 B

import hashlib
import os
import sys
from json import loads
import uuid
def uuid_from_string(string:str):
hex_string = hashlib.md5(string.encode("utf8")).hexdigest()
return uuid.UUID(hex=hex_string)
def app_dir():
return os.path.dirname(os.path.abspath(__file__))
def load_config(config_name):
try:
path = os.path.join(app_dir(), config_name)
print("Looking config file", path)
with open(path, "r", encoding="utf8") as f:
return loads(f.read())
except Exception as e:
print("cannot find or parse config.json", e)
sys.exit(1)