]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix merge issues
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 9 Jun 2024 14:22:53 +0000 (16:22 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 26 Jun 2024 09:52:47 +0000 (11:52 +0200)
src/nominatim_db/tools/exec_utils.py
test/python/cli/test_cmd_refresh.py
test/python/tools/test_refresh_wiki_data.py

index 5450c43bb36f66eda9fccb41d1dff8d272195e08..467347f87127f57089540216630c4f916c113e24 100644 (file)
@@ -30,13 +30,7 @@ def run_osm2pgsql(options: Mapping[str, Any]) -> None:
     """
     env = get_pg_env(options['dsn'])
 
     """
     env = get_pg_env(options['dsn'])
 
-    osm2pgsql_cmd = options['osm2pgsql']
-    if osm2pgsql_cmd is None:
-        osm2pgsql_cmd = shutil.which('osm2pgsql')
-        if osm2pgsql_cmd is None:
-            raise RuntimeError('osm2pgsql executable not found. Please install osm2pgsql first.')
-
-    cmd = [str(osm2pgsql_cmd),
+    cmd = [_find_osm2pgsql_cmd(options['osm2pgsql']),
            '--slim',
            '--log-progress', 'true',
            '--number-processes', '1' if options['append'] else str(options['threads']),
            '--slim',
            '--log-progress', 'true',
            '--number-processes', '1' if options['append'] else str(options['threads']),
@@ -82,3 +76,14 @@ def run_osm2pgsql(options: Mapping[str, Any]) -> None:
     subprocess.run(cmd, cwd=options.get('cwd', '.'),
                    input=options.get('import_data'),
                    env=env, check=True)
     subprocess.run(cmd, cwd=options.get('cwd', '.'),
                    input=options.get('import_data'),
                    env=env, check=True)
+
+
+def _find_osm2pgsql_cmd(cmdline: str) -> str:
+    if cmdline is not None:
+        return cmdline
+
+    in_path = shutil.which('osm2pgsql')
+    if in_path is None:
+        raise RuntimeError('osm2pgsql executable not found. Please install osm2pgsql first.')
+
+    return str(in_path)
index 01b1f6e0446b1940d8e31eb2f28096641ad2f107..3939681720c6142cf1fd17804a8b127da81d0727 100644 (file)
@@ -92,7 +92,7 @@ class TestRefresh:
                             lambda *args, **kwargs: calls.append('import') or 0)
         monkeypatch.setattr(nominatim_db.tools.refresh, 'recompute_importance',
                             lambda *args, **kwargs: calls.append('update'))
                             lambda *args, **kwargs: calls.append('import') or 0)
         monkeypatch.setattr(nominatim_db.tools.refresh, 'recompute_importance',
                             lambda *args, **kwargs: calls.append('update'))
-        func_mock = mock_func_factory(nominatim.tools.refresh, 'create_functions')
+        func_mock = mock_func_factory(nominatim_db.tools.refresh, 'create_functions')
 
         assert self.call_nominatim('refresh', '--importance', '--wiki-data') == 0
 
 
         assert self.call_nominatim('refresh', '--importance', '--wiki-data') == 0
 
index c10a775723534c9d4f1c7a435b4aa59f8d2f1330..997ba04dc43562938266a2b4809cb9647bda7b0c 100644 (file)
@@ -12,7 +12,7 @@ import csv
 
 import pytest
 
 
 import pytest
 
-from nominatim.tools.refresh import import_wikipedia_articles, recompute_importance, create_functions
+from nominatim_db.tools.refresh import import_wikipedia_articles, recompute_importance, create_functions
 
 @pytest.fixture
 def wiki_csv(tmp_path, sql_preprocessor):
 
 @pytest.fixture
 def wiki_csv(tmp_path, sql_preprocessor):