mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Move the ignores from tweaks to the dialog
This commit is contained in:
parent
5742f5b9dc
commit
c3bf0d736e
@ -171,11 +171,3 @@ content_server_wont_display = ['']
|
|||||||
# level sorts, and if you are seeing a slowdown, reduce the value of this tweak.
|
# level sorts, and if you are seeing a slowdown, reduce the value of this tweak.
|
||||||
maximum_resort_levels = 5
|
maximum_resort_levels = 5
|
||||||
|
|
||||||
|
|
||||||
# Select names and extensions that check library will not report.
|
|
||||||
# Example: to ignore all jpgs and pngs
|
|
||||||
# check_library_ignore_extensions=['jpg', 'png']
|
|
||||||
# Example: to ignore all instances of _catalog (calibre2opds) and its children:
|
|
||||||
# check_library_ignore_names=['_catalog']
|
|
||||||
check_library_ignore_names=[]
|
|
||||||
check_library_ignore_extensions=[]
|
|
||||||
|
@ -3,8 +3,9 @@ __copyright__ = '2008, Kovid Goyal kovid@kovidgoyal.net'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
|
|
||||||
from PyQt4.Qt import QDialog, QVBoxLayout, QTreeWidget, QPushButton, \
|
from PyQt4.Qt import QDialog, QVBoxLayout, QHBoxLayout, QTreeWidget, QLabel, \
|
||||||
QDialogButtonBox, QApplication, QTreeWidgetItem
|
QPushButton, QDialogButtonBox, QApplication, QTreeWidgetItem, \
|
||||||
|
QLineEdit
|
||||||
|
|
||||||
from calibre.library.check_library import CheckLibrary, CHECKS
|
from calibre.library.check_library import CheckLibrary, CHECKS
|
||||||
|
|
||||||
@ -17,11 +18,13 @@ class CheckLibraryDialog(QDialog):
|
|||||||
QDialog.__init__(self, parent)
|
QDialog.__init__(self, parent)
|
||||||
self.db = db
|
self.db = db
|
||||||
|
|
||||||
|
self.setWindowTitle(_('Check Library'))
|
||||||
|
|
||||||
self._layout = QVBoxLayout(self)
|
self._layout = QVBoxLayout(self)
|
||||||
self.setLayout(self._layout)
|
self.setLayout(self._layout)
|
||||||
|
|
||||||
self.log = QTreeWidget(self)
|
self.log = QTreeWidget(self)
|
||||||
self._layout.addWidget(self.log)
|
self._layout.addWidget(self.log)
|
||||||
self.setWindowTitle(_('Check Library'))
|
|
||||||
|
|
||||||
self.check = QPushButton(_('Run the check'))
|
self.check = QPushButton(_('Run the check'))
|
||||||
self.check.setDefault(False)
|
self.check.setDefault(False)
|
||||||
@ -32,20 +35,50 @@ class CheckLibraryDialog(QDialog):
|
|||||||
self.ok = QPushButton('&OK')
|
self.ok = QPushButton('&OK')
|
||||||
self.ok.setDefault(True)
|
self.ok.setDefault(True)
|
||||||
self.ok.clicked.connect(self.accept)
|
self.ok.clicked.connect(self.accept)
|
||||||
|
self.cancel = QPushButton('&Cancel')
|
||||||
|
self.cancel.setDefault(False)
|
||||||
|
self.cancel.clicked.connect(self.reject)
|
||||||
self.bbox = QDialogButtonBox(self)
|
self.bbox = QDialogButtonBox(self)
|
||||||
self.bbox.addButton(self.copy, QDialogButtonBox.ActionRole)
|
self.bbox.addButton(self.copy, QDialogButtonBox.ActionRole)
|
||||||
self.bbox.addButton(self.check, QDialogButtonBox.ActionRole)
|
self.bbox.addButton(self.check, QDialogButtonBox.ActionRole)
|
||||||
|
self.bbox.addButton(self.cancel, QDialogButtonBox.RejectRole)
|
||||||
self.bbox.addButton(self.ok, QDialogButtonBox.AcceptRole)
|
self.bbox.addButton(self.ok, QDialogButtonBox.AcceptRole)
|
||||||
|
|
||||||
|
h = QHBoxLayout()
|
||||||
|
ln = QLabel(_('Names to ignore:'))
|
||||||
|
h.addWidget(ln)
|
||||||
|
self.name_ignores = QLineEdit()
|
||||||
|
self.name_ignores.setText(db.prefs.get('check_library_ignore_names', ''))
|
||||||
|
ln.setBuddy(self.name_ignores)
|
||||||
|
h.addWidget(self.name_ignores)
|
||||||
|
le = QLabel(_('Extensions to ignore'))
|
||||||
|
h.addWidget(le)
|
||||||
|
self.ext_ignores = QLineEdit()
|
||||||
|
self.ext_ignores.setText(db.prefs.get('check_library_ignore_extensions', ''))
|
||||||
|
le.setBuddy(self.ext_ignores)
|
||||||
|
h.addWidget(self.ext_ignores)
|
||||||
|
self._layout.addLayout(h)
|
||||||
|
|
||||||
self._layout.addWidget(self.bbox)
|
self._layout.addWidget(self.bbox)
|
||||||
self.resize(750, 500)
|
self.resize(750, 500)
|
||||||
self.bbox.setEnabled(True)
|
self.bbox.setEnabled(True)
|
||||||
|
|
||||||
self.run_the_check()
|
self.run_the_check()
|
||||||
|
|
||||||
|
def accept(self):
|
||||||
|
self.db.prefs['check_library_ignore_extensions'] = \
|
||||||
|
unicode(self.ext_ignores.text())
|
||||||
|
self.db.prefs['check_library_ignore_names'] = \
|
||||||
|
unicode(self.name_ignores.text())
|
||||||
|
QDialog.accept(self)
|
||||||
|
|
||||||
|
def box_to_list(self, txt):
|
||||||
|
return [f.strip().lower() for f in txt.split(',') if f.strip()]
|
||||||
|
|
||||||
def run_the_check(self):
|
def run_the_check(self):
|
||||||
checker = CheckLibrary(self.db.library_path, self.db)
|
checker = CheckLibrary(self.db.library_path, self.db)
|
||||||
checker.scan_library()
|
checker.scan_library(self.box_to_list(unicode(self.name_ignores.text())),
|
||||||
|
self.box_to_list(unicode(self.name_ignores.text())))
|
||||||
|
|
||||||
plaintext = []
|
plaintext = []
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import re, os, traceback
|
|||||||
from calibre import isbytestring
|
from calibre import isbytestring
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding
|
||||||
from calibre.ebooks import BOOK_EXTENSIONS
|
from calibre.ebooks import BOOK_EXTENSIONS
|
||||||
from calibre.utils.config import tweaks
|
|
||||||
|
|
||||||
EBOOK_EXTENSIONS = frozenset(BOOK_EXTENSIONS)
|
EBOOK_EXTENSIONS = frozenset(BOOK_EXTENSIONS)
|
||||||
|
|
||||||
@ -37,10 +36,6 @@ class CheckLibrary(object):
|
|||||||
|
|
||||||
self.is_case_sensitive = db.is_case_sensitive
|
self.is_case_sensitive = db.is_case_sensitive
|
||||||
|
|
||||||
self.ignore_names = frozenset(tweaks['check_library_ignore_names'])
|
|
||||||
self.ignore_ext = frozenset(['.'+ e for e in
|
|
||||||
tweaks['check_library_ignore_extensions']])
|
|
||||||
|
|
||||||
self.all_authors = frozenset([x[1] for x in db.all_authors()])
|
self.all_authors = frozenset([x[1] for x in db.all_authors()])
|
||||||
self.all_ids = frozenset([id for id in db.all_ids()])
|
self.all_ids = frozenset([id for id in db.all_ids()])
|
||||||
self.all_dbpaths = frozenset(self.dbpath(id) for id in self.all_ids)
|
self.all_dbpaths = frozenset(self.dbpath(id) for id in self.all_ids)
|
||||||
@ -73,7 +68,10 @@ class CheckLibrary(object):
|
|||||||
return self.failed_folders or self.mismatched_dirs or \
|
return self.failed_folders or self.mismatched_dirs or \
|
||||||
self.conflicting_custom_cols or self.failed_restores
|
self.conflicting_custom_cols or self.failed_restores
|
||||||
|
|
||||||
def scan_library(self):
|
def scan_library(self, name_ignores, extension_ignores):
|
||||||
|
self.ignore_names = frozenset(name_ignores)
|
||||||
|
self.ignore_ext = frozenset(['.'+ e for e in extension_ignores])
|
||||||
|
|
||||||
lib = self.src_library_path
|
lib = self.src_library_path
|
||||||
for auth_dir in os.listdir(lib):
|
for auth_dir in os.listdir(lib):
|
||||||
if auth_dir in self.ignore_names:
|
if auth_dir in self.ignore_names:
|
||||||
|
@ -888,6 +888,14 @@ Perform some checks on the filesystem representing a library. Reports are {0}
|
|||||||
parser.add_option('-r', '--report', default=None, dest='report',
|
parser.add_option('-r', '--report', default=None, dest='report',
|
||||||
help=_("Comma-separated list of reports.\n"
|
help=_("Comma-separated list of reports.\n"
|
||||||
"Default: all"))
|
"Default: all"))
|
||||||
|
|
||||||
|
parser.add_option('-e', '--ignore_extensions', default=None, dest='exts',
|
||||||
|
help=_("Comma-separated list of extensions to ignore.\n"
|
||||||
|
"Default: all"))
|
||||||
|
|
||||||
|
parser.add_option('-n', '--ignore_names', default=None, dest='names',
|
||||||
|
help=_("Comma-separated list of names to ignore.\n"
|
||||||
|
"Default: all"))
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def command_check_library(args, dbpath):
|
def command_check_library(args, dbpath):
|
||||||
@ -919,6 +927,15 @@ def command_check_library(args, dbpath):
|
|||||||
print _('Unknown report check'), r
|
print _('Unknown report check'), r
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if opts.names is None:
|
||||||
|
names = []
|
||||||
|
else:
|
||||||
|
names = [f.strip().lower() for f in opts.names.split(',') if f.strip()]
|
||||||
|
if opts.exts is None:
|
||||||
|
exts = []
|
||||||
|
else:
|
||||||
|
exts = [f.strip().lower() for f in opts.exts.split(',') if f.strip()]
|
||||||
|
|
||||||
def print_one(checker, check):
|
def print_one(checker, check):
|
||||||
attr = check[0]
|
attr = check[0]
|
||||||
list = getattr(checker, attr, None)
|
list = getattr(checker, attr, None)
|
||||||
@ -934,7 +951,7 @@ def command_check_library(args, dbpath):
|
|||||||
|
|
||||||
db = LibraryDatabase2(dbpath)
|
db = LibraryDatabase2(dbpath)
|
||||||
checker = CheckLibrary(dbpath, db)
|
checker = CheckLibrary(dbpath, db)
|
||||||
checker.scan_library()
|
checker.scan_library(names, exts)
|
||||||
for check in checks:
|
for check in checks:
|
||||||
print_one(checker, check)
|
print_one(checker, check)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user