Some linting.

This commit is contained in:
voussoir 2021-08-20 22:32:19 -07:00
parent 5dae9ba178
commit e9d5711f29
No known key found for this signature in database
GPG key ID: 5F7554F8C26DACCB
12 changed files with 48 additions and 22 deletions

View file

@ -6,3 +6,14 @@ from . import objects
from . import photodb from . import photodb
from . import searchhelpers from . import searchhelpers
from . import tag_export from . import tag_export
__all__ = [
'constants',
'decorators',
'exceptions',
'helpers',
'objects',
'photodb',
'searchhelpers',
'tag_export',
]

View file

@ -7,7 +7,6 @@ import hashlib
import mimetypes import mimetypes
import os import os
import PIL.Image import PIL.Image
import re
import zipstream import zipstream
from voussoirkit import bytestring from voussoirkit import bytestring

View file

@ -357,8 +357,8 @@ class Album(ObjectBase, GroupableMixin):
@decorators.required_feature('album.edit') @decorators.required_feature('album.edit')
@decorators.transaction @decorators.transaction
def add_child(self, *args, **kwargs): def add_child(self, member):
return super().add_child(*args, **kwargs) return super().add_child(member)
@decorators.required_feature('album.edit') @decorators.required_feature('album.edit')
@decorators.transaction @decorators.transaction
@ -1308,7 +1308,11 @@ class Photo(ObjectBase):
new_path.assert_not_exists() new_path.assert_not_exists()
self.photodb.log.info('Renaming file "%s" -> "%s".', old_path.absolute_path, new_path.absolute_path) self.photodb.log.info(
'Renaming file "%s" -> "%s".',
old_path.absolute_path,
new_path.absolute_path,
)
new_path.parent.makedirs(exist_ok=True) new_path.parent.makedirs(exist_ok=True)
@ -1476,7 +1480,7 @@ class Tag(ObjectBase, GroupableMixin):
@decorators.required_feature('tag.edit') @decorators.required_feature('tag.edit')
@decorators.transaction @decorators.transaction
def add_child(self, member): def add_child(self, member):
ret = self.__add_child(member) ret = super().add_child(member)
if ret is BAIL: if ret is BAIL:
return BAIL return BAIL
@ -1486,10 +1490,8 @@ class Tag(ObjectBase, GroupableMixin):
@decorators.required_feature('tag.edit') @decorators.required_feature('tag.edit')
@decorators.transaction @decorators.transaction
def add_children(self, members): def add_children(self, members):
bail = True ret = super().add_children(members)
for member in members: if ret is BAIL:
bail = (self.__add_child(member) is BAIL) and bail
if bail:
return BAIL return BAIL
self.photodb.caches['tag_exports'].clear() self.photodb.caches['tag_exports'].clear()

View file

@ -964,8 +964,8 @@ class PDBPhotoMixin:
query = f'{"-" * 80}\n{query}\n{"-" * 80}' query = f'{"-" * 80}\n{query}\n{"-" * 80}'
self.log.debug('\n%s %s', query, bindings) self.log.debug('\n%s %s', query, bindings)
#explain = self.sql_execute('EXPLAIN QUERY PLAN ' + query, bindings) # explain = self.sql_execute('EXPLAIN QUERY PLAN ' + query, bindings)
#print('\n'.join(str(x) for x in explain.fetchall())) # print('\n'.join(str(x) for x in explain.fetchall()))
generator = self.sql_select(query, bindings) generator = self.sql_select(query, bindings)
seen_albums = set() seen_albums = set()
results_received = 0 results_received = 0

View file

