add get_str_list() for config

Converts a config value written as a comma-sparated list into
a Python list of strings.
This commit is contained in:
Sarah Hoffmann
2022-05-29 13:53:50 +02:00
parent b593fe9c3e
commit 61d813bfef
5 changed files with 30 additions and 5 deletions

View File

@@ -99,6 +99,17 @@ class Configuration:
raise UsageError("Configuration error.") from exp
def get_str_list(self, name):
""" Return the given configuration parameter as a list of strings.
The values are assumed to be given as a comma-sparated list and
will be stripped before returning them. On empty values None
is returned.
"""
raw = self.__getattr__(name)
return [v.strip() for v in raw.split(',')] if raw else None
def get_path(self, name):
""" Return the given configuration parameter as a Path.
If a relative path is configured, then the function converts this