simplify if statements

This commit is contained in:
Sarah Hoffmann
2021-07-12 00:16:25 +02:00
parent bc5e15996a
commit a08ef43e40
2 changed files with 6 additions and 8 deletions

View File

@@ -40,9 +40,8 @@ class DeadlockHandler:
if exc_type == psycopg2.errors.DeadlockDetected: # pylint: disable=E1101 if exc_type == psycopg2.errors.DeadlockDetected: # pylint: disable=E1101
self.handler() self.handler()
return True return True
else: elif exc_type == psycopg2.extensions.TransactionRollbackError \
if exc_type == psycopg2.extensions.TransactionRollbackError: and exc_value.pgcode == '40P01':
if exc_value.pgcode == '40P01':
self.handler() self.handler()
return True return True

View File

@@ -130,8 +130,7 @@ def import_osm_data(osm_file, options, drop=False, ignore_errors=False):
if drop: if drop:
conn.drop_table('planet_osm_nodes') conn.drop_table('planet_osm_nodes')
if drop: if drop and options['flatnode_file']:
if options['flatnode_file']:
Path(options['flatnode_file']).unlink() Path(options['flatnode_file']).unlink()