]> git.openstreetmap.org Git - nominatim.git/commitdiff
adding prefix to keys is now more configurable
authorTareq Al-Ahdal <tareqoalahdal@gmail.com>
Thu, 17 Mar 2022 22:20:00 +0000 (06:20 +0800)
committerTareq Al-Ahdal <tareqoalahdal@gmail.com>
Thu, 17 Mar 2022 22:20:00 +0000 (06:20 +0800)
nominatim/tools/country_info.py

index 675fac5d2018d74d48179700f927e3d4d2816061..2457e01b6b05178c7b7c41e55574953e8a4d9351 100644 (file)
@@ -66,8 +66,8 @@ def setup_country_tables(dsn, sql_dir, ignore_partitions=False):
     """
     db_utils.execute_file(dsn, sql_dir / 'country_osm_grid.sql.gz')
 
-    def prepend_name_to_keys(name):
-        return {'name:'+k: v for k, v in name.items()}
+    def add_prefix_to_keys(name, prefix):
+        return {prefix+k: v for k, v in name.items()}
 
     params, country_names_data = [], ''
     for ccode, props in _COUNTRY_INFO.items():
@@ -79,10 +79,9 @@ def setup_country_tables(dsn, sql_dir, ignore_partitions=False):
             lang = props['languages'][0] if len(props['languages']) == 1 else None
             params.append((ccode, partition, lang))
 
-            name = prepend_name_to_keys(props.get('names').get('name'))
+            name = add_prefix_to_keys(props.get('names').get('name'), 'name:')
             name = json.dumps(name , ensure_ascii=False, separators=(', ', '=>'))
             country_names_data += ccode + '\t' + name[1:-1] + '\n'
-
     with connect(dsn) as conn:
         with conn.cursor() as cur:
             cur.execute(