diff --git a/linkcheck/__init__.py b/linkcheck/__init__.py
index 573d6bcf..b342f80a 100644
--- a/linkcheck/__init__.py
+++ b/linkcheck/__init__.py
@@ -74,7 +74,7 @@ def get_link_pat(arg, strict=False):
@rtype: dict
@raises: re.error on invalid regular expressions
"""
- log.debug(LOG_CHECK, "Link pattern %r strict=%s", arg, strict)
+ log.debug(LOG_CHECK, _("Link pattern %r strict=%s"), arg, strict)
if arg.startswith('!'):
pattern = arg[1:]
negate = True
@@ -84,7 +84,7 @@ def get_link_pat(arg, strict=False):
try:
regex = re.compile(pattern)
except re.error as msg:
- log.warn(LOG_CHECK, "invalid regular expression %r: %s" % (pattern, msg))
+ log.warn(LOG_CHECK, _("invalid regular expression %r: %s"), pattern, msg)
raise
return {
"pattern": regex,
diff --git a/linkcheck/better_exchook2.py b/linkcheck/better_exchook2.py
index cd5cc4f1..f4a5dee6 100644
--- a/linkcheck/better_exchook2.py
+++ b/linkcheck/better_exchook2.py
@@ -232,7 +232,7 @@ def better_exchook(etype, value, tb, out=sys.stdout):
if value is None or not valuestr:
line = "%s" % etype
else:
- line = "%s: %s" % (etype, valuestr)
+ line = f"{etype}: {valuestr}"
return line
if (isinstance(etype, BaseException) or
(hasattr(types, "InstanceType") and isinstance(etype, types.InstanceType)) or
diff --git a/linkcheck/bookmarks/chromium.py b/linkcheck/bookmarks/chromium.py
index 4a4bf026..7183b10e 100644
--- a/linkcheck/bookmarks/chromium.py
+++ b/linkcheck/bookmarks/chromium.py
@@ -22,15 +22,13 @@ def parse_bookmark_data(data):
Return iterator for bookmarks of the form (url, name).
Bookmarks are not sorted.
"""
- for url, name in parse_bookmark_json(json.loads(data)):
- yield url, name
+ yield from parse_bookmark_json(json.loads(data))
def parse_bookmark_json(data):
"""Parse complete JSON data for Chromium Bookmarks."""
for entry in data["roots"].values():
- for url, name in parse_bookmark_node(entry):
- yield url, name
+ yield from parse_bookmark_node(entry)
def parse_bookmark_node(node):
@@ -39,5 +37,4 @@ def parse_bookmark_node(node):
yield node["url"], node["name"]
elif node["type"] == "folder":
for child in node["children"]:
- for entry in parse_bookmark_node(child):
- yield entry
+ yield from parse_bookmark_node(child)
diff --git a/linkcheck/bookmarks/safari.py b/linkcheck/bookmarks/safari.py
index 6d593f39..9ea2e97b 100644
--- a/linkcheck/bookmarks/safari.py
+++ b/linkcheck/bookmarks/safari.py
@@ -48,8 +48,7 @@ def parse_plist(entry):
yield (url, title)
elif has_children(entry):
for child in entry[KEY_CHILDREN]:
- for item in parse_plist(child):
- yield item
+ yield from parse_plist(child)
def is_leaf(entry):
diff --git a/linkcheck/checker/__init__.py b/linkcheck/checker/__init__.py
index dd0a28f5..91fbb588 100644
--- a/linkcheck/checker/__init__.py
+++ b/linkcheck/checker/__init__.py
@@ -39,10 +39,10 @@ def guess_url(url):
return url
if url.lower().startswith("www."):
# syntactic sugar
- return "http://%s" % url
+ return f"http://{url}"
elif url.lower().startswith("ftp."):
# syntactic sugar
- return "ftp://%s" % url
+ return f"ftp://{url}"
return url
@@ -197,7 +197,7 @@ def get_index_html(urls):
except KeyError:
# Some unicode entries raise KeyError.
url = name
- lines.append('%s' % (url, name))
+ lines.append(f'{name}')
lines.extend(["