mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
ef05b19024
@ -5,6 +5,7 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from contextlib import suppress
|
||||||
from functools import lru_cache, partial
|
from functools import lru_cache, partial
|
||||||
from qt.core import (
|
from qt.core import (
|
||||||
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon,
|
QAction, QApplication, QClipboard, QColor, QDialog, QEasingCurve, QIcon,
|
||||||
@ -474,6 +475,13 @@ def create_copy_links(menu, data=None):
|
|||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
link(_('Link to show book in calibre'), f'calibre://show-book/{library_id}/{book_id}')
|
link(_('Link to show book in calibre'), f'calibre://show-book/{library_id}/{book_id}')
|
||||||
link(_('Link to show book details in a popup window'), f'calibre://book-details/{library_id}/{book_id}')
|
link(_('Link to show book details in a popup window'), f'calibre://book-details/{library_id}/{book_id}')
|
||||||
|
mi = db.new_api.get_proxy_metadata(book_id)
|
||||||
|
data_path = os.path.join(db.backend.library_path, mi.path, 'data')
|
||||||
|
with suppress(OSError):
|
||||||
|
if os.listdir(data_path):
|
||||||
|
if iswindows:
|
||||||
|
data_path = '/' + data_path.replace('\\', '/')
|
||||||
|
link(_("Link to open book's data files folder"), 'file://' + data_path)
|
||||||
if data:
|
if data:
|
||||||
field = data.get('field')
|
field = data.get('field')
|
||||||
if data['type'] == 'author':
|
if data['type'] == 'author':
|
||||||
@ -490,7 +498,6 @@ def create_copy_links(menu, data=None):
|
|||||||
|
|
||||||
if all_links:
|
if all_links:
|
||||||
menu.addSeparator()
|
menu.addSeparator()
|
||||||
mi = db.new_api.get_proxy_metadata(book_id)
|
|
||||||
all_links.insert(0, '')
|
all_links.insert(0, '')
|
||||||
all_links.insert(0, mi.get('title') + ' - ' + ' & '.join(mi.get('authors')))
|
all_links.insert(0, mi.get('title') + ' - ' + ' & '.join(mi.get('authors')))
|
||||||
link(_('Copy all the above links'), '\n'.join(all_links))
|
link(_('Copy all the above links'), '\n'.join(all_links))
|
||||||
|
@ -618,17 +618,17 @@ class TemplateDialog(QDialog, Ui_TemplateDialog):
|
|||||||
def add_python_template_header_text(self):
|
def add_python_template_header_text(self):
|
||||||
self.textbox.setPlainText('''python:
|
self.textbox.setPlainText('''python:
|
||||||
def evaluate(book, context):
|
def evaluate(book, context):
|
||||||
# book is a calibre metadata object
|
\t# book is a calibre metadata object
|
||||||
# context is an instance of calibre.utils.formatter.PythonTemplateContext,
|
\t# context is an instance of calibre.utils.formatter.PythonTemplateContext,
|
||||||
# which currently contains the following attributes:
|
\t# which currently contains the following attributes:
|
||||||
# db: a calibre legacy database object.
|
\t# db: a calibre legacy database object.
|
||||||
# globals: the template global variable dictionary.
|
\t# globals: the template global variable dictionary.
|
||||||
# arguments: is a list of arguments if the template is called by a GPM template, otherwise None.
|
\t# arguments: is a list of arguments if the template is called by a GPM template, otherwise None.
|
||||||
# funcs: used to call Built-in/User functions and Stored GPM/Python templates.
|
\t# funcs: used to call Built-in/User functions and Stored GPM/Python templates.
|
||||||
# Example: context.funcs.list_re_group()
|
\t# Example: context.funcs.list_re_group()
|
||||||
|
|
||||||
# your Python code goes here
|
\t# your Python code goes here
|
||||||
return 'a string'
|
\treturn 'a string'
|
||||||
''')
|
''')
|
||||||
|
|
||||||
def set_word_wrap(self, to_what):
|
def set_word_wrap(self, to_what):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user