mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Misc. minor fixes
This commit is contained in:
parent
3829b4c20f
commit
fb9d030241
@ -1891,6 +1891,12 @@ def process_file(path, options, logger):
|
|||||||
if options.header:
|
if options.header:
|
||||||
header = Paragraph()
|
header = Paragraph()
|
||||||
fheader = options.headerformat
|
fheader = options.headerformat
|
||||||
|
if not options.title:
|
||||||
|
options.title = _('Unknown')
|
||||||
|
if not options.author:
|
||||||
|
options.author = _('Unknown')
|
||||||
|
if not fheader:
|
||||||
|
fheader = "%t by %a"
|
||||||
fheader = re.sub(r'(?<!%)%t', options.title, fheader)
|
fheader = re.sub(r'(?<!%)%t', options.title, fheader)
|
||||||
fheader = re.sub(r'(?<!%)%a', options.author, fheader)
|
fheader = re.sub(r'(?<!%)%a', options.author, fheader)
|
||||||
fheader = re.sub(r'%%a','%a',fheader)
|
fheader = re.sub(r'%%a','%a',fheader)
|
||||||
|
@ -15,7 +15,7 @@ from lxml import etree
|
|||||||
from dateutil import parser
|
from dateutil import parser
|
||||||
|
|
||||||
from calibre.ebooks.chardet import xml_to_unicode
|
from calibre.ebooks.chardet import xml_to_unicode
|
||||||
from calibre.constants import __appname__, __version__
|
from calibre.constants import __appname__, __version__, filesystem_encoding
|
||||||
from calibre.ebooks.metadata.toc import TOC
|
from calibre.ebooks.metadata.toc import TOC
|
||||||
from calibre.ebooks.metadata import MetaInformation, string_to_authors
|
from calibre.ebooks.metadata import MetaInformation, string_to_authors
|
||||||
|
|
||||||
@ -1048,6 +1048,8 @@ def metadata_to_opf(mi, as_string=True):
|
|||||||
metadata[-1].tail = '\n' +(' '*4)
|
metadata[-1].tail = '\n' +(' '*4)
|
||||||
|
|
||||||
if mi.cover:
|
if mi.cover:
|
||||||
|
if not isinstance(mi.cover, unicode):
|
||||||
|
mi.cover = mi.cover.decode(filesystem_encoding)
|
||||||
guide.text = '\n'+(' '*8)
|
guide.text = '\n'+(' '*8)
|
||||||
r = guide.makeelement(OPF('reference'),
|
r = guide.makeelement(OPF('reference'),
|
||||||
attrib={'type':'cover', 'title':_('Cover'), 'href':mi.cover})
|
attrib={'type':'cover', 'title':_('Cover'), 'href':mi.cover})
|
||||||
|
@ -23,7 +23,7 @@ from calibre.ebooks.pdf.verify import is_valid_pdf, is_encrypted
|
|||||||
|
|
||||||
from pyPdf import PdfFileWriter, PdfFileReader
|
from pyPdf import PdfFileWriter, PdfFileReader
|
||||||
|
|
||||||
DEFAULT_CROP = '10'
|
DEFAULT_CROP = 10
|
||||||
|
|
||||||
USAGE = '\n%prog %%name ' + _('''\
|
USAGE = '\n%prog %%name ' + _('''\
|
||||||
[options] file.pdf
|
[options] file.pdf
|
||||||
@ -36,16 +36,16 @@ OPTIONS = set([
|
|||||||
level=OptionRecommendation.HIGH, long_switch='output', short_switch='o',
|
level=OptionRecommendation.HIGH, long_switch='output', short_switch='o',
|
||||||
help=_('Path to output file. By default a file is created in the current directory.')),
|
help=_('Path to output file. By default a file is created in the current directory.')),
|
||||||
OptionRecommendation(name='bottom_left_x', recommended_value=DEFAULT_CROP,
|
OptionRecommendation(name='bottom_left_x', recommended_value=DEFAULT_CROP,
|
||||||
level=OptionRecommendation.LOW, long_switch='leftx', short_switch='x',
|
level=OptionRecommendation.LOW, long_switch='left-x', short_switch='x',
|
||||||
help=_('Number of pixels to crop from the left most x (default is %s)') % DEFAULT_CROP),
|
help=_('Number of pixels to crop from the left most x (default is %s)') % DEFAULT_CROP),
|
||||||
OptionRecommendation(name='bottom_left_y', recommended_value=DEFAULT_CROP,
|
OptionRecommendation(name='bottom_left_y', recommended_value=DEFAULT_CROP,
|
||||||
level=OptionRecommendation.LOW, long_switch='lefty', short_switch='y',
|
level=OptionRecommendation.LOW, long_switch='left-y', short_switch='y',
|
||||||
help=_('Number of pixels to crop from the left most y (default is %s)') % DEFAULT_CROP),
|
help=_('Number of pixels to crop from the left most y (default is %s)') % DEFAULT_CROP),
|
||||||
OptionRecommendation(name='top_right_x', recommended_value=DEFAULT_CROP,
|
OptionRecommendation(name='top_right_x', recommended_value=DEFAULT_CROP,
|
||||||
level=OptionRecommendation.LOW, long_switch='rightx', short_switch='v',
|
level=OptionRecommendation.LOW, long_switch='right-x', short_switch='v',
|
||||||
help=_('Number of pixels to crop from the right most x (default is %s)') % DEFAULT_CROP),
|
help=_('Number of pixels to crop from the right most x (default is %s)') % DEFAULT_CROP),
|
||||||
OptionRecommendation(name='top_right_y', recommended_value=DEFAULT_CROP,
|
OptionRecommendation(name='top_right_y', recommended_value=DEFAULT_CROP,
|
||||||
level=OptionRecommendation.LOW, long_switch='right y', short_switch='w',
|
level=OptionRecommendation.LOW, long_switch='right-y', short_switch='w',
|
||||||
help=_('Number of pixels to crop from the right most y (default is %s)') % DEFAULT_CROP),
|
help=_('Number of pixels to crop from the right most y (default is %s)') % DEFAULT_CROP),
|
||||||
OptionRecommendation(name='bounding', recommended_value=None,
|
OptionRecommendation(name='bounding', recommended_value=None,
|
||||||
level=OptionRecommendation.LOW, long_switch='bounding', short_switch='b',
|
level=OptionRecommendation.LOW, long_switch='bounding', short_switch='b',
|
||||||
|
@ -511,7 +511,7 @@ class Wizard(QWizard):
|
|||||||
self.device_page = DevicePage()
|
self.device_page = DevicePage()
|
||||||
self.library_page = LibraryPage()
|
self.library_page = LibraryPage()
|
||||||
self.finish_page = FinishPage()
|
self.finish_page = FinishPage()
|
||||||
bt = unicode(self.buttonText(self.FinishButton))
|
bt = unicode(self.buttonText(self.FinishButton)).replace('&', '')
|
||||||
t = unicode(self.finish_page.finish_text.text())
|
t = unicode(self.finish_page.finish_text.text())
|
||||||
self.finish_page.finish_text.setText(t%bt)
|
self.finish_page.finish_text.setText(t%bt)
|
||||||
self.kindle_page = KindlePage()
|
self.kindle_page = KindlePage()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user