From 0b4a3a866166ebecbefcd5f82f1d7bf85c54f43f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 28 Jan 2025 23:52:11 +0530 Subject: [PATCH] .format() to f-string from previous PR --- src/calibre/ebooks/mobi/reader/markup.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/calibre/ebooks/mobi/reader/markup.py b/src/calibre/ebooks/mobi/reader/markup.py index 5152600cc328..32cac1ecb835 100644 --- a/src/calibre/ebooks/mobi/reader/markup.py +++ b/src/calibre/ebooks/mobi/reader/markup.py @@ -80,7 +80,7 @@ def remove_kindlegen_markup(parts, aid_anchor_suffix, linked_aids): aid = None replacement = '' if aid in linked_aids: - replacement = ' id="{}"'.format(aid + '-' + aid_anchor_suffix) + replacement = f' id="{aid + "-" + aid_anchor_suffix}"' tag = within_tag_aid_position_pattern.sub(replacement, tag, 1) srcpieces[j] = tag part = ''.join(srcpieces) @@ -150,7 +150,7 @@ def flow_as_unicode(flow): num = int(m.group(1), 32) href = resource_map[num-1] if href: - replacement = '"{}"'.format('../'+ href) + replacement = f'"{"../"+ href}"' tag = img_index_pattern.sub(replacement, tag, 1) else: log.warn(f'Referenced image {num} was not recognized ' @@ -168,7 +168,7 @@ def flow_as_unicode(flow): num = int(m.group(1), 32) href = resource_map[num-1] if href: - replacement = '"{}"'.format('../'+ href) + replacement = f'"{"../"+ href}"' tag = url_img_index_pattern.sub(replacement, tag, 1) else: log.warn(f'Referenced image {num} was not recognized as a ' @@ -182,9 +182,9 @@ def flow_as_unicode(flow): log.warn(f'Referenced font {num} was not recognized as a ' f'valid font in {tag}') else: - replacement = '"{}"'.format('../'+ href) + replacement = f'"{"../"+ href}"' if href.endswith('.failed'): - replacement = '"{}"'.format('failed-'+href) + replacement = f'"{"failed-"+href}"' tag = font_index_pattern.sub(replacement, tag, 1) # process links to other css pieces @@ -280,7 +280,7 @@ def insert_images_into_markup(parts, resource_map, log): except IndexError: href = '' if href: - replacement = '"{}"'.format('../' + href) + replacement = f'"{"../" + href}"' tag = img_index_pattern.sub(replacement, tag, 1) else: log.warn(f'Referenced image {num} was not recognized as '