misc cleanup

This commit is contained in:
Eli Schwartz 2019-09-01 23:12:54 -04:00 committed by Kovid Goyal
parent ac81ccedb3
commit 00559bef8f
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
6 changed files with 13 additions and 13 deletions

View File

@ -108,7 +108,7 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
fmts = config['internally_viewed_formats'] fmts = config['internally_viewed_formats']
viewer = self.opt_internally_viewed_formats viewer = self.opt_internally_viewed_formats
viewer.blockSignals(True) viewer.blockSignals(True)
exts = set([]) exts = set()
for ext in BOOK_EXTENSIONS: for ext in BOOK_EXTENSIONS:
ext = ext.lower() ext = ext.lower()
ext = re.sub(r'(x{0,1})htm(l{0,1})', 'html', ext) ext = re.sub(r'(x{0,1})htm(l{0,1})', 'html', ext)

View File

@ -9,7 +9,7 @@ import textwrap
from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting from calibre.gui2.preferences import ConfigWidgetBase, test_widget, Setting
from calibre.gui2.preferences.misc_ui import Ui_Form from calibre.gui2.preferences.misc_ui import Ui_Form
from calibre.gui2 import (config, open_local_file, gprefs) from calibre.gui2 import config, open_local_file, gprefs
from calibre import get_proxies from calibre import get_proxies
from polyglot.builtins import iteritems from polyglot.builtins import iteritems

View File

@ -64,7 +64,7 @@ class PluginModel(QAbstractItemModel, AdaptSQP): # {{{
plugins.sort(key=lambda x: x.name.lower()) plugins.sort(key=lambda x: x.name.lower())
def universal_set(self): def universal_set(self):
ans = set([]) ans = set()
for c, category in enumerate(self.categories): for c, category in enumerate(self.categories):
ans.add((c, -1)) ans.add((c, -1))
for p, plugin in enumerate(self._data[category]): for p, plugin in enumerate(self._data[category]):
@ -74,7 +74,7 @@ class PluginModel(QAbstractItemModel, AdaptSQP): # {{{
def get_matches(self, location, query, candidates=None): def get_matches(self, location, query, candidates=None):
if candidates is None: if candidates is None:
candidates = self.universal_set() candidates = self.universal_set()
ans = set([]) ans = set()
if not query: if not query:
return ans return ans
query = lower(query) query = lower(query)

View File

@ -22,13 +22,13 @@ def sort_key_for_action(ac):
q = ac.name if q is None else q[0] q = ac.name if q is None else q[0]
return primary_sort_key(force_unicode(q)) return primary_sort_key(force_unicode(q))
except Exception: except Exception:
return primary_sort_key(u'') return primary_sort_key('')
class FakeAction(object): class FakeAction(object):
def __init__(self, name, gui_name, icon, tooltip=None, def __init__(self, name, gui_name, icon, tooltip=None,
dont_add_to=frozenset([]), dont_remove_from=frozenset([])): dont_add_to=frozenset(), dont_remove_from=frozenset()):
self.name = name self.name = name
self.action_spec = (gui_name, icon, tooltip, None) self.action_spec = (gui_name, icon, tooltip, None)
self.dont_remove_from = dont_remove_from self.dont_remove_from = dont_remove_from
@ -131,7 +131,7 @@ class AllModel(BaseModel):
def remove(self, indices, allowed): def remove(self, indices, allowed):
rows = [i.row() for i in indices] rows = [i.row() for i in indices]
remove = set([]) remove = set()
for row in rows: for row in rows:
ac = self._data[row] ac = self._data[row]
if ac.name.startswith('---'): if ac.name.startswith('---'):
@ -181,7 +181,7 @@ class CurrentModel(BaseModel):
def add(self, names): def add(self, names):
actions = [] actions = []
reject = set([]) reject = set()
for name in names: for name in names:
ac = self.name_to_action(name, self.gui) ac = self.name_to_action(name, self.gui)
if self.key in ac.dont_add_to: if self.key in ac.dont_add_to:
@ -196,7 +196,7 @@ class CurrentModel(BaseModel):
def remove(self, indices): def remove(self, indices):
rows = [i.row() for i in indices] rows = [i.row() for i in indices]
remove, rejected = set([]), set([]) remove, rejected = set(), set()
for row in rows: for row in rows:
ac = self._data[row] ac = self._data[row]
if self.key in ac.dont_remove_from: if self.key in ac.dont_remove_from:

View File

@ -417,7 +417,7 @@ def get_devices():
def get_manufacturers(): def get_manufacturers():
mans = set([]) mans = set()
for x in get_devices(): for x in get_devices():
mans.add(x.manufacturer) mans.add(x.manufacturer)
if Device.manufacturer in mans: if Device.manufacturer in mans:

View File

@ -536,7 +536,7 @@ class CustomColumns(object):
if num is not None: if num is not None:
data = self.custom_column_num_map[num] data = self.custom_column_num_map[num]
if data['datatype'] == 'composite': if data['datatype'] == 'composite':
return set([]) return set()
if not data['editable']: if not data['editable']:
raise ValueError('Column %r is not editable'%data['label']) raise ValueError('Column %r is not editable'%data['label'])
table, lt = self.custom_table_names(data['num']) table, lt = self.custom_table_names(data['num'])
@ -549,7 +549,7 @@ class CustomColumns(object):
if extra is None: if extra is None:
extra = 1.0 extra = 1.0
books_to_refresh = set([]) books_to_refresh = set()
if data['normalized']: if data['normalized']:
if data['datatype'] == 'enumeration' and ( if data['datatype'] == 'enumeration' and (
val and val not in data['display']['enum_values']): val and val not in data['display']['enum_values']):
@ -563,7 +563,7 @@ class CustomColumns(object):
set_val = val if data['is_multiple'] else [val] set_val = val if data['is_multiple'] else [val]
existing = getter() existing = getter()
if not existing: if not existing:
existing = set([]) existing = set()
else: else:
existing = set(existing) existing = set(existing)
# preserve the order in set_val # preserve the order in set_val