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
style = self.__getattr__('IMPORT_STYLE')
if style in ('admin', 'street', 'address', 'full', 'extratags'):
- return self.config_dir / 'import-{}.style'.format(style)
+ return self.config_dir / f'import-{style}.style'
return self.find_config_file('', 'IMPORT_STYLE')
if configfile.suffix in ('.yaml', '.yml'):
result = self._load_from_yaml(configfile)
elif configfile.suffix == '.json':
- with configfile.open('r') as cfg:
+ with configfile.open('r', encoding='utf-8') as cfg:
result = json.load(cfg)
else:
raise UsageError(f"Config file '{configfile}' has unknown format.")