X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/14f777da18df25e43685a7b1cd7b4e972c9fca39..2dafc4cf4fc46ea4be293a458d565fbff645ac28:/nominatim/tools/freeze.py diff --git a/nominatim/tools/freeze.py b/nominatim/tools/freeze.py index a182fc8b..39c3279d 100644 --- a/nominatim/tools/freeze.py +++ b/nominatim/tools/freeze.py @@ -1,10 +1,19 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# This file is part of Nominatim. (https://nominatim.org) +# +# Copyright (C) 2022 by the Nominatim developer community. +# For a full list of authors see the git log. """ 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', @@ -19,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. """ @@ -36,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()