replace 2-element f-strings with simple '+' concatenations

Python's 'ast' module and its 'NodeVisitor' class
were incredibly helpful in identifying these
This commit is contained in:
Mike Fährmann
2025-12-21 15:09:03 +01:00
parent d0f06be0d2
commit 00c6821a3f
74 changed files with 229 additions and 237 deletions

View File

@@ -24,7 +24,7 @@ class BellazonExtractor(Extractor):
archive_fmt = "{post[id]}/{id}_{filename}"
def items(self):
native = (f"{self.root}/", f"{self.root[6:]}/")
native = (self.root + "/", self.root[6:] + "/")
extract_urls = text.re(
r'(?s)<('
r'(?:video .*?<source [^>]*?src|a [^>]*?href)="([^"]+).*?</a>'
@@ -82,7 +82,7 @@ class BellazonExtractor(Extractor):
dc["extension"] = text.ext_from_url(url)
if url[0] == "/":
url = f"https:{url}"
url = "https:" + url
yield Message.Url, url, dc
else:
@@ -91,10 +91,10 @@ class BellazonExtractor(Extractor):
yield Message.Queue, url, data
def _pagination(self, base, pnum=None):
base = f"{self.root}{base}"
base = self.root + base
if pnum is None:
url = f"{base}/"
url = base + "/"
pnum = 1
else:
url = f"{base}/page/{pnum}/"
@@ -112,7 +112,7 @@ class BellazonExtractor(Extractor):
url = f"{base}/page/{pnum}/"
def _pagination_reverse(self, base, pnum=None):
base = f"{self.root}{base}"
base = self.root + base
url = f"{base}/page/{'9999' if pnum is None else pnum}/"
with self.request(url) as response:
@@ -127,7 +127,7 @@ class BellazonExtractor(Extractor):
if pnum > 1:
url = f"{base}/page/{pnum}/"
elif pnum == 1:
url = f"{base}/"
url = base + "/"
else:
return
@@ -198,9 +198,9 @@ class BellazonPostExtractor(BellazonExtractor):
def posts(self):
path, post_id = self.groups
page = self.request(f"{self.root}{path}").text
page = self.request(self.root + path).text
pos = page.find(f'id="elComment_{post_id}')
pos = page.find('id="elComment_' + post_id)
if pos < 0:
raise exception.NotFoundError("post")
html = text.extract(page, "<article ", "</article>", pos-100)[0]