qol changes

This commit is contained in:
venus
2026-07-13 21:11:27 -05:00
parent fbda1dd079
commit 4b16a69b1a
5 changed files with 15 additions and 11 deletions

View File

@@ -1,20 +1,20 @@
# src/ctf/utils.py
# basic utilities
import tomllib
import json
import toml
from pathlib import Path
from platformdirs import user_config_dir
# Parse config file
# Parse the config file, returning a config dictionary with relevant config options
# Load the config from file and parse with TOML
def load_config(config = f"{user_config_dir()}/ctf-config.toml") -> dict:
p = Path(config)
if p.exists():
return toml.load(p)
return{}
# Write a dictionary to the config file
def write_config(data: dict, config = f"{user_config_dir()}/ctf"):
with open(config, "w") as f:
toml.dump(data, f)
@@ -39,11 +39,7 @@ def active_competitions(dir: str) -> dict:
print(comps[item])
return comps
# Class for a competition, defining active catagories, challenges completed, etc
class competition():
def __init__(self, p: Path):
pass
# Load variables to export
config = load_config("/home/venus/code/ctf/config.toml")
competition = config["Competition"]
enviroment = config["Enviroment"]