added get_list() and set_list() to src/Config.py

This commit is contained in:
jesopo 2019-12-07 11:05:32 +00:00
parent e08bac9312
commit 3bf2f86702

View file

@ -37,3 +37,13 @@ class Config(object):
def get(self, key: str, default: typing.Any=None) -> typing.Any: def get(self, key: str, default: typing.Any=None) -> typing.Any:
return self._config.get(key, default) return self._config.get(key, default)
def get_list(self, key: str):
if key in self and self[key]:
return [item.strip() for item in self[key].split(",")]
return []
def set_list(self, key: str, list: typing.List[str]):
value = ",".join(item.strip() for item in list)
if value:
self[key] = value
elif key in self:
del self[key]