Reformat using black

This commit is contained in:
cuom1999 2022-05-14 12:57:27 -05:00
parent efee4ad081
commit a87fb49918
221 changed files with 19127 additions and 7310 deletions

View file

@ -5,19 +5,21 @@ from django.db import connection, transaction
class LockModel(object):
def __init__(self, write, read=()):
self.tables = ', '.join(chain(
('`%s` WRITE' % model._meta.db_table for model in write),
('`%s` READ' % model._meta.db_table for model in read),
))
self.tables = ", ".join(
chain(
("`%s` WRITE" % model._meta.db_table for model in write),
("`%s` READ" % model._meta.db_table for model in read),
)
)
self.cursor = connection.cursor()
def __enter__(self):
self.cursor.execute('LOCK TABLES ' + self.tables)
self.cursor.execute("LOCK TABLES " + self.tables)
def __exit__(self, exc_type, exc_val, exc_tb):
if exc_type is None:
transaction.commit()
else:
transaction.rollback()
self.cursor.execute('UNLOCK TABLES')
self.cursor.execute("UNLOCK TABLES")
self.cursor.close()