Implement Config.section() to fetch, validate config sections
This commit is contained in:
parent
7653ebdd29
commit
1e915b5007
2 changed files with 7 additions and 1 deletions
|
@ -61,6 +61,12 @@ class Config(configparser.ConfigParser):
|
||||||
|
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def section(self, section: str):
|
||||||
|
if not self.has_section(section):
|
||||||
|
raise ConfigSectionException(section)
|
||||||
|
|
||||||
|
return self[section]
|
||||||
|
|
||||||
def get(self, section: str, option: str, *args, **kwargs):
|
def get(self, section: str, option: str, *args, **kwargs):
|
||||||
if not self.has_section(section):
|
if not self.has_section(section):
|
||||||
raise ConfigSectionException(section)
|
raise ConfigSectionException(section)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Server():
|
||||||
self.newsgroups = dict()
|
self.newsgroups = dict()
|
||||||
self.sslctx = None
|
self.sslctx = None
|
||||||
|
|
||||||
if config['listen'].get('tls', 'no') == 'yes':
|
if config.section('listen').get('tls', 'no') == 'yes':
|
||||||
self.sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
self.sslctx = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
|
||||||
self.sslctx.load_cert_chain(config.get('tls', 'cert'),
|
self.sslctx.load_cert_chain(config.get('tls', 'cert'),
|
||||||
config.get('tls', 'key'))
|
config.get('tls', 'key'))
|
||||||
|
|
Loading…
Add table
Reference in a new issue