diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index f7b2ad7cfd..1d1f716d0f 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -2042,8 +2042,8 @@ class KOBOTOUCH(KOBO): int(row['FavouritesIndex']), row['Accessibility'], row['IsDownloaded'], row['___UserID'], bookshelves, book_stats={ - 'StorePages': row['StorePages'], - 'StoreWordCount': row['StoreWordCount'], + 'StorePages': row['StorePages'], + 'StoreWordCount': row['StoreWordCount'], 'StoreTimeToReadLowerEstimate': row['StoreTimeToReadLowerEstimate'], 'StoreTimeToReadUpperEstimate': row['StoreTimeToReadUpperEstimate'] } @@ -3223,14 +3223,15 @@ class KOBOTOUCH(KOBO): debug_print("KoboTouch:generate_update_from_template template error - template='%s'" % template) debug_print("KoboTouch:generate_update_from_template - new_value=", new_value) - debug_print(f"KoboTouch:generate_update_from_template - {book.title} - column_name='{column_name}', current_value='{current_value}', new_value='{new_value}'") - if (new_value is not None and \ - (current_value is None or new_value != current_value) ) or \ + debug_print( + f"KoboTouch:generate_update_from_template - {book.title} - column_name='{column_name}'," + f" current_value='{current_value}', new_value='{new_value}'") + if (new_value is not None and + (current_value is None or new_value != current_value)) or \ (new_value is None and current_value is not None): update_values.append(new_value) set_clause.append(column_name) - plugboard = None if self.plugboard_func and not series_only: if book.contentID.endswith('.kepub.epub') or not os.path.splitext(book.contentID)[1]: @@ -3368,34 +3369,34 @@ class KOBOTOUCH(KOBO): if self.update_bookstats: if self.bookstats_pagecount_template is not None: current_bookstats_pagecount = book.kobo_bookstats.get('StorePages', None) - generate_update_from_template(book, update_values, set_clause, - column_name='StorePages', - template=self.bookstats_pagecount_template, - new_value=book.bookstats_pagecount, - current_value=current_bookstats_pagecount + generate_update_from_template(book, update_values, set_clause, + column_name='StorePages', + template=self.bookstats_pagecount_template, + new_value=book.bookstats_pagecount, + current_value=current_bookstats_pagecount ) if self.bookstats_wordcount_template is not None: current_bookstats_wordcount = book.kobo_bookstats.get('StoreWordCount', None) - generate_update_from_template(book, update_values, set_clause, - column_name='StoreWordCount', - template=self.bookstats_wordcount_template, - new_value=book.bookstats_wordcount, - current_value=current_bookstats_wordcount + generate_update_from_template(book, update_values, set_clause, + column_name='StoreWordCount', + template=self.bookstats_wordcount_template, + new_value=book.bookstats_wordcount, + current_value=current_bookstats_wordcount ) if self.bookstats_timetoread_upper_template is not None: current_bookstats_timetoread_upper = book.kobo_bookstats.get('StoreTimeToReadUpperEstimate', None) - generate_update_from_template(book, update_values, set_clause, - column_name='StoreTimeToReadUpperEstimate', - template=self.bookstats_timetoread_upper_template, - new_value=book.bookstats_timetoread_upper, + generate_update_from_template(book, update_values, set_clause, + column_name='StoreTimeToReadUpperEstimate', + template=self.bookstats_timetoread_upper_template, + new_value=book.bookstats_timetoread_upper, current_value=current_bookstats_timetoread_upper ) if self.bookstats_timetoread_lower_template is not None: current_bookstats_timetoread_lower = book.kobo_bookstats.get('StoreTimeToReadLowerEstimate', None) - generate_update_from_template(book, update_values, set_clause, - column_name='StoreTimeToReadLowerEstimate', - template=self.bookstats_timetoread_lower_template, - new_value=book.bookstats_timetoread_lower, + generate_update_from_template(book, update_values, set_clause, + column_name='StoreTimeToReadLowerEstimate', + template=self.bookstats_timetoread_lower_template, + new_value=book.bookstats_timetoread_lower, current_value=current_bookstats_timetoread_lower ) @@ -3427,7 +3428,6 @@ class KOBOTOUCH(KOBO): if show_debug: debug_print("KoboTouch:set_core_metadata - end") - @classmethod def config_widget(cls): # TODO: Cleanup the following diff --git a/src/calibre/devices/kobo/kobotouch_config.py b/src/calibre/devices/kobo/kobotouch_config.py index c5d36a9a14..b803092cf8 100644 --- a/src/calibre/devices/kobo/kobotouch_config.py +++ b/src/calibre/devices/kobo/kobotouch_config.py @@ -693,15 +693,19 @@ class MetadataGroupBox(DeviceOptionsGroupBox): @property def update_bookstats(self): return self.update_bookstats_checkbox.isChecked() + @property def bookstats_pagecount_template(self): return self.bookstats_pagecount_template_edit.template + @property def bookstats_wordcount_template(self): return self.bookstats_wordcount_template_edit.template + @property def bookstats_timetoread_lower_template(self): return self.bookstats_timetoread_lower_template_edit.template + @property def bookstats_timetoread_upper_template(self): return self.bookstats_timetoread_upper_template_edit.template @@ -709,6 +713,7 @@ class MetadataGroupBox(DeviceOptionsGroupBox): from calibre.gui2.dialogs.template_line_editor import TemplateLineEditor + class TemplateConfig(QWidget): # {{{ def __init__(self, val, label=None, tooltip=None): diff --git a/src/calibre/ebooks/metadata/sources/google.py b/src/calibre/ebooks/metadata/sources/google.py index e2f0991e1a..2ed312dd76 100644 --- a/src/calibre/ebooks/metadata/sources/google.py +++ b/src/calibre/ebooks/metadata/sources/google.py @@ -201,7 +201,7 @@ class GoogleBooks(Source): # }}} def id_from_url(self, url): # {{{ - url_pattern = '(?:http|https)://books\.google\.com/books\?id=(?P.+)' + url_pattern = r'(?:http|https)://books\.google\.com/books\?id=(?P.+)' url_pattern = re.compile(url_pattern) id_ = url_pattern.search(url).group('id_') if id_: diff --git a/src/calibre/gui2/actions/mark_books.py b/src/calibre/gui2/actions/mark_books.py index 142f562a66..fc7de5f0d2 100644 --- a/src/calibre/gui2/actions/mark_books.py +++ b/src/calibre/gui2/actions/mark_books.py @@ -4,7 +4,6 @@ __license__ = 'GPL v3' __copyright__ = '2013, Kovid Goyal ' -from collections import defaultdict from functools import partial from qt.core import (QTimer, QApplication, Qt, QEvent, QDialog, QMenu, QIcon,