From 3bf2f8670232f50f6d7ff7a800be43ada45a406b Mon Sep 17 00:00:00 2001 From: jesopo Date: Sat, 7 Dec 2019 11:05:32 +0000 Subject: [PATCH] added get_list() and set_list() to src/Config.py --- src/Config.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Config.py b/src/Config.py index a65893c8..579b2dec 100644 --- a/src/Config.py +++ b/src/Config.py @@ -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]