tuxbot-bot/cogs/utils/config.py

24 lines
520 B
Python
Raw Normal View History

2019-12-16 18:12:10 +01:00
import configparser
class Config:
__slots__ = ('name', '_db')
def __init__(self, name):
self.name = name
2019-12-16 18:12:10 +01:00
self._db: configparser.ConfigParser = configparser.ConfigParser()
self._db.read(self.name)
def __contains__(self, item):
return item in self._db
def __getitem__(self, item):
return self._db[str(item)]
2019-12-16 18:12:10 +01:00
def all(self) -> list:
return self._db.sections()
2019-12-16 18:12:10 +01:00
def get(self, *args, **kwargs) -> str:
return self._db.get(*args, **kwargs)