2019-12-16 18:12:10 +01:00
|
|
|
import configparser
|
2019-09-09 22:40:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
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)
|
2019-09-09 22:40:17 +02:00
|
|
|
|
|
|
|
def __contains__(self, item):
|
|
|
|
return item in self._db
|
|
|
|
|
|
|
|
def __getitem__(self, item):
|
2019-12-16 21:41:10 +01:00
|
|
|
return self._db[item]
|
2019-09-09 22:40:17 +02:00
|
|
|
|
2019-12-16 18:12:10 +01:00
|
|
|
def all(self) -> list:
|
|
|
|
return self._db.sections()
|
2019-09-09 22:40:17 +02:00
|
|
|
|
2019-12-16 18:12:10 +01:00
|
|
|
def get(self, *args, **kwargs) -> str:
|
|
|
|
return self._db.get(*args, **kwargs)
|