monsterwell/classes/config.py
2023-01-09 17:41:18 +00:00

24 lines
589 B
Python

from configparser import ConfigParser
from .directory import Directory
from .server import Server
class Config:
def __init__(self):
self._parser = ConfigParser()
@classmethod
def from_file(cls, path):
o = cls()
o._parser.read(path)
return o
@property
def directories(self):
for section in self._parser.sections():
if section.startswith("Directory "):
yield Directory.from_config(self._parser[section])
@property
def server(self):
return Server.from_config(self._parser["Server"])