diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 87996c8d..d56610b8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: exclude: ".*(galleria|photoswipe|jquery|leaflet).*$" - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.7.4 + rev: v0.8.3 hooks: - id: ruff args: [ --fix, --show-fixes, --exit-non-zero-on-fix ] diff --git a/src/sigal/gallery.py b/src/sigal/gallery.py index addddb2a..2ca97a45 100644 --- a/src/sigal/gallery.py +++ b/src/sigal/gallery.py @@ -781,7 +781,7 @@ def __init__(self, settings, ncpu=None, show_progress=False): with progressbar( albums.values(), - label="%16s" % "Sorting albums", + label="{:>16s}".format("Sorting albums"), file=self.progressbar_target, ) as progress_albums: for album in progress_albums: @@ -789,7 +789,7 @@ def __init__(self, settings, ncpu=None, show_progress=False): with progressbar( albums.values(), - label="%16s" % "Sorting media", + label="{:>16s}".format("Sorting medias"), file=self.progressbar_target, ) as progress_albums: for album in progress_albums: @@ -911,7 +911,7 @@ def log_func(x): ) with progressbar( self.albums.values(), - label="%16s" % "Writing files", + label="{:>16s}".format("Writing files"), item_show_func=log_func, show_eta=False, file=self.progressbar_target, diff --git a/src/sigal/plugins/encrypt/encrypt.py b/src/sigal/plugins/encrypt/encrypt.py index a3a5a9fb..393bc977 100644 --- a/src/sigal/plugins/encrypt/encrypt.py +++ b/src/sigal/plugins/encrypt/encrypt.py @@ -200,7 +200,7 @@ def encrypt_files(settings, config, cache, albums, progressbar_target): medias = list(chain.from_iterable(albums.values())) with progressbar( medias, - label="%16s" % "Encrypting files", + label="{:>16s}".format("Encrypting files"), file=progressbar_target, show_eta=True, ) as medias: diff --git a/src/sigal/plugins/encrypt/endec.py b/src/sigal/plugins/encrypt/endec.py index 157e3f60..661c13dc 100644 --- a/src/sigal/plugins/encrypt/endec.py +++ b/src/sigal/plugins/encrypt/endec.py @@ -66,7 +66,7 @@ def wrapper(args): def encrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes): if len(key) != 128 / 8: - raise ValueError("Unsupported key length: %d" % len(key)) + raise ValueError(f"Unsupported key length: {len(key)}") aesgcm = AESGCM(key) iv = os.urandom(12) plaintext = infile @@ -80,7 +80,7 @@ def encrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes): def decrypt(key: bytes, infile: BinaryIO, outfile: BinaryIO, tag: bytes): if len(key) != 128 / 8: - raise ValueError("Unsupported key length: %d" % len(key)) + raise ValueError(f"Unsupported key length: {len(key)}") aesgcm = AESGCM(key) ciphertext = infile plaintext = outfile diff --git a/src/sigal/video.py b/src/sigal/video.py index 593c20b0..d7e0eefb 100644 --- a/src/sigal/video.py +++ b/src/sigal/video.py @@ -98,10 +98,10 @@ def get_resize_options(source, converter, output_size): # + I made a drawing on paper to figure this out if h_dst * w_src < h_src * w_dst: # biggest fitting dimension is height - resize_opt = ["-vf", "scale=trunc(oh*a/2)*2:%i" % h_dst] + resize_opt = ["-vf", f"scale=trunc(oh*a/2)*2:{h_dst:d}"] else: # biggest fitting dimension is width - resize_opt = ["-vf", "scale=%i:trunc(ow/a/2)*2" % w_dst] + resize_opt = ["-vf", f"scale={w_dst:d}:trunc(ow/a/2)*2"] return resize_opt