mailmonster/classes/config.py

33 lines
939 B
Python
Raw Permalink Normal View History

2022-02-07 13:54:57 +00:00
import configparser
import pathlib
class Config:
@classmethod
def fromFile(cls, path):
parser = configparser.ConfigParser()
parser.read(path)
return cls(parser)
def __init__(self, config):
self._config = config
def getTempDir(self):
return pathlib.Path(self._config["MONSTER"].get("TempDir", fallback="/tmp/MailMonster/"))
def getMailServer(self):
return self._config["MONSTER"].get("Server", fallback="localhost")
def getMailPort(self):
return int(self._config["MONSTER"].get("Port", fallback=0))
def getMailSSL(self):
return bool(int(self._config["MONSTER"].get("SSL", fallback=0)))
def getMailUsername(self):
return self._config["MONSTER"].get("Username")
def getMailPassword(self):
return self._config["MONSTER"].get("Password")
def getMailSender(self):
return self._config["MONSTER"].get("Sender")