diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.py b/src/calibre/gui2/catalog/catalog_epub_mobi.py index 6ecab3c081..5acda0948c 100644 --- a/src/calibre/gui2/catalog/catalog_epub_mobi.py +++ b/src/calibre/gui2/catalog/catalog_epub_mobi.py @@ -16,7 +16,7 @@ class PluginWidget(QWidget,Ui_Form): TITLE = _('E-book options') HELP = _('Options specific to')+' EPUB/MOBI '+_('output') - OPTION_FIELDS = [('exclude_genre','\[[\w ]*\]'), + OPTION_FIELDS = [('exclude_genre','\[.+\]'), ('exclude_tags','~,'+_('Catalog')), ('generate_titles', True), ('generate_recently_added', True), diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.ui b/src/calibre/gui2/catalog/catalog_epub_mobi.ui index dab8c972c7..cdf91eed6f 100644 --- a/src/calibre/gui2/catalog/catalog_epub_mobi.ui +++ b/src/calibre/gui2/catalog/catalog_epub_mobi.ui @@ -80,7 +80,7 @@ Regex tips: -- The default regex - \[[\w ]*\] - excludes genre tags of the form [tag], e.g., [Amazon Freebie] +- The default regex - \[.+\] - excludes genre tags of the form [tag], e.g., [Amazon Freebie] - A regex pattern of a single dot excludes all genre tags, generating no Genre Section diff --git a/src/calibre/gui2/dialogs/metadata_bulk.py b/src/calibre/gui2/dialogs/metadata_bulk.py index 29ba22a5ac..0139d0aee2 100644 --- a/src/calibre/gui2/dialogs/metadata_bulk.py +++ b/src/calibre/gui2/dialogs/metadata_bulk.py @@ -194,6 +194,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog): finally: pd.hide() + self.db.clean() return QDialog.accept(self) diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py index e87d39ba55..f521bceaf9 100644 --- a/src/calibre/gui2/ui.py +++ b/src/calibre/gui2/ui.py @@ -21,7 +21,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \ from calibre import prints from calibre.constants import __appname__, isosx from calibre.ptempfile import PersistentTemporaryFile -from calibre.utils.config import prefs, dynamic, tweaks +from calibre.utils.config import prefs, dynamic from calibre.utils.ipc.server import Server from calibre.library.database2 import LibraryDatabase2 from calibre.customize.ui import interface_actions @@ -230,8 +230,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ ######################### Search Restriction ########################## SearchRestrictionMixin.__init__(self) - if tweaks['restrict_at_startup']: - self.apply_named_search_restriction(tweaks['restrict_at_startup']) ########################### Cover Flow ################################ @@ -375,8 +373,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{ self.set_window_title() self.apply_named_search_restriction('') # reset restriction to null self.saved_searches_changed() # reload the search restrictions combo box - if tweaks['restrict_at_startup']: - self.apply_named_search_restriction(tweaks['restrict_at_startup']) def set_window_title(self): self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name()) diff --git a/src/calibre/gui2/viewer/documentview.py b/src/calibre/gui2/viewer/documentview.py index 4653529095..75f95b1a90 100644 --- a/src/calibre/gui2/viewer/documentview.py +++ b/src/calibre/gui2/viewer/documentview.py @@ -81,7 +81,8 @@ class ConfigDialog(QDialog, Ui_Dialog): self.css.setToolTip(_('Set the user CSS stylesheet. This can be used to customize the look of all books.')) self.max_view_width.setValue(opts.max_view_width) pats = [os.path.basename(x).split('.')[0] for x in - glob.glob(P('viewer/hyphenate/patterns/*.js'))] + glob.glob(P('viewer/hyphenate/patterns/*.js', + allow_user_override=False))] names = list(map(get_language, pats)) pmap = {} for i in range(len(pats)): diff --git a/src/calibre/library/catalog.py b/src/calibre/library/catalog.py index ed41ecb76e..b4fd537729 100644 --- a/src/calibre/library/catalog.py +++ b/src/calibre/library/catalog.py @@ -541,7 +541,7 @@ class EPUB_MOBI(CatalogPlugin): "Default: '%default'None\n" "Applies to: ePub, MOBI output formats")), Option('--exclude-genre', - default='\[[\w ]*\]', + default='\[.+\]', dest='exclude_genre', action = None, help=_("Regex describing tags to exclude as genres.\n" "Default: '%default' excludes bracketed tags, e.g. '[]'\n" diff --git a/src/calibre/library/custom_columns.py b/src/calibre/library/custom_columns.py index 3b4a84af4f..7c613295b9 100644 --- a/src/calibre/library/custom_columns.py +++ b/src/calibre/library/custom_columns.py @@ -315,6 +315,10 @@ class CustomColumns(object): def set_custom_bulk(self, ids, add=[], remove=[], label=None, num=None, notify=False): + ''' + Fast algorithm for updating custom column is_multiple datatypes. + Do not use with other custom column datatypes. + ''' if label is not None: data = self.custom_column_label_map[label] if num is not None: @@ -378,10 +382,6 @@ class CustomColumns(object): ) # get rid of the temp tables self.conn.executescript(drops) - # Remove any dreg tags -- ones with no references - self.conn.execute( - '''DELETE FROM %s WHERE (SELECT COUNT(id) FROM %s WHERE - value=%s.id) < 1''' % (cust_table, link_table, cust_table)) self.conn.commit() # set the in-memory copies of the tags diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index 3d2663cd1d..5c8fe523e3 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -705,7 +705,8 @@ if prefs['installation_uuid'] is None: # Read tweaks def read_raw_tweaks(): make_config_dir() - default_tweaks = P('default_tweaks.py', data=True) + default_tweaks = P('default_tweaks.py', data=True, + allow_user_override=False) tweaks_file = os.path.join(config_dir, 'tweaks.py') if not os.path.exists(tweaks_file): with open(tweaks_file, 'wb') as f: diff --git a/src/calibre/utils/resources.py b/src/calibre/utils/resources.py index dd600eb627..97c14926e4 100644 --- a/src/calibre/utils/resources.py +++ b/src/calibre/utils/resources.py @@ -25,29 +25,36 @@ class PathResolver(object): pass return False + self.default_path = sys.resources_location + dev_path = os.environ.get('CALIBRE_DEVELOP_FROM', None) if dev_path is not None: dev_path = os.path.join(os.path.abspath( os.path.dirname(dev_path)), 'resources') if suitable(dev_path): self.locations.insert(0, dev_path) + self.default_path = dev_path user_path = os.path.join(config_dir, 'resources') + self.user_path = None if suitable(user_path): self.locations.insert(0, user_path) + self.user_path = user_path - def __call__(self, path): + def __call__(self, path, allow_user_override=True): path = path.replace(os.sep, '/') ans = self.cache.get(path, None) if ans is None: for base in self.locations: + if not allow_user_override and base == self.user_path: + continue fpath = os.path.join(base, *path.split('/')) if os.path.exists(fpath): ans = fpath break if ans is None: - ans = os.path.join(self.locations[0], *path.split('/')) + ans = os.path.join(self.default_path, *path.split('/')) self.cache[path] = ans @@ -55,13 +62,13 @@ class PathResolver(object): _resolver = PathResolver() -def get_path(path, data=False): - fpath = _resolver(path) +def get_path(path, data=False, allow_user_override=True): + fpath = _resolver(path, allow_user_override=allow_user_override) if data: return open(fpath, 'rb').read() return fpath -def get_image_path(path, data=False): +def get_image_path(path, data=False, allow_user_override=True): return get_path('images/'+path, data=data) __builtin__.__dict__['P'] = get_path