mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
5fb2c7190b
@ -16,7 +16,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
|
|
||||||
TITLE = _('E-book options')
|
TITLE = _('E-book options')
|
||||||
HELP = _('Options specific to')+' EPUB/MOBI '+_('output')
|
HELP = _('Options specific to')+' EPUB/MOBI '+_('output')
|
||||||
OPTION_FIELDS = [('exclude_genre','\[[\w ]*\]'),
|
OPTION_FIELDS = [('exclude_genre','\[.+\]'),
|
||||||
('exclude_tags','~,'+_('Catalog')),
|
('exclude_tags','~,'+_('Catalog')),
|
||||||
('generate_titles', True),
|
('generate_titles', True),
|
||||||
('generate_recently_added', True),
|
('generate_recently_added', True),
|
||||||
|
@ -80,7 +80,7 @@
|
|||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Regex tips:
|
<string>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</string>
|
- A regex pattern of a single dot excludes all genre tags, generating no Genre Section</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
|
@ -194,6 +194,7 @@ class MetadataBulkDialog(QDialog, Ui_MetadataBulkDialog):
|
|||||||
finally:
|
finally:
|
||||||
pd.hide()
|
pd.hide()
|
||||||
|
|
||||||
|
self.db.clean()
|
||||||
return QDialog.accept(self)
|
return QDialog.accept(self)
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ from PyQt4.Qt import Qt, SIGNAL, QTimer, \
|
|||||||
from calibre import prints
|
from calibre import prints
|
||||||
from calibre.constants import __appname__, isosx
|
from calibre.constants import __appname__, isosx
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
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.utils.ipc.server import Server
|
||||||
from calibre.library.database2 import LibraryDatabase2
|
from calibre.library.database2 import LibraryDatabase2
|
||||||
from calibre.customize.ui import interface_actions
|
from calibre.customize.ui import interface_actions
|
||||||
@ -230,8 +230,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
|
|
||||||
######################### Search Restriction ##########################
|
######################### Search Restriction ##########################
|
||||||
SearchRestrictionMixin.__init__(self)
|
SearchRestrictionMixin.__init__(self)
|
||||||
if tweaks['restrict_at_startup']:
|
|
||||||
self.apply_named_search_restriction(tweaks['restrict_at_startup'])
|
|
||||||
|
|
||||||
########################### Cover Flow ################################
|
########################### Cover Flow ################################
|
||||||
|
|
||||||
@ -375,8 +373,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
self.set_window_title()
|
self.set_window_title()
|
||||||
self.apply_named_search_restriction('') # reset restriction to null
|
self.apply_named_search_restriction('') # reset restriction to null
|
||||||
self.saved_searches_changed() # reload the search restrictions combo box
|
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):
|
def set_window_title(self):
|
||||||
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
self.setWindowTitle(__appname__ + u' - ||%s||'%self.iactions['Choose Library'].library_name())
|
||||||
|
@ -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.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)
|
self.max_view_width.setValue(opts.max_view_width)
|
||||||
pats = [os.path.basename(x).split('.')[0] for x in
|
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))
|
names = list(map(get_language, pats))
|
||||||
pmap = {}
|
pmap = {}
|
||||||
for i in range(len(pats)):
|
for i in range(len(pats)):
|
||||||
|
@ -541,7 +541,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
"Default: '%default'None\n"
|
"Default: '%default'None\n"
|
||||||
"Applies to: ePub, MOBI output formats")),
|
"Applies to: ePub, MOBI output formats")),
|
||||||
Option('--exclude-genre',
|
Option('--exclude-genre',
|
||||||
default='\[[\w ]*\]',
|
default='\[.+\]',
|
||||||
dest='exclude_genre',
|
dest='exclude_genre',
|
||||||
action = None,
|
action = None,
|
||||||
help=_("Regex describing tags to exclude as genres.\n" "Default: '%default' excludes bracketed tags, e.g. '[<tag>]'\n"
|
help=_("Regex describing tags to exclude as genres.\n" "Default: '%default' excludes bracketed tags, e.g. '[<tag>]'\n"
|
||||||
|
@ -315,6 +315,10 @@ class CustomColumns(object):
|
|||||||
|
|
||||||
def set_custom_bulk(self, ids, add=[], remove=[],
|
def set_custom_bulk(self, ids, add=[], remove=[],
|
||||||
label=None, num=None, notify=False):
|
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:
|
if label is not None:
|
||||||
data = self.custom_column_label_map[label]
|
data = self.custom_column_label_map[label]
|
||||||
if num is not None:
|
if num is not None:
|
||||||
@ -378,10 +382,6 @@ class CustomColumns(object):
|
|||||||
)
|
)
|
||||||
# get rid of the temp tables
|
# get rid of the temp tables
|
||||||
self.conn.executescript(drops)
|
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()
|
self.conn.commit()
|
||||||
|
|
||||||
# set the in-memory copies of the tags
|
# set the in-memory copies of the tags
|
||||||
|
@ -705,7 +705,8 @@ if prefs['installation_uuid'] is None:
|
|||||||
# Read tweaks
|
# Read tweaks
|
||||||
def read_raw_tweaks():
|
def read_raw_tweaks():
|
||||||
make_config_dir()
|
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')
|
tweaks_file = os.path.join(config_dir, 'tweaks.py')
|
||||||
if not os.path.exists(tweaks_file):
|
if not os.path.exists(tweaks_file):
|
||||||
with open(tweaks_file, 'wb') as f:
|
with open(tweaks_file, 'wb') as f:
|
||||||
|
@ -25,29 +25,36 @@ class PathResolver(object):
|
|||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
self.default_path = sys.resources_location
|
||||||
|
|
||||||
dev_path = os.environ.get('CALIBRE_DEVELOP_FROM', None)
|
dev_path = os.environ.get('CALIBRE_DEVELOP_FROM', None)
|
||||||
if dev_path is not None:
|
if dev_path is not None:
|
||||||
dev_path = os.path.join(os.path.abspath(
|
dev_path = os.path.join(os.path.abspath(
|
||||||
os.path.dirname(dev_path)), 'resources')
|
os.path.dirname(dev_path)), 'resources')
|
||||||
if suitable(dev_path):
|
if suitable(dev_path):
|
||||||
self.locations.insert(0, dev_path)
|
self.locations.insert(0, dev_path)
|
||||||
|
self.default_path = dev_path
|
||||||
|
|
||||||
user_path = os.path.join(config_dir, 'resources')
|
user_path = os.path.join(config_dir, 'resources')
|
||||||
|
self.user_path = None
|
||||||
if suitable(user_path):
|
if suitable(user_path):
|
||||||
self.locations.insert(0, 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, '/')
|
path = path.replace(os.sep, '/')
|
||||||
ans = self.cache.get(path, None)
|
ans = self.cache.get(path, None)
|
||||||
if ans is None:
|
if ans is None:
|
||||||
for base in self.locations:
|
for base in self.locations:
|
||||||
|
if not allow_user_override and base == self.user_path:
|
||||||
|
continue
|
||||||
fpath = os.path.join(base, *path.split('/'))
|
fpath = os.path.join(base, *path.split('/'))
|
||||||
if os.path.exists(fpath):
|
if os.path.exists(fpath):
|
||||||
ans = fpath
|
ans = fpath
|
||||||
break
|
break
|
||||||
|
|
||||||
if ans is None:
|
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
|
self.cache[path] = ans
|
||||||
|
|
||||||
@ -55,13 +62,13 @@ class PathResolver(object):
|
|||||||
|
|
||||||
_resolver = PathResolver()
|
_resolver = PathResolver()
|
||||||
|
|
||||||
def get_path(path, data=False):
|
def get_path(path, data=False, allow_user_override=True):
|
||||||
fpath = _resolver(path)
|
fpath = _resolver(path, allow_user_override=allow_user_override)
|
||||||
if data:
|
if data:
|
||||||
return open(fpath, 'rb').read()
|
return open(fpath, 'rb').read()
|
||||||
return fpath
|
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)
|
return get_path('images/'+path, data=data)
|
||||||
|
|
||||||
__builtin__.__dict__['P'] = get_path
|
__builtin__.__dict__['P'] = get_path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user