32 lines
656 B
Python
32 lines
656 B
Python
# utils
|
|
|
|
import os
|
|
import json
|
|
|
|
def get_path(*path):
|
|
return os.path.join(os.getcwd(), *path)
|
|
|
|
def get_config(name):
|
|
with open(get_path("configs/vars.json"), "r") as f:
|
|
config = json.loads(f.read())
|
|
f.close()
|
|
|
|
return config[name]
|
|
|
|
def set_config(name, value):
|
|
with open(get_path("configs/vars.json"), "r") as f:
|
|
config = json.loads(f.read())
|
|
f.close()
|
|
|
|
config[name] = value
|
|
|
|
with open(get_path("configs/vars.json"), "w") as f:
|
|
f.write(json.dumps(config, indent=4))
|
|
f.close()
|
|
|
|
def get_index_meta(version):
|
|
with open(get_path(f"configs/indexes/index.{version}.meta.json"), "r") as f:
|
|
meta = json.loads(f.read())
|
|
f.close()
|
|
|
|
return meta
|