]> git.openstreetmap.org Git - nominatim.git/commitdiff
simplify if statements
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 11 Jul 2021 22:16:25 +0000 (00:16 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 12 Jul 2021 09:28:47 +0000 (11:28 +0200)
nominatim/db/async_connection.py
nominatim/tools/database_import.py

index db4b89ce2fa74b6a03763dccac1f00df5f8ef22e..a55612c82d2188b637f9cbed786945e8ea05410c 100644 (file)
@@ -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)
index efbf2ec80c0c771dbea2e71390c5ba184b782280..df82f9aaf4a6e042eae58e6dab378ed8cd422b3b 100644 (file)
@@ -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):