mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
e4c79f81af
commit
1e5036ab73
@ -82,7 +82,8 @@ class FilenamePattern(QWidget, Ui_Form): # {{{
|
|||||||
val = prefs['filename_pattern']
|
val = prefs['filename_pattern']
|
||||||
self.re.lineEdit().setText(val)
|
self.re.lineEdit().setText(val)
|
||||||
|
|
||||||
val_hist += gprefs.get('filename_pattern_history', ['(?P<title>.+)', '(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ?'])
|
val_hist += gprefs.get('filename_pattern_history', [
|
||||||
|
'(?P<title>.+)', '(?P<author>[^_-]+) -?\s*(?P<series>[^_0-9-]*)(?P<series_index>[0-9]*)\s*-\s*(?P<title>[^_].+) ?'])
|
||||||
if val in val_hist:
|
if val in val_hist:
|
||||||
del val_hist[val_hist.index(val)]
|
del val_hist[val_hist.index(val)]
|
||||||
val_hist.insert(0, val)
|
val_hist.insert(0, val)
|
||||||
@ -136,7 +137,6 @@ class FilenamePattern(QWidget, Ui_Form): # {{{
|
|||||||
|
|
||||||
self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))
|
self.isbn.setText(_('No match') if mi.isbn is None else str(mi.isbn))
|
||||||
|
|
||||||
|
|
||||||
def pattern(self):
|
def pattern(self):
|
||||||
pat = unicode(self.re.lineEdit().text())
|
pat = unicode(self.re.lineEdit().text())
|
||||||
return re.compile(pat)
|
return re.compile(pat)
|
||||||
@ -186,7 +186,6 @@ class FormatList(QListWidget): # {{{
|
|||||||
if d.err is None:
|
if d.err is None:
|
||||||
self.formats_dropped.emit(event, [d.fpath])
|
self.formats_dropped.emit(event, [d.fpath])
|
||||||
|
|
||||||
|
|
||||||
def dragMoveEvent(self, event):
|
def dragMoveEvent(self, event):
|
||||||
event.acceptProposedAction()
|
event.acceptProposedAction()
|
||||||
|
|
||||||
@ -736,13 +735,11 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
|
|
||||||
CONSTANTS = ["False", "True", "None", "NotImplemented", "Ellipsis"]
|
CONSTANTS = ["False", "True", "None", "NotImplemented", "Ellipsis"]
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, parent=None):
|
def __init__(self, parent=None):
|
||||||
super(PythonHighlighter, self).__init__(parent)
|
super(PythonHighlighter, self).__init__(parent)
|
||||||
if not self.Config:
|
if not self.Config:
|
||||||
self.loadConfig()
|
self.loadConfig()
|
||||||
|
|
||||||
|
|
||||||
self.initializeFormats()
|
self.initializeFormats()
|
||||||
|
|
||||||
PythonHighlighter.Rules.append((QRegExp(
|
PythonHighlighter.Rules.append((QRegExp(
|
||||||
@ -752,7 +749,7 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
"|".join([r"\b%s\b" % builtin for builtin in self.BUILTINS])),
|
"|".join([r"\b%s\b" % builtin for builtin in self.BUILTINS])),
|
||||||
"builtin"))
|
"builtin"))
|
||||||
PythonHighlighter.Rules.append((QRegExp(
|
PythonHighlighter.Rules.append((QRegExp(
|
||||||
"|".join([r"\b%s\b" % constant \
|
"|".join([r"\b%s\b" % constant
|
||||||
for constant in self.CONSTANTS])), "constant"))
|
for constant in self.CONSTANTS])), "constant"))
|
||||||
PythonHighlighter.Rules.append((QRegExp(
|
PythonHighlighter.Rules.append((QRegExp(
|
||||||
r"\b[+-]?[0-9]+[lL]?\b"
|
r"\b[+-]?[0-9]+[lL]?\b"
|
||||||
@ -812,7 +809,6 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
Config["%sfontbold" % name] = QVariant(bold).toBool()
|
Config["%sfontbold" % name] = QVariant(bold).toBool()
|
||||||
Config["%sfontitalic" % name] = QVariant(italic).toBool()
|
Config["%sfontitalic" % name] = QVariant(italic).toBool()
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def initializeFormats(cls):
|
def initializeFormats(cls):
|
||||||
Config = cls.Config
|
Config = cls.Config
|
||||||
@ -829,7 +825,6 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
format.setFontItalic(Config["%sfontitalic" % name])
|
format.setFontItalic(Config["%sfontitalic" % name])
|
||||||
PythonHighlighter.Formats[name] = format
|
PythonHighlighter.Formats[name] = format
|
||||||
|
|
||||||
|
|
||||||
def highlightBlock(self, text):
|
def highlightBlock(self, text):
|
||||||
NORMAL, TRIPLESINGLE, TRIPLEDOUBLE, ERROR = range(4)
|
NORMAL, TRIPLESINGLE, TRIPLEDOUBLE, ERROR = range(4)
|
||||||
|
|
||||||
@ -900,7 +895,6 @@ class PythonHighlighter(QSyntaxHighlighter): # {{{
|
|||||||
self.setFormat(i, text.length(),
|
self.setFormat(i, text.length(),
|
||||||
PythonHighlighter.Formats["string"])
|
PythonHighlighter.Formats["string"])
|
||||||
|
|
||||||
|
|
||||||
def rehighlight(self):
|
def rehighlight(self):
|
||||||
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
|
||||||
QSyntaxHighlighter.rehighlight(self)
|
QSyntaxHighlighter.rehighlight(self)
|
||||||
@ -1045,11 +1039,13 @@ class Splitter(QSplitter):
|
|||||||
@dynamic_property
|
@dynamic_property
|
||||||
def side_index_size(self):
|
def side_index_size(self):
|
||||||
def fget(self):
|
def fget(self):
|
||||||
if self.count() < 2: return 0
|
if self.count() < 2:
|
||||||
|
return 0
|
||||||
return self.sizes()[self.side_index]
|
return self.sizes()[self.side_index]
|
||||||
|
|
||||||
def fset(self, val):
|
def fset(self, val):
|
||||||
if self.count() < 2: return
|
if self.count() < 2:
|
||||||
|
return
|
||||||
if val == 0 and not self.is_side_index_hidden:
|
if val == 0 and not self.is_side_index_hidden:
|
||||||
self.save_state()
|
self.save_state()
|
||||||
sizes = list(self.sizes())
|
sizes = list(self.sizes())
|
||||||
@ -1081,7 +1077,8 @@ class Splitter(QSplitter):
|
|||||||
self.resize_timer.start()
|
self.resize_timer.start()
|
||||||
|
|
||||||
def get_state(self):
|
def get_state(self):
|
||||||
if self.count() < 2: return (False, 200)
|
if self.count() < 2:
|
||||||
|
return (False, 200)
|
||||||
return (self.desired_show, self.desired_side_size)
|
return (self.desired_show, self.desired_side_size)
|
||||||
|
|
||||||
def apply_state(self, state, save_desired=True):
|
def apply_state(self, state, save_desired=True):
|
||||||
@ -1142,3 +1139,4 @@ class Splitter(QSplitter):
|
|||||||
|
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user