Some linting.

master
voussoir 2020-09-15 19:47:07 -07:00
parent 35b5b5cd21
commit c91888a738
5 changed files with 17 additions and 9 deletions

View File

@ -1,5 +1,4 @@
import bcrypt
import copy
import json
import logging
import os
@ -1029,6 +1028,7 @@ class PDBSQLMixin:
if bindings is None:
bindings = []
cur = self.sql.cursor()
# self.log.debug(f'{query} {bindings}')
cur.execute(query, bindings)
return cur

View File

@ -97,14 +97,14 @@ def minmax(key, value, minimums, maximums, warning_bag=None):
try:
(low, high) = helpers.hyphen_range(value)
except ValueError as e:
except ValueError as exc:
if warning_bag:
warning_bag.add(constants.WARNING_MINMAX_INVALID.format(field=key, value=value))
return
else:
raise
except exceptions.OutOfOrder as e:
except exceptions.OutOfOrder as exc:
if warning_bag:
warning_bag.add(e.error_message)
return

View File

@ -214,13 +214,15 @@ def post_batch_photos_searchhidden_core(photo_ids, searchhidden):
@site.route('/batch/photos/set_searchhidden', methods=['POST'])
@decorators.required_fields(['photo_ids'], forbid_whitespace=True)
def post_batch_photos_set_searchhidden():
response = post_batch_photos_searchhidden_core(photo_ids=request.form['photo_ids'], searchhidden=True)
photo_ids = request.form['photo_ids']
response = post_batch_photos_searchhidden_core(photo_ids=photo_ids, searchhidden=True)
return response
@site.route('/batch/photos/unset_searchhidden', methods=['POST'])
@decorators.required_fields(['photo_ids'], forbid_whitespace=True)
def post_batch_photos_unset_searchhidden():
response = post_batch_photos_searchhidden_core(photo_ids=request.form['photo_ids'], searchhidden=False)
photo_ids = request.form['photo_ids']
response = post_batch_photos_searchhidden_core(photo_ids=photo_ids, searchhidden=False)
return response
# Clipboard ########################################################################################

View File

@ -25,7 +25,7 @@ def register_all(site):
def bytestring(x):
try:
return voussoirkit.bytestring.bytestring(x)
except Exception as e:
except Exception as exc:
return '??? b'
@filter_function

View File

@ -29,7 +29,9 @@ def upgrade_2_to_3(photodb):
)
''')
photodb.sql_execute('CREATE INDEX IF NOT EXISTS index_user_id ON users(id)')
photodb.sql_execute('CREATE INDEX IF NOT EXISTS index_user_username ON users(username COLLATE NOCASE)')
photodb.sql_execute('''
CREATE INDEX IF NOT EXISTS index_user_username ON users(username COLLATE NOCASE)
''')
def upgrade_3_to_4(photodb):
'''
@ -171,7 +173,9 @@ def upgrade_9_to_10(photodb):
new_thumbnail_path = photo.make_thumbnail_filepath()
new_thumbnail_path = new_thumbnail_path.absolute_path
new_thumbnail_path = '.' + new_thumbnail_path.replace(thumbnail_dir, '')
photodb.sql_execute('UPDATE photos SET thumbnail = ? WHERE id == ?', [new_thumbnail_path, photo.id])
query = 'UPDATE photos SET thumbnail = ? WHERE id == ?'
bindings = [new_thumbnail_path, photo.id]
photodb.sql_execute(query, bindings)
def upgrade_10_to_11(photodb):
'''
@ -249,7 +253,9 @@ def upgrade_12_to_13(photodb):
display_name TEXT,
created INT
)''')
photodb.sql_execute('INSERT INTO users SELECT id, username, password, NULL, created FROM users_old')
photodb.sql_execute('''
INSERT INTO users SELECT id, username, password, NULL, created FROM users_old
''')
photodb.sql_execute('DROP TABLE users_old')
def upgrade_13_to_14(photodb):