mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
3cec1c5f30
commit
30ee950706
@ -4,6 +4,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
'''Dialog to edit metadata in bulk'''
|
||||
|
||||
import re, os, inspect
|
||||
from collections import namedtuple
|
||||
|
||||
from PyQt4.Qt import Qt, QDialog, QGridLayout, QVBoxLayout, QFont, QLabel, \
|
||||
pyqtSignal, QDialogButtonBox, QInputDialog, QLineEdit, \
|
||||
@ -53,6 +54,10 @@ def get_cover_data(stream, ext): # {{{
|
||||
return cdata, area
|
||||
# }}}
|
||||
|
||||
Settings = namedtuple('Settings', 'remove_all remove add au aus do_aus rating pub do_series do_autonumber do_remove_format '
|
||||
'remove_format do_swap_ta do_remove_conv do_auto_author series do_series_restart series_start_value '
|
||||
'do_title_case cover_action clear_series pubdate adddate do_title_sort languages clear_languages restore_original')
|
||||
|
||||
class MyBlockingBusy(QDialog): # {{{
|
||||
|
||||
do_one_signal = pyqtSignal()
|
||||
@ -72,7 +77,7 @@ class MyBlockingBusy(QDialog): # {{{
|
||||
self.setLayout(self._layout)
|
||||
self.msg_text = msg
|
||||
self.msg = QLabel(msg+' ') # Ensure dialog is wide enough
|
||||
#self.msg.setWordWrap(True)
|
||||
# self.msg.setWordWrap(True)
|
||||
self.font = QFont()
|
||||
self.font.setPointSize(self.font.pointSize() + 8)
|
||||
self.msg.setFont(self.font)
|
||||
@ -140,7 +145,6 @@ class MyBlockingBusy(QDialog): # {{{
|
||||
pubdate, adddate, do_title_sort, languages, clear_languages, \
|
||||
restore_original = self.args
|
||||
|
||||
|
||||
# first loop: All changes that modify the filesystem and commit
|
||||
# immediately. We want to
|
||||
# try hard to keep the DB and the file system in sync, even in the face
|
||||
@ -199,7 +203,8 @@ class MyBlockingBusy(QDialog): # {{{
|
||||
for fmt in fmts.split(','):
|
||||
fmtf = self.db.format(id, fmt, index_is_id=True,
|
||||
as_file=True)
|
||||
if fmtf is None: continue
|
||||
if fmtf is None:
|
||||
continue
|
||||
cdata, area = get_cover_data(fmtf, fmt)
|
||||
if cdata:
|
||||
covers.append((cdata, area))
|
||||
@ -296,18 +301,18 @@ class MyBlockingBusy(QDialog): # {{{
|
||||
|
||||
class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
|
||||
s_r_functions = { '' : lambda x: x,
|
||||
s_r_functions = {'' : lambda x: x,
|
||||
_('Lower Case') : lambda x: icu_lower(x),
|
||||
_('Upper Case') : lambda x: icu_upper(x),
|
||||
_('Title Case') : lambda x: titlecase(x),
|
||||
_('Capitalize') : lambda x: capitalize(x),
|
||||
}
|
||||
|
||||
s_r_match_modes = [ _('Character match'),
|
||||
s_r_match_modes = [_('Character match'),
|
||||
_('Regular Expression'),
|
||||
]
|
||||
|
||||
s_r_replace_modes = [ _('Replace field'),
|
||||
s_r_replace_modes = [_('Replace field'),
|
||||
_('Prepend to field'),
|
||||
_('Append to field'),
|
||||
]
|
||||
@ -559,8 +564,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
def s_r_get_field(self, mi, field):
|
||||
if field:
|
||||
if field == '{template}':
|
||||
v = SafeFormat().safe_format\
|
||||
(unicode(self.s_r_template.text()), mi, _('S/R TEMPLATE ERROR'), mi)
|
||||
v = SafeFormat().safe_format(
|
||||
unicode(self.s_r_template.text()), mi, _('S/R TEMPLATE ERROR'), mi)
|
||||
return [v]
|
||||
fm = self.db.metadata_for_field(field)
|
||||
if field == 'sort':
|
||||
@ -998,7 +1003,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
elif self.cover_from_fmt.isChecked():
|
||||
cover_action = 'fromfmt'
|
||||
|
||||
args = (remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
|
||||
args = Settings(remove_all, remove, add, au, aus, do_aus, rating, pub, do_series,
|
||||
do_autonumber, do_remove_format, remove_format, do_swap_ta,
|
||||
do_remove_conv, do_auto_author, series, do_series_restart,
|
||||
series_start_value, do_title_case, cover_action, clear_series,
|
||||
@ -1146,9 +1151,9 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
set_index(self.search_field, 'search_field')
|
||||
set_text(self.s_r_template, 's_r_template')
|
||||
|
||||
self.s_r_template_changed() #simulate gain/loss of focus
|
||||
self.s_r_template_changed() # simulate gain/loss of focus
|
||||
|
||||
set_index(self.s_r_src_ident, 's_r_src_ident');
|
||||
set_index(self.s_r_src_ident, 's_r_src_ident')
|
||||
set_text(self.s_r_dst_ident, 's_r_dst_ident')
|
||||
set_text(self.search_for, 'search_for')
|
||||
set_checked(self.case_sensitive, 'case_sensitive')
|
||||
@ -1179,3 +1184,4 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
||||
self.starting_from.setValue(1)
|
||||
self.multiple_separator.setText(" ::: ")
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user