Skip to content

Commit

Permalink
.format() to f-string from previous PR
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 28, 2025
1 parent 9c5e88c commit 0b4a3a8
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/calibre/ebooks/mobi/reader/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 '
Expand All @@ -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 '
Expand All @@ -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
Expand Down Expand Up @@ -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 '
Expand Down

0 comments on commit 0b4a3a8

Please sign in to comment.