mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-16 15:47:58 +00:00
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:
@@ -128,7 +128,7 @@ class SetupAll:
|
||||
drop=args.no_updates)
|
||||
LOG.warning('Create search index for default country names.')
|
||||
country_info.create_country_names(conn, tokenizer,
|
||||
args.config.LANGUAGES)
|
||||
args.config.get_str_list('LANGUAGES'))
|
||||
if args.no_updates:
|
||||
freeze.drop_update_tables(conn)
|
||||
tokenizer.finalize_import(args.config)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -131,9 +131,6 @@ def create_country_names(conn, tokenizer, languages=None):
|
||||
empty then only name translations for the given languages are added
|
||||
to the index.
|
||||
"""
|
||||
if languages:
|
||||
languages = languages.split(',')
|
||||
|
||||
def _include_key(key):
|
||||
return ':' not in key or not languages or \
|
||||
key[key.index(':') + 1:] in languages
|
||||
|
||||
Reference in New Issue
Block a user