From: Sarah Hoffmann Date: Sun, 11 Jul 2021 22:16:25 +0000 (+0200) Subject: simplify if statements X-Git-Tag: v4.0.0~52^2~6 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/a08ef43e40fc940050cf962913677285b58493ef simplify if statements --- diff --git a/nominatim/db/async_connection.py b/nominatim/db/async_connection.py index db4b89ce..a55612c8 100644 --- a/nominatim/db/async_connection.py +++ b/nominatim/db/async_connection.py @@ -40,11 +40,10 @@ class DeadlockHandler: if exc_type == psycopg2.errors.DeadlockDetected: # pylint: disable=E1101 self.handler() return True - else: - if exc_type == psycopg2.extensions.TransactionRollbackError: - if exc_value.pgcode == '40P01': - self.handler() - return True + elif exc_type == psycopg2.extensions.TransactionRollbackError \ + and exc_value.pgcode == '40P01': + self.handler() + return True if self.ignore_sql_errors and isinstance(exc_value, psycopg2.Error): LOG.info("SQL error ignored: %s", exc_value) diff --git a/nominatim/tools/database_import.py b/nominatim/tools/database_import.py index efbf2ec8..df82f9aa 100644 --- a/nominatim/tools/database_import.py +++ b/nominatim/tools/database_import.py @@ -130,9 +130,8 @@ def import_osm_data(osm_file, options, drop=False, ignore_errors=False): if drop: conn.drop_table('planet_osm_nodes') - if drop: - if options['flatnode_file']: - Path(options['flatnode_file']).unlink() + if drop and options['flatnode_file']: + Path(options['flatnode_file']).unlink() def create_tables(conn, config, reverse_only=False):