]> git.openstreetmap.org Git - nominatim.git/commitdiff
fix uses of config.get_path() to expect None
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 3 Jul 2022 16:36:33 +0000 (18:36 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 18 Jul 2022 07:47:57 +0000 (09:47 +0200)
nominatim/clicmd/args.py
nominatim/clicmd/freeze.py
nominatim/tools/freeze.py
nominatim/tools/refresh.py
test/python/tools/test_freeze.py

index d1f47ba00b4a41eb34aaa852d23cbbc5e9b4aca7..6a3c8387b0e671eaa134be61bb4c83e4d34daa47 100644 (file)
@@ -29,7 +29,7 @@ class NominatimArgs:
                     osm2pgsql_style=self.config.get_import_style_file(),
                     threads=self.threads or default_threads,
                     dsn=self.config.get_libpq_dsn(),
-                    flatnode_file=str(self.config.get_path('FLATNODE_FILE')),
+                    flatnode_file=str(self.config.get_path('FLATNODE_FILE') or ''),
                     tablespaces=dict(slim_data=self.config.TABLESPACE_OSM_DATA,
                                      slim_index=self.config.TABLESPACE_OSM_INDEX,
                                      main_data=self.config.TABLESPACE_PLACE_DATA,
index 85eb1b4a1730e9070956ee4d900aa91a9f3c4f8c..b11880ca74dcccb3ad659fbe5721eb2270253c1a 100644 (file)
@@ -37,6 +37,6 @@ class SetupFreeze:
 
         with connect(args.config.get_libpq_dsn()) as conn:
             freeze.drop_update_tables(conn)
-        freeze.drop_flatnode_file(str(args.config.get_path('FLATNODE_FILE')))
+        freeze.drop_flatnode_file(args.config.get_path('FLATNODE_FILE'))
 
         return 0
index e502c963de414a80c4f525d7c72e128ceaffd532..b0ebb2c08f8c872b4147a2b4eaecadccfd1df0bd 100644 (file)
@@ -42,10 +42,8 @@ def drop_update_tables(conn):
     conn.commit()
 
 
-def drop_flatnode_file(fname):
+def drop_flatnode_file(fpath):
     """ Remove the flatnode file if it exists.
     """
-    if fname:
-        fpath = Path(fname)
-        if fpath.exists():
-            fpath.unlink()
+    if fpath and fpath.exists():
+        fpath.unlink()
index 561bcf83ce4775f4fd19afa9761b368109f58476..257d587e117f41de52571958826e75ae3202ba28 100644 (file)
@@ -174,7 +174,7 @@ def _quote_php_variable(var_type, config, conf_name):
         return 'false'
 
     if var_type == Path:
-        value = str(config.get_path(conf_name))
+        value = str(config.get_path(conf_name) or '')
     else:
         value = getattr(config, conf_name)
 
index 30b673ffb7afe690ed7636fd0326551a7bfc6f7e..3ebb1730e46bd788e4c4cf24ada301bd94c0d6af 100644 (file)
@@ -39,17 +39,17 @@ def test_drop_tables(temp_db_conn, temp_db_cursor, table_factory):
         assert not temp_db_cursor.table_exists(table)
 
 def test_drop_flatnode_file_no_file():
-    freeze.drop_flatnode_file('')
+    freeze.drop_flatnode_file(None)
 
 
 def test_drop_flatnode_file_file_already_gone(tmp_path):
-    freeze.drop_flatnode_file(str(tmp_path / 'something.store'))
+    freeze.drop_flatnode_file(tmp_path / 'something.store')
 
 
 def test_drop_flatnode_file_delte(tmp_path):
     flatfile = tmp_path / 'flatnode.store'
     flatfile.write_text('Some content')
 
-    freeze.drop_flatnode_file(str(flatfile))
+    freeze.drop_flatnode_file(flatfile)
 
     assert not flatfile.exists()