From c6c7ed4dbe71ed59e67d2313b7c1bedbc92fb64c Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 26 Jan 2025 10:14:58 +0530 Subject: [PATCH] pep8 --- src/calibre/gui2/preferences/look_feel.py | 25 ++----------------- .../preferences/look_feel_tabs/__init__.py | 11 +++----- .../preferences/look_feel_tabs/cover_view.py | 2 +- .../preferences/look_feel_tabs/tb_display.py | 10 ++------ .../look_feel_tabs/tb_partitioning.py | 7 ++---- .../look_feel_tabs/tb_quickview.py | 5 ++-- 6 files changed, 13 insertions(+), 47 deletions(-) diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py index 264bebd0e0..c2709cb5a0 100644 --- a/src/calibre/gui2/preferences/look_feel.py +++ b/src/calibre/gui2/preferences/look_feel.py @@ -5,7 +5,6 @@ __license__ = 'GPL v3' __copyright__ = '2010, Kovid Goyal ' __docformat__ = 'restructuredtext en' -import json from collections import defaultdict from functools import partial from threading import Thread @@ -36,7 +35,6 @@ from qt.core import ( Qt, QTableWidget, QTableWidgetItem, - QTabWidget, QVBoxLayout, QWidget, pyqtSignal, @@ -46,32 +44,13 @@ from calibre import human_readable from calibre.constants import ismacos, iswindows from calibre.ebooks.metadata.book.render import DEFAULT_AUTHOR_LINK from calibre.ebooks.metadata.sources.prefs import msprefs -from calibre.gui2 import ( - choose_files, - choose_save_file, - config, - default_author_link, - error_dialog, - gprefs, - icon_resource_manager, - open_local_file, - qt_app, - question_dialog, -) - +from calibre.gui2 import config, default_author_link, error_dialog, gprefs, icon_resource_manager, open_local_file, qt_app, question_dialog from calibre.gui2.custom_column_widgets import get_field_list as em_get_field_list from calibre.gui2.dialogs.quickview import get_qv_field_list from calibre.gui2.library.alternate_views import CM_TO_INCH, auto_height from calibre.gui2.preferences import ConfigWidgetBase, Setting, set_help_tips, test_widget from calibre.gui2.preferences.coloring import EditRules -from calibre.gui2.preferences.look_feel_tabs import ( - DisplayedFields, - export_layout, - import_layout, - move_field_down, - move_field_up, - reset_layout, -) +from calibre.gui2.preferences.look_feel_tabs import DisplayedFields, export_layout, import_layout, move_field_down, move_field_up, reset_layout from calibre.gui2.preferences.look_feel_ui import Ui_Form from calibre.gui2.widgets import BusyCursor from calibre.gui2.widgets2 import Dialog diff --git a/src/calibre/gui2/preferences/look_feel_tabs/__init__.py b/src/calibre/gui2/preferences/look_feel_tabs/__init__.py index 4ad4a9560f..a50b12f6a7 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/__init__.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/__init__.py @@ -9,13 +9,7 @@ import json from qt.core import QAbstractListModel, QIcon, QItemSelectionModel, Qt -from calibre.gui2 import ( - choose_files, - choose_save_file, - config, - error_dialog, - gprefs, -) +from calibre.gui2 import choose_files, choose_save_file, error_dialog from calibre.gui2.book_details import get_field_list @@ -108,6 +102,7 @@ class DisplayedFields(QAbstractListModel): # {{{ self.changed = True return idx + def export_layout(in_widget, model=None): filename = choose_save_file(in_widget, 'look_feel_prefs_import_export_field_list', _('Save column list to file'), @@ -120,6 +115,7 @@ def export_layout(in_widget, model=None): error_dialog(in_widget, _('Export field layout'), _('

Could not write field list. Error:
%s')%err, show=True) + def import_layout(in_widget, model=None): filename = choose_files(in_widget, 'look_feel_prefs_import_export_field_list', _('Load column list from file'), @@ -134,6 +130,7 @@ def import_layout(in_widget, model=None): error_dialog(in_widget, _('Import layout'), _('

Could not read field list. Error:
%s')%err, show=True) + def reset_layout(in_widget, model=None): model.initialize(use_defaults=True) in_widget.changed_signal.emit() diff --git a/src/calibre/gui2/preferences/look_feel_tabs/cover_view.py b/src/calibre/gui2/preferences/look_feel_tabs/cover_view.py index 606e849bf1..5d946b87a0 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/cover_view.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/cover_view.py @@ -10,7 +10,7 @@ from qt.core import QKeySequence from calibre.gui2 import config, gprefs from calibre.gui2.dialogs.template_dialog import TemplateDialog -from calibre.gui2.preferences import LazyConfigWidgetBase, ConfigWidgetBase, set_help_tips +from calibre.gui2.preferences import ConfigWidgetBase, LazyConfigWidgetBase, set_help_tips from calibre.gui2.preferences.look_feel_tabs.cover_view_ui import Ui_Form diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_display.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_display.py index 70345d89d2..99646fce8d 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_display.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_display.py @@ -10,16 +10,10 @@ from functools import partial from calibre.db.categories import is_standard_category from calibre.gui2 import config, gprefs from calibre.gui2.preferences import ConfigWidgetBase, LazyConfigWidgetBase -from calibre.gui2.preferences.look_feel_tabs import ( - DisplayedFields, - import_layout, - export_layout, - move_field_down, - move_field_up, - reset_layout - ) +from calibre.gui2.preferences.look_feel_tabs import DisplayedFields, export_layout, import_layout, move_field_down, move_field_up, reset_layout from calibre.gui2.preferences.look_feel_tabs.tb_display_ui import Ui_Form + class TBDisplayedFields(DisplayedFields): # {{{ # The code in this class depends on the fact that the tag browser is # initialized before this class is instantiated. diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_partitioning.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_partitioning.py index 73a3691b3b..d09f36d8d2 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_partitioning.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_partitioning.py @@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en' from functools import partial -from calibre.gui2 import gprefs +from calibre.gui2 import gprefs from calibre.gui2.preferences import ConfigWidgetBase, LazyConfigWidgetBase from calibre.gui2.preferences.look_feel_tabs import DisplayedFields, export_layout, import_layout, reset_layout from calibre.gui2.preferences.look_feel_tabs.tb_partitioning_ui import Ui_Form @@ -44,7 +44,7 @@ class TBPartitionedFields(DisplayedFields): # {{{ ans = [[k, True] for k in cats.keys()] self.changed = True elif pref_data_override: - po = {k:v for k,v in pref_data_override} + po = dict(pref_data_override) ans = [[k, po.get(k, True)] for k in cats.keys()] self.changed = True else: @@ -93,6 +93,3 @@ class TbPartitioningTab(LazyConfigWidgetBase, Ui_Form): def commit(self): self.tb_categories_to_part_model.commit() return ConfigWidgetBase.commit(self) - - - diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_quickview.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_quickview.py index 17dc7f4f03..2a8af3ecd3 100644 --- a/src/calibre/gui2/preferences/look_feel_tabs/tb_quickview.py +++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_quickview.py @@ -10,10 +10,11 @@ from functools import partial from calibre.gui2 import gprefs from calibre.gui2.actions.show_quickview import get_quickview_action_plugin from calibre.gui2.dialogs.quickview import get_qv_field_list -from calibre.gui2.preferences import LazyConfigWidgetBase, ConfigWidgetBase +from calibre.gui2.preferences import ConfigWidgetBase, LazyConfigWidgetBase from calibre.gui2.preferences.look_feel_tabs import DisplayedFields, move_field_down, move_field_up from calibre.gui2.preferences.look_feel_tabs.tb_quickview_ui import Ui_Form + class QVDisplayedFields(DisplayedFields): # {{{ def __init__(self, db, parent=None): @@ -70,5 +71,3 @@ class QuickviewTab(LazyConfigWidgetBase, Ui_Form): rr = ConfigWidgetBase.commit(self, *args) self.qv_display_model.commit() return rr - -