Initial commit

This commit is contained in:
unknown
2026-05-14 00:42:39 +02:00
commit dae8a0a4a1
37 changed files with 1226 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import configparser
from pathlib import Path
#from serverside.consts import BASE_DIR
BASE_DIR = Path(__file__).resolve().parent.parent.parent
CONFIG_PATH = BASE_DIR / "configuration.ini"
_config = configparser.ConfigParser()
_config.read(CONFIG_PATH)
def get(section: str, key: str, fallback=None):
try:
return _config.get(section, key)
except (configparser.NoSectionError, configparser.NoOptionError):
return fallback
def get_int(section: str, key: str, fallback=None):
try:
return _config.getint(section, key)
except (configparser.NoSectionError, configparser.NoOptionError, ValueError):
return fallback
def get_float(section: str, key: str, fallback=None):
try:
return _config.getfloat(section, key)
except (configparser.NoSectionError, configparser.NoOptionError, ValueError):
return fallback
def get_bool(section: str, key: str, fallback=None):
try:
return _config.getboolean(section, key)
except (configparser.NoSectionError, configparser.NoOptionError, ValueError):
return fallback
def sections():
return _config.sections()
def options(section: str):
try:
return _config.options(section)
except configparser.NoSectionError:
return []