diff --git a/sigal/__init__.py b/sigal/__init__.py
index 0ef79fe..acad34a 100644
--- a/sigal/__init__.py
+++ b/sigal/__init__.py
@@ -174,7 +174,7 @@ def build(source, destination, debug, verbose, quiet, force, config, theme,
if not quiet:
stats_str = ''
- types = sorted(set(t.rsplit('_',1)[0] for t in stats))
+ types = sorted(set(t.rsplit('_', 1)[0] for t in stats))
for t in types[:-1]:
stats_str += '{} and '.format(format_stats(t))
stats_str += '{}'.format(format_stats(types[-1]))
diff --git a/sigal/image.py b/sigal/image.py
index 3e05334..55af92a 100644
--- a/sigal/image.py
+++ b/sigal/image.py
@@ -46,7 +46,7 @@ from pilkit.processors import Transpose
from pilkit.utils import save_image
from . import signals, utils
-from .settings import Status, get_thumb
+from .settings import Status
try:
# Pillow 7.2+
diff --git a/sigal/plugins/encrypt/__init__.py b/sigal/plugins/encrypt/__init__.py
index e530ef9..cb8cd07 100644
--- a/sigal/plugins/encrypt/__init__.py
+++ b/sigal/plugins/encrypt/__init__.py
@@ -39,4 +39,4 @@ Compatibility with other plugins:
"""
-from .encrypt import register
+from .encrypt import register # noqa
diff --git a/sigal/plugins/encrypt/endec.py b/sigal/plugins/encrypt/endec.py
index 086fda1..c199b36 100644
--- a/sigal/plugins/encrypt/endec.py
+++ b/sigal/plugins/encrypt/endec.py
@@ -35,6 +35,7 @@ from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
backend = default_backend()
MAGIC_STRING = b"_e_n_c_r_y_p_t_e_d_"
+
def kdf_gen_key(password: str, salt: str, iters: int) -> bytes:
password = password.encode("utf-8")
salt = salt.encode("utf-8")
@@ -48,6 +49,7 @@ def kdf_gen_key(password: str, salt: str, iters: int) -> bytes:
key = kdf.derive(password)
return key
+
def dispatchargs(decorated):
def wrapper(args):
if args.key is not None:
@@ -65,8 +67,9 @@ def dispatchargs(decorated):
return wrapper
+
def encrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes):
- if len(key) != 128/8:
+ if len(key) != 128 / 8:
raise ValueError("Unsupported key length: %d" % len(key))
aesgcm = AESGCM(key)
iv = os.urandom(12)
@@ -78,8 +81,9 @@ def encrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes):
ciphertext.write(iv)
ciphertext.write(encrypted)
+
def decrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes):
- if len(key) != 128/8:
+ if len(key) != 128 / 8:
raise ValueError("Unsupported key length: %d" % len(key))
aesgcm = AESGCM(key)
ciphertext = infile
@@ -95,6 +99,7 @@ def decrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes):
raise ValueError("Incorrect tag, iv, or corrupted ciphertext")
plaintext.write(decrypted)
+
if __name__ == "__main__":
import argparse as ap
parser = ap.ArgumentParser(description="Encrypt or decrypt using AES-128-GCM")
diff --git a/sigal/plugins/feeds.py b/sigal/plugins/feeds.py
index ec18fae..4ed6b0d 100644
--- a/sigal/plugins/feeds.py
+++ b/sigal/plugins/feeds.py
@@ -70,7 +70,7 @@ def generate_feed(gallery, medias, feed_type=None, feed_url='', nb_items=0):
# item.date.date(),
# urlparse(link).path.lstrip('/')),
description='
'.format(base_url, item.path,
- item.thumbnail),
+ item.thumbnail),
# categories=item.tags if hasattr(item, 'tags') else None,
author_name=getattr(item, 'author', ''),
pubdate=item.date or datetime.now(),
diff --git a/sigal/plugins/nomedia.py b/sigal/plugins/nomedia.py
index a7d3ac6..5017c0a 100644
--- a/sigal/plugins/nomedia.py
+++ b/sigal/plugins/nomedia.py
@@ -94,7 +94,7 @@ def filter_nomedia(album, settings=None):
_remove_albums_with_subdirs(album.gallery.albums, [album.path])
try:
os.rmdir(album.dst_path)
- except OSError as e:
+ except OSError:
# directory was created and populated with images in a
# previous run => keep it
pass
diff --git a/sigal/plugins/zip_gallery.py b/sigal/plugins/zip_gallery.py
index 2695db6..e6c9d0f 100644
--- a/sigal/plugins/zip_gallery.py
+++ b/sigal/plugins/zip_gallery.py
@@ -34,7 +34,7 @@ See :ref:`compatibility with the encrypt plugin `.
import logging
import os
import zipfile
-from os.path import isfile, join, splitext
+from os.path import isfile, join
from sigal import signals
from sigal.gallery import Album
@@ -42,11 +42,13 @@ from sigal.utils import cached_property
logger = logging.getLogger(__name__)
+
def _should_generate_album_zip(album):
"""Checks whether a `.nozip_gallery` file exists in the album folder"""
nozipgallerypath = os.path.join(album.src_path, ".nozip_gallery")
return not os.path.isfile(nozipgallerypath)
+
def _generate_album_zip(album):
"""Make a ZIP archive with all media files and return its path.
@@ -81,6 +83,7 @@ def _generate_album_zip(album):
return False
+
def generate_album_zip(album):
"""Checks for .nozip_gallery file in album folder.
If this file exists, no ZIP archive is generated.
@@ -98,9 +101,11 @@ def generate_album_zip(album):
return _generate_album_zip(album)
+
def nozip_gallery_file(album, settings=None):
"""Filesystem based switch to disable ZIP generation for an Album"""
Album.zip = cached_property(generate_album_zip)
+
def register(settings):
signals.album_initialized.connect(nozip_gallery_file)
diff --git a/sigal/video.py b/sigal/video.py
index ce5f007..071ed6a 100644
--- a/sigal/video.py
+++ b/sigal/video.py
@@ -28,7 +28,7 @@ import subprocess
from os.path import splitext
from . import image, utils
-from .settings import Status, get_thumb
+from .settings import Status
from .utils import is_valid_html5_video
@@ -77,6 +77,7 @@ def video_size(source, converter='ffmpeg'):
x, y = y, x
return x, y
+
def get_resize_options(source, converter, output_size):
"""Figure out resize options for video from src and dst sizes.
@@ -152,10 +153,10 @@ def generate_video(source, outname, settings):
base, dst_ext = splitext(outname)
if dst_ext == src_ext and not resize_opt and not video_always_convert:
- logger.debug('For %s, the source and destination extension are the " \
- "same, there is no resizing to be done, and " \
- "video_always_convert is False, so the output is " \
- " being copied', outname)
+ logger.debug('For %s, the source and destination extension are the '
+ 'same, there is no resizing to be done, and '
+ 'video_always_convert is False, so the output is '
+ ' being copied', outname)
shutil.copy(source, outname)
return
@@ -163,7 +164,7 @@ def generate_video(source, outname, settings):
if second_pass_options:
generate_video_pass(converter, source, final_pass_options)
final_second_pass_options = _get_empty_if_none_else_variable(
- second_pass_options) + resize_opt
+ second_pass_options) + resize_opt
generate_video_pass(converter, source,
final_second_pass_options, outname)
else:
diff --git a/tests/test_encrypt.py b/tests/test_encrypt.py
index 8a53e7b..049f87b 100644
--- a/tests/test_encrypt.py
+++ b/tests/test_encrypt.py
@@ -20,6 +20,7 @@ def get_key_tag(settings):
tag = options["gcm_tag"].encode("utf-8")
return (key, tag)
+
def test_encrypt(settings, tmpdir, disconnect_signals):
settings['destination'] = str(tmpdir)
if "sigal.plugins.encrypt" not in settings["plugins"]:
@@ -63,7 +64,7 @@ def test_encrypt(settings, tmpdir, disconnect_signals):
]
if settings["keep_orig"]:
encryptedImages.append(os.path.join(settings["destination"],
- media.path, media.big))
+ media.path, media.big))
# check if images are encrypted by trying to decrypt
for image in encryptedImages:
@@ -79,6 +80,6 @@ def test_encrypt(settings, tmpdir, disconnect_signals):
# check keycheck file
with open(os.path.join(settings["destination"],
- 'static', "keycheck.txt"), "rb") as infile:
+ 'static', "keycheck.txt"), "rb") as infile:
with BytesIO() as outfile:
endec.decrypt(key, infile, outfile, tag)
diff --git a/tests/test_video.py b/tests/test_video.py
index 85c8af9..55a39be 100644
--- a/tests/test_video.py
+++ b/tests/test_video.py
@@ -5,7 +5,7 @@ import pytest
from sigal.gallery import Video
from sigal.settings import Status, create_settings
from sigal.video import (generate_thumbnail, generate_video, process_video,
- video_size, get_resize_options, generate_video_pass)
+ video_size)
from unittest.mock import patch
CURRENT_DIR = os.path.dirname(__file__)
diff --git a/tests/test_zip.py b/tests/test_zip.py
index c409388..6909de9 100644
--- a/tests/test_zip.py
+++ b/tests/test_zip.py
@@ -1,4 +1,3 @@
-import glob
import os
import zipfile