mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
explicit f-string conversion (extra-edit)
This commit is contained in:
parent
5edc9b814c
commit
dcc86ee4ef
@ -92,7 +92,7 @@ class AlternativesEconomiques(BasicNewsRecipe):
|
|||||||
display_name = section_name.replace('-', ' ').title()
|
display_name = section_name.replace('-', ' ').title()
|
||||||
articles.append((display_name, feed_articles[:self.max_articles_per_feed]))
|
articles.append((display_name, feed_articles[:self.max_articles_per_feed]))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f'Error processing {section_name}: {e!s}')
|
self.log.error(f'Error processing {section_name}: {e}')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
return articles
|
return articles
|
||||||
@ -133,7 +133,7 @@ class AlternativesEconomiques(BasicNewsRecipe):
|
|||||||
'description': ''
|
'description': ''
|
||||||
})
|
})
|
||||||
except Exception as e:
|
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
|
continue
|
||||||
|
|
||||||
return feed_articles
|
return feed_articles
|
||||||
|
@ -125,7 +125,7 @@ class ArretSurImages(BasicNewsRecipe):
|
|||||||
else:
|
else:
|
||||||
print("Échec de l'authentification - Vérifiez vos identifiants")
|
print("Échec de l'authentification - Vérifiez vos identifiants")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Erreur lors de l'authentification: {e!s}")
|
print(f"Erreur lors de l'authentification: {e}")
|
||||||
return br
|
return br
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
@ -162,7 +162,7 @@ class ArretSurImages(BasicNewsRecipe):
|
|||||||
</html>
|
</html>
|
||||||
'''
|
'''
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Erreur preprocessing HTML: {e!s}')
|
print(f'Erreur preprocessing HTML: {e}')
|
||||||
return raw_html
|
return raw_html
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
@ -186,11 +186,11 @@ class ArretSurImages(BasicNewsRecipe):
|
|||||||
else:
|
else:
|
||||||
tag.replace_with(img_tag)
|
tag.replace_with(img_tag)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Erreur processing image: {e!s}')
|
print(f'Erreur processing image: {e}')
|
||||||
tag.decompose()
|
tag.decompose()
|
||||||
else:
|
else:
|
||||||
tag.decompose()
|
tag.decompose()
|
||||||
return soup
|
return soup
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Erreur preprocessing HTML: {e!s}')
|
print(f'Erreur preprocessing HTML: {e}')
|
||||||
return soup
|
return soup
|
||||||
|
@ -122,7 +122,7 @@ class LeCanardEnchaine(BasicNewsRecipe):
|
|||||||
print(f' {len(unique_articles)} articles trouvés')
|
print(f' {len(unique_articles)} articles trouvés')
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Erreur sur {section_title}: {e!s}')
|
print(f'Erreur sur {section_title}: {e}')
|
||||||
|
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
|
@ -75,12 +75,12 @@ class Pocket(BasicNewsRecipe):
|
|||||||
def get_auth_uri(self):
|
def get_auth_uri(self):
|
||||||
'''Quick function to return the authentication part of the url'''
|
'''Quick function to return the authentication part of the url'''
|
||||||
uri = ''
|
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:
|
if self.username is None or self.password is None:
|
||||||
self.user_error('Username or password is blank.')
|
self.user_error('Username or password is blank.')
|
||||||
else:
|
else:
|
||||||
uri = u'{0}&username={1!s}'.format(uri, self.username)
|
uri = u'{0}&username={1}'.format(uri, self.username)
|
||||||
uri = u'{0}&password={1!s}'.format(uri, self.password)
|
uri = u'{0}&password={1}'.format(uri, self.password)
|
||||||
return uri
|
return uri
|
||||||
|
|
||||||
def get_pull_articles_uri(self):
|
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}&state={1}'.format(uri, u'unread')
|
||||||
uri = u'{0}&contentType={1}'.format(uri, u'article')
|
uri = u'{0}&contentType={1}'.format(uri, u'article')
|
||||||
uri = u'{0}&sort={1}'.format(uri, self.sort_method)
|
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:
|
if self.only_pull_tag is not None:
|
||||||
uri = u'{0}&tag={1}'.format(uri, self.only_pull_tag)
|
uri = u'{0}&tag={1}'.format(uri, self.only_pull_tag)
|
||||||
return uri
|
return uri
|
||||||
|
@ -86,7 +86,7 @@ class LRFObject:
|
|||||||
if h[1] != '' and h[0] != '':
|
if h[1] != '' and h[0] != '':
|
||||||
setattr(self, h[0], val)
|
setattr(self, h[0], val)
|
||||||
else:
|
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):
|
def __iter__(self):
|
||||||
yield from range(0)
|
yield from range(0)
|
||||||
@ -129,7 +129,7 @@ class LRFContentObject(LRFObject):
|
|||||||
func, args = action[0], (action[1],)
|
func, args = action[0], (action[1],)
|
||||||
getattr(self, func)(tag, *args)
|
getattr(self, func)(tag, *args)
|
||||||
else:
|
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):
|
def __iter__(self):
|
||||||
yield from self._contents
|
yield from self._contents
|
||||||
|
@ -77,7 +77,7 @@ class Pict:
|
|||||||
try:
|
try:
|
||||||
os.mkdir(self.__dir_name)
|
os.mkdir(self.__dir_name)
|
||||||
except OSError as msg:
|
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
|
raise self.__bug_handler
|
||||||
else:
|
else:
|
||||||
if self.__run_level > 1:
|
if self.__run_level > 1:
|
||||||
|
@ -146,7 +146,7 @@ class DuplicatesQuestion(QDialog):
|
|||||||
for i in range(self.dup_list.topLevelItemCount()):
|
for i in range(self.dup_list.topLevelItemCount()):
|
||||||
x = self.dup_list.topLevelItem(i)
|
x = self.dup_list.topLevelItem(i)
|
||||||
check = '✓' if x.checkState(0) == Qt.CheckState.Checked else '✗'
|
check = '✓' if x.checkState(0) == Qt.CheckState.Checked else '✗'
|
||||||
title = f'{check} {x.text(0)!s}'
|
title = f'{check} {x.text(0)}'
|
||||||
dups = []
|
dups = []
|
||||||
for child in (x.child(j) for j in range(x.childCount())):
|
for child in (x.child(j) for j in range(x.childCount())):
|
||||||
dups.append('\t' + str(child.text(0)))
|
dups.append('\t' + str(child.text(0)))
|
||||||
|
@ -965,7 +965,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
break
|
break
|
||||||
mi.append(self.db.new_api.get_proxy_metadata(_id))
|
mi.append(self.db.new_api.get_proxy_metadata(_id))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
|
prints(f'TemplateLineEditor: exception fetching metadata: {e}')
|
||||||
mi = None
|
mi = None
|
||||||
t = TemplateDialog(self, self.s_r_template.text(), mi=mi)
|
t = TemplateDialog(self, self.s_r_template.text(), mi=mi)
|
||||||
t.setWindowTitle(_('Edit search/replace template'))
|
t.setWindowTitle(_('Edit search/replace template'))
|
||||||
|
@ -30,7 +30,7 @@ class TemplateLineEditor(QLineEdit):
|
|||||||
mi.append(db.new_api.get_metadata(_id))
|
mi.append(db.new_api.get_metadata(_id))
|
||||||
self.mi = mi
|
self.mi = mi
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
|
prints(f'TemplateLineEditor: exception fetching metadata: {e}')
|
||||||
self.mi = None
|
self.mi = None
|
||||||
self.setClearButtonEnabled(True)
|
self.setClearButtonEnabled(True)
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ class ManageDictionaries(Dialog): # {{{
|
|||||||
x.setData(0, Qt.ItemDataRole.FontRole, bf if x is item else None)
|
x.setData(0, Qt.ItemDataRole.FontRole, bf if x is item else None)
|
||||||
lc = str(item.parent().data(0, Qt.ItemDataRole.UserRole))
|
lc = str(item.parent().data(0, Qt.ItemDataRole.UserRole))
|
||||||
pl = dprefs['preferred_locales']
|
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
|
dprefs['preferred_locales'] = pl
|
||||||
|
|
||||||
def init_dictionary(self, item):
|
def init_dictionary(self, item):
|
||||||
|
@ -557,10 +557,10 @@ class CatalogBuilder:
|
|||||||
if self.opts.fmt == 'mobi':
|
if self.opts.fmt == 'mobi':
|
||||||
# Exit if building MOBI
|
# Exit if building MOBI
|
||||||
error_msg = _('<p>Inconsistent author sort values for author<br/>' +
|
error_msg = _('<p>Inconsistent author sort values for author<br/>' +
|
||||||
f"'{author[0]!s}':</p>" +
|
f"'{author[0]}':</p>" +
|
||||||
f'<p><center><b>{author[1]!s}</b> != <b>{current_author[1]!s}</b></center></p>' +
|
f'<p><center><b>{author[1]}</b> != <b>{current_author[1]}</b></center></p>' +
|
||||||
'<p>Unable to build MOBI catalog.<br/>' +
|
'<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('\n*** Metadata error ***')
|
||||||
self.opts.log.warn(error_msg)
|
self.opts.log.warn(error_msg)
|
||||||
@ -573,8 +573,8 @@ class CatalogBuilder:
|
|||||||
if not self.error:
|
if not self.error:
|
||||||
self.error.append('Author sort mismatch')
|
self.error.append('Author sort mismatch')
|
||||||
|
|
||||||
error_msg = _(f"Warning: Inconsistent author sort values for author '{author[0]!s}':\n" +
|
error_msg = _(f"Warning: Inconsistent author sort values for author '{author[0]}':\n" +
|
||||||
f' {author[1]!s} != {current_author[1]!s}\n')
|
f' {author[1]} != {current_author[1]}\n')
|
||||||
self.opts.log.warn('\n*** Metadata warning ***')
|
self.opts.log.warn('\n*** Metadata warning ***')
|
||||||
self.opts.log.warn(error_msg)
|
self.opts.log.warn(error_msg)
|
||||||
self.error.append(error_msg)
|
self.error.append(error_msg)
|
||||||
@ -793,7 +793,7 @@ class CatalogBuilder:
|
|||||||
if self.DEBUG and self.opts.verbose:
|
if self.DEBUG and self.opts.verbose:
|
||||||
tl = [i['title'] for i in books_by_author]
|
tl = [i['title'] for i in books_by_author]
|
||||||
lt = max(tl, key=len)
|
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'))
|
print(fs.format('', 'Title', 'Author', 'Series'))
|
||||||
for i in books_by_author:
|
for i in books_by_author:
|
||||||
print(fs.format('', i['title'], i['author_sort'], i['series']))
|
print(fs.format('', i['title'], i['author_sort'], i['series']))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user