Reformatted code base using black.
This commit is contained in:
parent
56319cbad3
commit
53fdaa9d09
1 changed files with 12604 additions and 8966 deletions
|
|
@ -124,7 +124,7 @@ class XEP_0264(object):
|
|||
|
||||
if thumbnails:
|
||||
# we want thumbnails ordered from smallest to biggest
|
||||
thumbnails.sort(key=lambda t: t.get('size', (0, 0)))
|
||||
thumbnails.sort(key=lambda t: t.get("size", (0, 0)))
|
||||
file_data.setdefault("extra", {})[C.KEY_THUMBNAILS] = thumbnails
|
||||
return True
|
||||
|
||||
|
|
@ -141,8 +141,8 @@ class XEP_0264(object):
|
|||
return hashlib.sha256(repr((image_uid, size)).encode()).hexdigest()
|
||||
|
||||
def _blocking_gen_thumb(
|
||||
self, source_path, size=None, max_age=None, image_uid=None,
|
||||
fix_orientation=True):
|
||||
self, source_path, size=None, max_age=None, image_uid=None, fix_orientation=True
|
||||
):
|
||||
"""Generate a thumbnail for image
|
||||
|
||||
This is a blocking method and must be executed in a thread
|
||||
|
|
@ -171,7 +171,8 @@ class XEP_0264(object):
|
|||
return img.size, uid
|
||||
|
||||
def generate_thumbnail(
|
||||
self, source_path, size=None, max_age=None, image_uid=None, fix_orientation=True):
|
||||
self, source_path, size=None, max_age=None, image_uid=None, fix_orientation=True
|
||||
):
|
||||
"""Generate a thumbnail of image
|
||||
|
||||
@param source_path(unicode): absolute path to source image
|
||||
|
|
@ -188,8 +189,12 @@ class XEP_0264(object):
|
|||
- unique Id of the thumbnail
|
||||
"""
|
||||
d = threads.deferToThread(
|
||||
self._blocking_gen_thumb, source_path, size, max_age, image_uid=image_uid,
|
||||
fix_orientation=fix_orientation
|
||||
self._blocking_gen_thumb,
|
||||
source_path,
|
||||
size,
|
||||
max_age,
|
||||
image_uid=image_uid,
|
||||
fix_orientation=fix_orientation,
|
||||
)
|
||||
d.addErrback(
|
||||
lambda failure_: log.error("thumbnail generation error: {}".format(failure_))
|
||||
|
|
|
|||
Loading…
Reference in a new issue