@ -57,7 +57,8 @@ def flat_dict(tags, include_synonyms=True):
for equaling the main tag versus existing in the rest of the subtree. for equaling the main tag versus existing in the rest of the subtree.
''' '''
result = {} result = {}
def recur(tag):
def recurse(tag):
try: try:
return result[tag] return result[tag]
except KeyError: except KeyError:
@ -67,7 +68,7 @@ def flat_dict(tags, include_synonyms=True):
my_result.add(tag) my_result.add(tag)
for child in tag.get_children(): for child in tag.get_children():
my_result.update(recur(child)) my_result.update(recurse(child))
result[tag] = my_result result[tag] = my_result
@ -77,7 +78,7 @@ def flat_dict(tags, include_synonyms=True):
return my_result return my_result
for tag in tags: for tag in tags:
recur(tag) recurse(tag)
return result return result

View file

@ -246,7 +246,6 @@ def easybake_argparse(args):
photodb.commit() photodb.commit()
def export_symlinks_argparse(args): def export_symlinks_argparse(args):
photodb = find_photodb()
destination = pathclass.Path(args.destination) destination = pathclass.Path(args.destination)
destination.makedirs(exist_ok=True) destination.makedirs(exist_ok=True)
@ -594,12 +593,12 @@ digest:
flags: flags:
--exclude_directories A B C: --exclude_directories A B C:
Any directories matching any pattern of A, B, C... will be skipped. Any directories matching any pattern of A, B, C... will be skipped.
These patterns may be absolute paths like 'D:\temp', plain names like These patterns may be absolute paths like 'D:\\temp', plain names like
'thumbnails' or glob patterns like 'build_*'. 'thumbnails' or glob patterns like 'build_*'.
--exclude_filenames A B C: --exclude_filenames A B C:
Any filenames matching any pattern of A, B, C... will be skipped. Any filenames matching any pattern of A, B, C... will be skipped.
These patterns may be absolute paths like 'D:\somewhere\config.json', These patterns may be absolute paths like 'D:\\somewhere\\config.json',
plain names like 'thumbs.db' or glob patterns like '*.temp'. plain names like 'thumbs.db' or glob patterns like '*.temp'.
--glob_directories A B C: --glob_directories A B C:

View file

@ -4,3 +4,11 @@ from . import endpoints
from . import sessions from . import sessions
site = common.site site = common.site
__all__ = [
'common',
'decorators',
'endpoints',
'sessions',
'site',
]

View file

@ -3,8 +3,6 @@ import hashlib
from voussoirkit import cacheclass from voussoirkit import cacheclass
from voussoirkit import spinal from voussoirkit import spinal
import etiquette
class FileEtagManager: class FileEtagManager:
''' '''
The FileEtagManager serves ETag and Cache-Control headers for disk files to The FileEtagManager serves ETag and Cache-Control headers for disk files to

View file

@ -4,3 +4,12 @@ from . import bookmark_endpoints
from . import photo_endpoints from . import photo_endpoints
from . import tag_endpoints from . import tag_endpoints
from . import user_endpoints from . import user_endpoints
__all__ = [
'album_endpoints',
'basic_endpoints',
'bookmark_endpoints',
'photo_endpoints',
'tag_endpoints',
'user_endpoints',
]

View file

@ -1,6 +1,5 @@
import flask; from flask import request import flask; from flask import request
import os import os
import time
import urllib.parse import urllib.parse
from voussoirkit import flasktools from voussoirkit import flasktools

View file

@ -1,5 +1,4 @@
import flask; from flask import request import flask; from flask import request
import time
from voussoirkit import flasktools from voussoirkit import flasktools

View file

@ -188,7 +188,8 @@ def upgrade_6_to_7(photodb):
Most of the indices were renamed. Most of the indices were renamed.
''' '''
photodb.sql_execute('BEGIN') photodb.sql_execute('BEGIN')
indices = photodb.sql_select('SELECT name FROM sqlite_master WHERE type == "index" AND name NOT LIKE "sqlite_%"') query = 'SELECT name FROM sqlite_master WHERE type == "index" AND name NOT LIKE "sqlite_%"'
indices = photodb.sql_select(query)
indices = [name for (name,) in indices] indices = [name for (name,) in indices]
for index in indices: for index in indices:
photodb.sql_execute(f'DROP INDEX {index}') photodb.sql_execute(f'DROP INDEX {index}')