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'''
|
'''Dialog to edit metadata in bulk'''
|
||||||
|
|
||||||
import re, os, inspect
|
import re, os, inspect
|
||||||
|
from collections import namedtuple
|
||||||
|
|
||||||
from PyQt4.Qt import Qt, QDialog, QGridLayout, QVBoxLayout, QFont, QLabel, \
|
from PyQt4.Qt import Qt, QDialog, QGridLayout, QVBoxLayout, QFont, QLabel, \
|
||||||
pyqtSignal, QDialogButtonBox, QInputDialog, QLineEdit, \
|
pyqtSignal, QDialogButtonBox, QInputDialog, QLineEdit, \
|
||||||
@ -53,6 +54,10 @@ def get_cover_data(stream, ext): # {{{
|
|||||||
return cdata, area
|
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): # {{{
|
class MyBlockingBusy(QDialog): # {{{
|
||||||
|
|
||||||
do_one_signal = pyqtSignal()
|
do_one_signal = pyqtSignal()
|
||||||
@ -140,7 +145,6 @@ class MyBlockingBusy(QDialog): # {{{
|
|||||||
pubdate, adddate, do_title_sort, languages, clear_languages, \
|
pubdate, adddate, do_title_sort, languages, clear_languages, \
|
||||||
restore_original = self.args
|
restore_original = self.args
|
||||||
|
|
||||||
|
|
||||||
# first loop: All changes that modify the filesystem and commit
|
# first loop: All changes that modify the filesystem and commit
|
||||||
# immediately. We want to
|
# immediately. We want to
|
||||||
# try hard to keep the DB and the file system in sync, even in the face
|
# 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(','):
|
for fmt in fmts.split(','):
|
||||||
fmtf = self.db.format(id, fmt, index_is_id=True,
|
fmtf = self.db.format(id, fmt, index_is_id=True,
|
||||||
as_file=True)
|
as_file=True)
|
||||||
if fmtf is None: continue
|
if fmtf is None:
|
||||||
|
continue
|
||||||
cdata, area = get_cover_data(fmtf, fmt)
|
cdata, area = get_cover_data(fmtf, fmt)
|
||||||
if cdata:
|
if cdata:
|
||||||
covers.append((cdata, area))
|
covers.append((cdata, area))
|
||||||
@ -559,8 +564,8 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
def s_r_get_field(self, mi, field):
|
def s_r_get_field(self, mi, field):
|
||||||
if field:
|
if field:
|
||||||
if field == '{template}':
|
if field == '{template}':
|
||||||
v = SafeFormat().safe_format\
|
v = SafeFormat().safe_format(
|
||||||
(unicode(self.s_r_template.text()), mi, _('S/R TEMPLATE ERROR'), mi)
|
unicode(self.s_r_template.text()), mi, _('S/R TEMPLATE ERROR'), mi)
|
||||||
return [v]
|
return [v]
|
||||||
fm = self.db.metadata_for_field(field)
|
fm = self.db.metadata_for_field(field)
|
||||||
if field == 'sort':
|
if field == 'sort':
|
||||||
@ -998,7 +1003,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
elif self.cover_from_fmt.isChecked():
|
elif self.cover_from_fmt.isChecked():
|
||||||
cover_action = 'fromfmt'
|
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_autonumber, do_remove_format, remove_format, do_swap_ta,
|
||||||
do_remove_conv, do_auto_author, series, do_series_restart,
|
do_remove_conv, do_auto_author, series, do_series_restart,
|
||||||
series_start_value, do_title_case, cover_action, clear_series,
|
series_start_value, do_title_case, cover_action, clear_series,
|
||||||
@ -1148,7 +1153,7 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
|
|
||||||
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.s_r_dst_ident, 's_r_dst_ident')
|
||||||
set_text(self.search_for, 'search_for')
|
set_text(self.search_for, 'search_for')
|
||||||
set_checked(self.case_sensitive, 'case_sensitive')
|
set_checked(self.case_sensitive, 'case_sensitive')
|
||||||
@ -1179,3 +1184,4 @@ class MetadataBulkDialog(ResizableDialog, Ui_MetadataBulkDialog):
|
|||||||
self.starting_from.setValue(1)
|
self.starting_from.setValue(1)
|
||||||
self.multiple_separator.setText(" ::: ")
|
self.multiple_separator.setText(" ::: ")
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user