Files
kolibrios.org/modules/configs.py
Burer f9a07bcadd
All checks were successful
Docker Build and Push / build-and-push (push) Successful in 1m43s
rework and update banner on main page (#11)
Refactor banner code to be more universal, and updated it's content to GSoC 2026.

<img width="auto" alt="image.png" src="attachments/a9eee86a-eaf5-4a9b-b21c-8bd2bb6a7d07">

Reviewed-on: #11
Reviewed-by: Gleb Zaharov <risdeveau@lair.moe>
Co-authored-by: Burer <burer@kolibrios.org>
Co-committed-by: Burer <burer@kolibrios.org>
2026-03-02 11:09:15 +00:00

51 lines
1.1 KiB
Python

from os import path, listdir
from configparser import ConfigParser
import threading
_configs = {}
_loaded = False
_load_lock = threading.Lock()
def load_all_configs():
new_configs = {}
configs_dir = "configs"
if not path.isdir(configs_dir):
return new_configs
for filename in sorted(listdir(configs_dir)):
if not filename.endswith(".ini"):
continue
file_path = path.join(configs_dir, filename)
cp = ConfigParser()
with open(file_path, encoding="utf-8") as f:
cp.read_file(f)
for section in cp.sections():
section_data = new_configs.setdefault(section, {})
section_data.update(dict(cp[section]))
return new_configs
def ensure_loaded():
global _configs, _loaded
with _load_lock:
if _loaded:
return
_configs = load_all_configs()
_loaded = True
def get_section(name):
ensure_loaded()
return dict(_configs.get(name, {}))
def get_all_sections():
ensure_loaded()
return {section: dict(values) for section, values in _configs.items()}