explicit f-string conversion (extra-edit)

This commit is contained in:
un-pogaz 2025-01-24 11:14:20 +01:00
parent 5edc9b814c
commit dcc86ee4ef
11 changed files with 24 additions and 24 deletions

View File

@ -92,7 +92,7 @@ class AlternativesEconomiques(BasicNewsRecipe):
display_name = section_name.replace('-', ' ').title()
articles.append((display_name, feed_articles[:self.max_articles_per_feed]))
except Exception as e:
self.log.error(f'Error processing {section_name}: {e!s}')
self.log.error(f'Error processing {section_name}: {e}')
continue
return articles
@ -133,7 +133,7 @@ class AlternativesEconomiques(BasicNewsRecipe):
'description': ''
})
except Exception as e:
self.log.error(f'Error getting H1 title for {article_url}: {e!s}')
self.log.error(f'Error getting H1 title for {article_url}: {e}')
continue
return feed_articles

View File

@ -125,7 +125,7 @@ class ArretSurImages(BasicNewsRecipe):
else:
print("Échec de l'authentification - Vérifiez vos identifiants")
except Exception as e:
print(f"Erreur lors de l'authentification: {e!s}")
print(f"Erreur lors de l'authentification: {e}")
return br
def get_article_url(self, article):
@ -162,7 +162,7 @@ class ArretSurImages(BasicNewsRecipe):
</html>
'''
except Exception as e:
print(f'Erreur preprocessing HTML: {e!s}')
print(f'Erreur preprocessing HTML: {e}')
return raw_html
def preprocess_html(self, soup):
@ -186,11 +186,11 @@ class ArretSurImages(BasicNewsRecipe):
else:
tag.replace_with(img_tag)
except Exception as e:
print(f'Erreur processing image: {e!s}')
print(f'Erreur processing image: {e}')
tag.decompose()
else:
tag.decompose()
return soup
except Exception as e:
print(f'Erreur preprocessing HTML: {e!s}')
print(f'Erreur preprocessing HTML: {e}')
return soup

View File

@ -122,7 +122,7 @@ class LeCanardEnchaine(BasicNewsRecipe):
print(f' {len(unique_articles)} articles trouvés')
except Exception as e:
print(f'Erreur sur {section_title}: {e!s}')
print(f'Erreur sur {section_title}: {e}')
return feeds

View File

@ -75,12 +75,12 @@ class Pocket(BasicNewsRecipe):
def get_auth_uri(self):
'''Quick function to return the authentication part of the url'''
uri = ''
uri = u'{0}&apikey={1!s}'.format(uri, self.apikey)
uri = u'{0}&apikey={1}'.format(uri, self.apikey)
if self.username is None or self.password is None:
self.user_error('Username or password is blank.')
else:
uri = u'{0}&username={1!s}'.format(uri, self.username)
uri = u'{0}&password={1!s}'.format(uri, self.password)
uri = u'{0}&username={1}'.format(uri, self.username)
uri = u'{0}&password={1}'.format(uri, self.password)
return uri
def get_pull_articles_uri(self):
@ -88,7 +88,7 @@ class Pocket(BasicNewsRecipe):
uri = u'{0}&state={1}'.format(uri, u'unread')
uri = u'{0}&contentType={1}'.format(uri, u'article')
uri = u'{0}&sort={1}'.format(uri, self.sort_method)
uri = u'{0}&count={1!s}'.format(uri, self.max_articles_per_feed)
uri = u'{0}&count={1}'.format(uri, self.max_articles_per_feed)
if self.only_pull_tag is not None:
uri = u'{0}&tag={1}'.format(uri, self.only_pull_tag)
return uri

View File

@ -86,7 +86,7 @@ class LRFObject:
if h[1] != '' and h[0] != '':
setattr(self, h[0], val)
else:
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}')
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag}')
def __iter__(self):
yield from range(0)
@ -129,7 +129,7 @@ class LRFContentObject(LRFObject):
func, args = action[0], (action[1],)
getattr(self, func)(tag, *args)
else:
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}')
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag}')
def __iter__(self):
yield from self._contents

View File

@ -77,7 +77,7 @@ class Pict:
try:
os.mkdir(self.__dir_name)
except OSError as msg:
msg = f"{msg!s}Couldn't make directory '{self.__dir_name}':\n"
msg = f"{msg}Couldn't make directory '{self.__dir_name}':\n"
raise self.__bug_handler
else:
if self.__run_level > 1:

View File

@ -146,7 +146,7 @@ class DuplicatesQuestion(QDialog):
for i in range(self.dup_list.topLevelItemCount()):
x = self.dup_list.topLevelItem(i)
check = '' if x.checkState(0) == Qt.CheckState.Checked else ''
title = f'{check} {x.text(0)!s}'
title = f'{check} {x.text(0)}'
dups = []
for child in (x.child(j) for j in range(x.childCount())):
dups.append('\t' + str(child.text(0)))

View File

@ -965,7 +965,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
break
mi.append(self.db.new_api.get_proxy_metadata(_id))
except Exception as e:
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
prints(f'TemplateLineEditor: exception fetching metadata: {e}')
mi = None
t = TemplateDialog(self, self.s_r_template.text(), mi=mi)
t.setWindowTitle(_('Edit search/replace template'))

View File

@ -30,7 +30,7 @@ class TemplateLineEditor(QLineEdit):
mi.append(db.new_api.get_metadata(_id))
self.mi = mi
except Exception as e:
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
prints(f'TemplateLineEditor: exception fetching metadata: {e}')
self.mi = None
self.setClearButtonEnabled(True)

View File

@ -682,7 +682,7 @@ class ManageDictionaries(Dialog): # {{{
x.setData(0, Qt.ItemDataRole.FontRole, bf if x is item else None)
lc = str(item.parent().data(0, Qt.ItemDataRole.UserRole))
pl = dprefs['preferred_locales']
pl[lc] = f'{lc}-{item.data(0, Qt.ItemDataRole.UserRole)!s}'
pl[lc] = f'{lc}-{item.data(0, Qt.ItemDataRole.UserRole)}'
dprefs['preferred_locales'] = pl
def init_dictionary(self, item):

View File

@ -557,10 +557,10 @@ class CatalogBuilder:
if self.opts.fmt == 'mobi':
# Exit if building MOBI
error_msg = _('<p>Inconsistent author sort values for author<br/>' +
f"'{author[0]!s}':</p>" +
f'<p><center><b>{author[1]!s}</b> != <b>{current_author[1]!s}</b></center></p>' +
f"'{author[0]}':</p>" +
f'<p><center><b>{author[1]}</b> != <b>{current_author[1]}</b></center></p>' +
'<p>Unable to build MOBI catalog.<br/>' +
f"Select all books by '{author[0]!s}', apply correct Author Sort value in Edit Metadata dialog, then rebuild the catalog.\n<p>") # noqa: E501
f"Select all books by '{author[0]}', apply correct Author Sort value in Edit Metadata dialog, then rebuild the catalog.\n<p>") # noqa: E501
self.opts.log.warn('\n*** Metadata error ***')
self.opts.log.warn(error_msg)
@ -573,8 +573,8 @@ class CatalogBuilder:
if not self.error:
self.error.append('Author sort mismatch')
error_msg = _(f"Warning: Inconsistent author sort values for author '{author[0]!s}':\n" +
f' {author[1]!s} != {current_author[1]!s}\n')
error_msg = _(f"Warning: Inconsistent author sort values for author '{author[0]}':\n" +
f' {author[1]} != {current_author[1]}\n')
self.opts.log.warn('\n*** Metadata warning ***')
self.opts.log.warn(error_msg)
self.error.append(error_msg)
@ -793,7 +793,7 @@ class CatalogBuilder:
if self.DEBUG and self.opts.verbose:
tl = [i['title'] for i in books_by_author]
lt = max(tl, key=len)
fs = '{:<6}{:<%d} {:<%d} {!s}' % (len(lt), len(las))
fs = '{:<6}{:<%d} {:<%d} {}' % (len(lt), len(las))
print(fs.format('', 'Title', 'Author', 'Series'))
for i in books_by_author:
print(fs.format('', i['title'], i['author_sort'], i['series']))