X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/ed6fda696864be2b0970ec1eae327f48c00f7fd1..6dbec931f58c659075a903db1e8eab15b1c93b03:/nominatim/tools/country_info.py diff --git a/nominatim/tools/country_info.py b/nominatim/tools/country_info.py index ed04c2d5..d754b4dd 100644 --- a/nominatim/tools/country_info.py +++ b/nominatim/tools/country_info.py @@ -84,10 +84,20 @@ def setup_country_config(config): _COUNTRY_INFO.load(config) -def iterate(): +def iterate(prop=None): """ Iterate over country code and properties. + + When `prop` is None, all countries are returned with their complete + set of properties. + + If `prop` is given, then only countries are returned where the + given property is set. The second item of the tuple contains only + the content of the given property. """ - return _COUNTRY_INFO.items() + if prop is None: + return _COUNTRY_INFO.items() + + return ((c, p[prop]) for c, p in _COUNTRY_INFO.items() if prop in p) def setup_country_tables(dsn, sql_dir, ignore_partitions=False): @@ -131,9 +141,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