added get_list() and set_list() to src/Config.py
This commit is contained in:
parent
e08bac9312
commit
3bf2f86702
1 changed files with 10 additions and 0 deletions
|
@ -37,3 +37,13 @@ class Config(object):
|
|||
def get(self, key: str, default: typing.Any=None) -> typing.Any:
|
||||
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]
|
||||
|
|
Loading…
Reference in a new issue