Skip to content

Commit 2a18db4

Browse files
committed
Automatic fixes by ruff and black
1 parent 13f69d7 commit 2a18db4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+32
-75
lines changed

src/zimscraperlib/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "3.2.1-dev0"
1+
__version__ = "3.2.1-dev0"

src/zimscraperlib/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
import logging as stdlogging

src/zimscraperlib/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
import base64
65
import pathlib
76
import re
7+
88
from zimscraperlib.__about__ import __version__
99

1010
ROOT_DIR = pathlib.Path(__file__).parent

src/zimscraperlib/download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
from __future__ import annotations

src/zimscraperlib/filesystem.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
""" Files manipulation tools
@@ -41,7 +40,7 @@ def get_content_mimetype(content: bytes) -> str:
4140
def delete_callback(
4241
fpath: Union[str, pathlib.Path],
4342
callback: Optional[Callable] = None,
44-
*callback_args: Any
43+
*callback_args: Any,
4544
):
4645
"""helper deleting passed filepath, optionnaly calling an additional callback"""
4746

src/zimscraperlib/fix_ogvjs_dist.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54

@@ -19,7 +18,7 @@ def fix_source_dir(source_vendors_path: Union[pathlib.Path, str]):
1918
root = pathlib.Path(source_vendors_path)
2019
logger.info("fixing videosjs-ogvjs.js")
2120
plugin_path = root.joinpath("videojs-ogvjs.js")
22-
with open(plugin_path, "r") as fp:
21+
with open(plugin_path) as fp:
2322
content = fp.read()
2423

2524
content = content.replace(

src/zimscraperlib/html.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
""" Tools to work with HTML contents """
@@ -27,7 +26,7 @@ def find_title_in(content: Union[str, BinaryIO, TextIO], mime_type: str) -> str:
2726
def find_title_in_file(fpath: pathlib.Path, mime_type: str) -> str:
2827
"""Extracted title from an HTML file"""
2928
try:
30-
with open(fpath, "r") as fh:
29+
with open(fpath) as fh:
3130
return find_title_in(fh, mime_type)
3231
except Exception:
3332
return ""
@@ -60,7 +59,7 @@ def find_language_in(content: Union[str, BinaryIO, TextIO], mime_type: str) -> s
6059
def find_language_in_file(fpath: pathlib.Path, mime_type: str) -> str:
6160
"""Extracted language from an HTML file"""
6261
try:
63-
with open(fpath, "r") as fh:
62+
with open(fpath) as fh:
6463
return find_language_in(fh, mime_type)
6564
except Exception:
6665
return ""

src/zimscraperlib/i18n.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
import gettext

src/zimscraperlib/image/convertion.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54
import pathlib

src/zimscraperlib/image/optimization.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
# -*- coding: utf-8 -*-
32
# vim: ai ts=4 sts=4 et sw=4 nu
43

54

@@ -154,12 +153,12 @@ def optimize_jpeg(
154153

155154
if keep_exif and had_exif:
156155
piexif.transplant(
157-
exif_src=str(src.resolve())
158-
if isinstance(src, pathlib.Path)
159-
else src.getvalue(),
160-
image=str(dst.resolve())
161-
if isinstance(dst, pathlib.Path)
162-
else dst.getvalue(),
156+
exif_src=(
157+
str(src.resolve()) if isinstance(src, pathlib.Path) else src.getvalue()
158+
),
159+
image=(
160+
str(dst.resolve()) if isinstance(dst, pathlib.Path) else dst.getvalue()
161+
),
163162
new_file=dst,
164163
)
165164

@@ -251,7 +250,7 @@ def optimize_gif(
251250
args += ["--interlace"]
252251
args += [str(src)]
253252
with open(dst, "w") as out_file:
254-
gifsicle = subprocess.run(args, stdout=out_file)
253+
gifsicle = subprocess.run(args, stdout=out_file, check=False)
255254

256255
# remove dst if gifsicle failed and src is different from dst
257256
if gifsicle.returncode != 0 and src.resolve() != dst.resolve() and dst.exists():

0 commit comments

Comments
 (0)