mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
explicit f-string conversion (auto-fix)
ruff 'RUF010'
This commit is contained in:
parent
537ea5ef34
commit
5edc9b814c
@ -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}: {str(e)}')
|
self.log.error(f'Error processing {section_name}: {e!s}')
|
||||||
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}: {str(e)}')
|
self.log.error(f'Error getting H1 title for {article_url}: {e!s}')
|
||||||
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: {str(e)}")
|
print(f"Erreur lors de l'authentification: {e!s}")
|
||||||
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: {str(e)}')
|
print(f'Erreur preprocessing HTML: {e!s}')
|
||||||
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: {str(e)}')
|
print(f'Erreur processing image: {e!s}')
|
||||||
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: {str(e)}')
|
print(f'Erreur preprocessing HTML: {e!s}')
|
||||||
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}: {str(e)}')
|
print(f'Erreur sur {section_title}: {e!s}')
|
||||||
|
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ fragment ArticlePageFields on Article {
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
{lede_image_html}
|
{lede_image_html}
|
||||||
{str(body_soup)}
|
{body_soup!s}
|
||||||
{author_bios_html}
|
{author_bios_html}
|
||||||
</article>
|
</article>
|
||||||
</body></html>'''
|
</body></html>'''
|
||||||
|
@ -20,7 +20,7 @@ quote-style = 'single'
|
|||||||
ignore = [
|
ignore = [
|
||||||
'E402', 'E722', 'E741',
|
'E402', 'E722', 'E741',
|
||||||
'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420',
|
'UP012', 'UP030', 'UP032', 'UP038', 'C413', 'C420',
|
||||||
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF010', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF034', 'RUF100',
|
'RUF001', 'RUF002', 'RUF003', 'RUF005', 'RUF012', 'RUF013', 'RUF015', 'RUF031', 'RUF034', 'RUF100',
|
||||||
]
|
]
|
||||||
select = [
|
select = [
|
||||||
'E', 'F', 'I', 'W', 'INT',
|
'E', 'F', 'I', 'W', 'INT',
|
||||||
|
@ -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__}: {str(tag)}')
|
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}')
|
||||||
|
|
||||||
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__}: {str(tag)}')
|
raise LRFParseError(f'Unknown tag in {self.__class__.__name__}: {tag!s}')
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
yield from self._contents
|
yield from self._contents
|
||||||
|
@ -205,7 +205,7 @@ class Tag:
|
|||||||
s = 'Tag %04X ' % self.id
|
s = 'Tag %04X ' % self.id
|
||||||
if self.name:
|
if self.name:
|
||||||
s += self.name
|
s += self.name
|
||||||
s += f' at {self.offset:08X}, contents: {repr(self.contents)}'
|
s += f' at {self.offset:08X}, contents: {self.contents!r}'
|
||||||
return s
|
return s
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -168,7 +168,7 @@ class MetadataUpdater:
|
|||||||
def dump_metadata(self):
|
def dump_metadata(self):
|
||||||
''' Diagnostic '''
|
''' Diagnostic '''
|
||||||
for tag in self.metadata:
|
for tag in self.metadata:
|
||||||
print(f'{tag}: {repr(self.metadata[tag])}')
|
print(f'{tag}: {self.metadata[tag]!r}')
|
||||||
|
|
||||||
def encode_vwi(self,value):
|
def encode_vwi(self,value):
|
||||||
ans = []
|
ans = []
|
||||||
|
@ -745,7 +745,7 @@ def get_page_number_display_map(render_manager, opts, num_pages, log):
|
|||||||
if not isinstance(result, dict):
|
if not isinstance(result, dict):
|
||||||
raise ValueError('Not a dict')
|
raise ValueError('Not a dict')
|
||||||
except Exception:
|
except Exception:
|
||||||
log.warn(f'Could not do page number mapping, got unexpected result: {repr(result)}')
|
log.warn(f'Could not do page number mapping, got unexpected result: {result!r}')
|
||||||
else:
|
else:
|
||||||
default_map = {int(k): int(v) for k, v in iteritems(result)}
|
default_map = {int(k): int(v) for k, v in iteritems(result)}
|
||||||
return default_map
|
return default_map
|
||||||
|
@ -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"{str(msg)}Couldn't make directory '{self.__dir_name}':\n"
|
msg = f"{msg!s}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:
|
||||||
|
@ -552,7 +552,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
if False and self.DEBUG:
|
if False and self.DEBUG:
|
||||||
print('opts_dict')
|
print('opts_dict')
|
||||||
for opt in sorted(opts_dict.keys(), key=sort_key):
|
for opt in sorted(opts_dict.keys(), key=sort_key):
|
||||||
print(f' {opt}: {repr(opts_dict[opt])}')
|
print(f' {opt}: {opts_dict[opt]!r}')
|
||||||
return opts_dict
|
return opts_dict
|
||||||
|
|
||||||
def populate_combo_boxes(self):
|
def populate_combo_boxes(self):
|
||||||
|
@ -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} {str(x.text(0))}'
|
title = f'{check} {x.text(0)!s}'
|
||||||
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: {str(e)}')
|
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
|
||||||
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: {str(e)}')
|
prints(f'TemplateLineEditor: exception fetching metadata: {e!s}')
|
||||||
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}-{str(item.data(0, Qt.ItemDataRole.UserRole))}'
|
pl[lc] = f'{lc}-{item.data(0, Qt.ItemDataRole.UserRole)!s}'
|
||||||
dprefs['preferred_locales'] = pl
|
dprefs['preferred_locales'] = pl
|
||||||
|
|
||||||
def init_dictionary(self, item):
|
def init_dictionary(self, item):
|
||||||
|
@ -387,7 +387,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
'output_profile', 'prefix_rules', 'preset', 'read_book_marker',
|
'output_profile', 'prefix_rules', 'preset', 'read_book_marker',
|
||||||
'search_text', 'sort_by', 'sort_descriptions_by_author', 'sync',
|
'search_text', 'sort_by', 'sort_descriptions_by_author', 'sync',
|
||||||
'thumb_width', 'use_existing_cover', 'wishlist_tag']:
|
'thumb_width', 'use_existing_cover', 'wishlist_tag']:
|
||||||
build_log.append(f' {key}: {repr(opts_dict[key])}')
|
build_log.append(f' {key}: {opts_dict[key]!r}')
|
||||||
if opts.verbose:
|
if opts.verbose:
|
||||||
log('\n'.join(line for line in build_log))
|
log('\n'.join(line for line in build_log))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user