X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/efafa5271957fb54b356ec1c90e8613f14de40d4..6463839b4b5c3577dcce72795513c1a75444adb4:/nominatim/tools/freeze.py diff --git a/nominatim/tools/freeze.py b/nominatim/tools/freeze.py index e502c963..39c3279d 100644 --- a/nominatim/tools/freeze.py +++ b/nominatim/tools/freeze.py @@ -7,10 +7,13 @@ """ Functions for removing unnecessary data from the database. """ +from typing import Optional from pathlib import Path from psycopg2 import sql as pysql +from nominatim.db.connection import Connection + UPDATE_TABLES = [ 'address_levels', 'gb_postcode', @@ -25,7 +28,7 @@ UPDATE_TABLES = [ 'wikipedia_%' ] -def drop_update_tables(conn): +def drop_update_tables(conn: Connection) -> None: """ Drop all tables only necessary for updating the database from OSM replication data. """ @@ -42,10 +45,8 @@ def drop_update_tables(conn): conn.commit() -def drop_flatnode_file(fname): +def drop_flatnode_file(fpath: Optional[Path]) -> None: """ Remove the flatnode file if it exists. """ - if fname: - fpath = Path(fname) - if fpath.exists(): - fpath.unlink() + if fpath and fpath.exists(): + fpath.unlink()