summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorWolfgang Müller2024-11-14 16:27:26 +0100
committerWolfgang Müller2024-11-14 16:51:56 +0100
commit34a759b8044123bbf5d0aa66dedd3b563fe3a014 (patch)
tree9c956df2a973fb738d36fee1b46e7813c7541440 /src
parent9e4f47b3dbc64d9328f3d7532ecfe0cd9432f21c (diff)
downloadhircine-34a759b8044123bbf5d0aa66dedd3b563fe3a014.tar.gz
backend/lint: Implement flake8-simplify suggestions
Diffstat (limited to '')
-rw-r--r--src/hircine/plugins/__init__.py2
-rw-r--r--src/hircine/plugins/scrapers/gallery_dl.py2
-rw-r--r--src/hircine/scanner.py27
-rw-r--r--src/hircine/scraper/utils.py5
4 files changed, 17 insertions, 19 deletions
diff --git a/src/hircine/plugins/__init__.py b/src/hircine/plugins/__init__.py
index 27e55a7..ea1a262 100644
--- a/src/hircine/plugins/__init__.py
+++ b/src/hircine/plugins/__init__.py
@@ -8,7 +8,7 @@ transformers = []
def get_scraper(name):
- return scraper_registry.get(name, None)
+ return scraper_registry.get(name)
def get_scrapers():
diff --git a/src/hircine/plugins/scrapers/gallery_dl.py b/src/hircine/plugins/scrapers/gallery_dl.py
index a6cebc4..17f85d0 100644
--- a/src/hircine/plugins/scrapers/gallery_dl.py
+++ b/src/hircine/plugins/scrapers/gallery_dl.py
@@ -36,7 +36,7 @@ class GalleryDLScraper(Scraper):
self.data = self.load()
category = self.data.get("category")
- if category in HANDLERS.keys():
+ if category in HANDLERS:
self.is_available = True
self.handler = HANDLERS.get(category)()
diff --git a/src/hircine/scanner.py b/src/hircine/scanner.py
index 162e1f0..d1077ed 100644
--- a/src/hircine/scanner.py
+++ b/src/hircine/scanner.py
@@ -302,19 +302,18 @@ class Scanner:
def process_member(self, input):
path, name = input
- with ZipFile(path, mode="r") as zip:
- with zip.open(name, mode="r") as member:
- _, ext = os.path.splitext(name)
- digest = file_digest(member, blake3).digest()
-
- if self.thumbnailer.can_process(ext):
- hash = digest.hex()
-
- width, height = self.thumbnailer.process(
- member, hash, reprocess=self.reprocess
- )
- return digest, Member(
- path=member.name, hash=hash, width=width, height=height
- )
+ with ZipFile(path, mode="r") as zip, zip.open(name, mode="r") as member:
+ _, ext = os.path.splitext(name)
+ digest = file_digest(member, blake3).digest()
+
+ if self.thumbnailer.can_process(ext):
+ hash = digest.hex()
+
+ width, height = self.thumbnailer.process(
+ member, hash, reprocess=self.reprocess
+ )
+ return digest, Member(
+ path=member.name, hash=hash, width=width, height=height
+ )
return digest, None
diff --git a/src/hircine/scraper/utils.py b/src/hircine/scraper/utils.py
index 1c1fbee..d3fa6d6 100644
--- a/src/hircine/scraper/utils.py
+++ b/src/hircine/scraper/utils.py
@@ -57,6 +57,5 @@ def open_archive_file(archive, member, check_sidecar=True): # pragma: no cover
return
- with ZipFile(archive.path, "r") as zip:
- with zip.open(member, "r") as file:
- yield file
+ with ZipFile(archive.path, "r") as zip, zip.open(member, "r") as file:
+ yield file