cleaning things up by refactoring and combining files

This commit is contained in:
venus
2026-07-19 01:31:09 -05:00
parent 7f00bdb385
commit 185482f3d5
14 changed files with 335 additions and 154 deletions

26
src/ctf/config.py Normal file
View File

@@ -0,0 +1,26 @@
# src/ctf/config.py
# {{{ imports
import toml
from pathlib import Path
from platformdirs import user_config_dir
# }}}
# {{{ load_config
def load_config(config = f"{user_config_dir()}/ctf-config.toml") -> dict:
p = Path(config)
if p.exists():
return toml.load(p)
return {}
# }}}
# {{{ write_config
def write_config(data: dict, config = f"{user_config_dir()}/ctf"):
with open(config, "w") as f:
toml.dump(data, f)
# }}}
# {{{ exports
config_data = load_config("/home/venus/code/ctf/config.toml")
competition = config_data.get("Competition", {})
enviroment = config_data.get("Enviroment", {})
# }}}