mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
KG's iterim updates
This commit is contained in:
commit
008ba1328a
@ -11,9 +11,9 @@
|
|||||||
- title: Catalog generation
|
- title: Catalog generation
|
||||||
type: major
|
type: major
|
||||||
description: >
|
description: >
|
||||||
"You can now easily generate a catlog of all books in your calibre library by clicking the arrow next to the convert button. The catalog can be in one of several formats: XML, CSV, EPUB and MOBI, with scope for future formats via plugins. If you generate the catalog in an e-book format, it will be automatically sent to your e-book reader the next time you connect it, allowing you to easily browse your collection on the reader itself."
|
"You can now easily generate a catlog of all books in your calibre library by clicking the arrow next to the convert button. The catalog can be in one of several formats: XML, CSV, EPUB and MOBI, with scope for future formats via plugins. If you generate the catalog in an e-book format, it will be automatically sent to your e-book reader the next time you connect it, allowing you to easily browse your collection on the reader itself. This feature is in Beta (may have bugs) so feedback is appreciated."
|
||||||
|
|
||||||
- title: "RTF Input: Support for unicode characters. Needs testing."
|
- title: "RTF Input: Support for unicode characters."
|
||||||
type: major
|
type: major
|
||||||
tickets: [4501]
|
tickets: [4501]
|
||||||
|
|
||||||
|
@ -312,7 +312,7 @@ class CatalogPlugin(Plugin):
|
|||||||
continue
|
continue
|
||||||
resources.close()
|
resources.close()
|
||||||
|
|
||||||
def run(self, path_to_output, opts, db, ids):
|
def run(self, path_to_output, opts, db, ids, notification=None):
|
||||||
'''
|
'''
|
||||||
Run the plugin. Must be implemented in subclasses.
|
Run the plugin. Must be implemented in subclasses.
|
||||||
It should generate the catalog in the format specified
|
It should generate the catalog in the format specified
|
||||||
|
@ -85,6 +85,9 @@ class OptionRecommendation(object):
|
|||||||
|
|
||||||
class DummyReporter(object):
|
class DummyReporter(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.cancel_requested = False
|
||||||
|
|
||||||
def __call__(self, percent, msg=''):
|
def __call__(self, percent, msg=''):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -153,6 +153,21 @@ class Region(object):
|
|||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def contains(self, columns):
|
||||||
|
if not self.columns:
|
||||||
|
return True
|
||||||
|
if len(columns) != len(self.columns):
|
||||||
|
return False
|
||||||
|
for i in range(len(columns)):
|
||||||
|
c1, c2 = self.columns[i], columns[i]
|
||||||
|
x1 = Interval(c1.left, c1.right)
|
||||||
|
x2 = Interval(c2.left, c2.right)
|
||||||
|
intersection = x1.intersection(x2)
|
||||||
|
base = min(x1.width, x2.width)
|
||||||
|
if intersection.width/base < 0.6:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
class Page(object):
|
class Page(object):
|
||||||
|
|
||||||
# Fraction of a character width that two strings have to be apart,
|
# Fraction of a character width that two strings have to be apart,
|
||||||
|
@ -13,44 +13,34 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Form</string>
|
<string>Form</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QListWidget" name="db_fields">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<property name="geometry">
|
<item row="0" column="0">
|
||||||
<rect>
|
<widget class="QLabel" name="label_6">
|
||||||
<x>297</x>
|
<property name="text">
|
||||||
<y>20</y>
|
<string>Fields to include in output:</string>
|
||||||
<width>256</width>
|
</property>
|
||||||
<height>281</height>
|
<property name="alignment">
|
||||||
</rect>
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
</widget>
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
</item>
|
||||||
<horstretch>0</horstretch>
|
<item row="0" column="1">
|
||||||
<verstretch>0</verstretch>
|
<widget class="QListWidget" name="db_fields">
|
||||||
</sizepolicy>
|
<property name="sizePolicy">
|
||||||
</property>
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
<property name="toolTip">
|
<horstretch>0</horstretch>
|
||||||
<string extracomment="Select all fields to be exported"/>
|
<verstretch>0</verstretch>
|
||||||
</property>
|
</sizepolicy>
|
||||||
<property name="selectionMode">
|
</property>
|
||||||
<enum>QAbstractItemView::MultiSelection</enum>
|
<property name="toolTip">
|
||||||
</property>
|
<string extracomment="Select all fields to be exported"/>
|
||||||
</widget>
|
</property>
|
||||||
<widget class="QLabel" name="label_6">
|
<property name="selectionMode">
|
||||||
<property name="geometry">
|
<enum>QAbstractItemView::MultiSelection</enum>
|
||||||
<rect>
|
</property>
|
||||||
<x>20</x>
|
</widget>
|
||||||
<y>20</y>
|
</item>
|
||||||
<width>171</width>
|
</layout>
|
||||||
<height>17</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Fields to include in output:</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
@ -44,8 +44,7 @@ class PluginWidget(QWidget,Ui_Form):
|
|||||||
for opt in self.OPTION_FIELDS:
|
for opt in self.OPTION_FIELDS:
|
||||||
opt_value = unicode(getattr(self, opt[0]).text())
|
opt_value = unicode(getattr(self, opt[0]).text())
|
||||||
gprefs.set(self.name + '_' + opt[0], opt_value)
|
gprefs.set(self.name + '_' + opt[0], opt_value)
|
||||||
if opt[0] == 'exclude_tags':
|
opt_value = opt_value.split(',')
|
||||||
opt_value = opt_value.split(',')
|
|
||||||
opts_dict[opt[0]] = opt_value
|
opts_dict[opt[0]] = opt_value
|
||||||
|
|
||||||
opts_dict['output_profile'] = [load_defaults('page_setup')['output_profile']]
|
opts_dict['output_profile'] = [load_defaults('page_setup')['output_profile']]
|
||||||
|
@ -53,11 +53,6 @@ def gui_catalog(fmt, title, dbspec, ids, out_file_name, fmt_options,
|
|||||||
|
|
||||||
# Fetch and run the plugin for fmt
|
# Fetch and run the plugin for fmt
|
||||||
plugin = plugin_for_catalog_format(fmt)
|
plugin = plugin_for_catalog_format(fmt)
|
||||||
plugin.run(out_file_name, opts, db)
|
plugin.run(out_file_name, opts, db, notification=notification)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1402,7 +1402,7 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
|||||||
dynamic.set('catalogs_to_be_synced', sync)
|
dynamic.set('catalogs_to_be_synced', sync)
|
||||||
self.status_bar.showMessage(_('Catalog generated.'), 3000)
|
self.status_bar.showMessage(_('Catalog generated.'), 3000)
|
||||||
self.sync_catalogs()
|
self.sync_catalogs()
|
||||||
if job.fmt in ['CSV','XML']:
|
if job.fmt not in ['EPUB','MOBI']:
|
||||||
export_dir = choose_dir(self, _('Export Catalog Directory'),
|
export_dir = choose_dir(self, _('Export Catalog Directory'),
|
||||||
_('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
|
_('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
|
||||||
if export_dir:
|
if export_dir:
|
||||||
|
@ -5,6 +5,7 @@ from xml.sax.saxutils import escape
|
|||||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag, NavigableString
|
||||||
from calibre.customize import CatalogPlugin
|
from calibre.customize import CatalogPlugin
|
||||||
from calibre.ptempfile import PersistentTemporaryDirectory
|
from calibre.ptempfile import PersistentTemporaryDirectory
|
||||||
|
from calibre.customize.conversion import OptionRecommendation, DummyReporter
|
||||||
|
|
||||||
|
|
||||||
FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
FIELDS = ['all', 'author_sort', 'authors', 'comments',
|
||||||
@ -44,11 +45,12 @@ class CSV_XML(CatalogPlugin):
|
|||||||
"Default: '%default'\n"
|
"Default: '%default'\n"
|
||||||
"Applies to: CSV, XML output formats"))]
|
"Applies to: CSV, XML output formats"))]
|
||||||
|
|
||||||
def run(self, path_to_output, opts, db):
|
def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
||||||
from calibre.utils.logging import Log
|
from calibre.utils.logging import Log
|
||||||
|
|
||||||
log = Log()
|
log = Log()
|
||||||
self.fmt = path_to_output.rpartition('.')[2]
|
self.fmt = path_to_output.rpartition('.')[2]
|
||||||
|
self.notification = notification
|
||||||
|
|
||||||
if False and opts.verbose:
|
if False and opts.verbose:
|
||||||
log("%s:run" % self.name)
|
log("%s:run" % self.name)
|
||||||
@ -470,12 +472,6 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
# title dc:title in OPF metadata, NCX periodical
|
# title dc:title in OPF metadata, NCX periodical
|
||||||
# verbosity level of diagnostic printout
|
# verbosity level of diagnostic printout
|
||||||
|
|
||||||
class DummyReporter(object):
|
|
||||||
def __init__(self):
|
|
||||||
self.cancelRequested = False
|
|
||||||
|
|
||||||
def __call__(self, percent, msg=''):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def __init__(self, db, opts, plugin,
|
def __init__(self, db, opts, plugin,
|
||||||
generateForMobigen=False,
|
generateForMobigen=False,
|
||||||
@ -667,47 +663,47 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
# Methods
|
# Methods
|
||||||
def buildSources(self):
|
def buildSources(self):
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
if not self.booksByTitle:
|
if not self.booksByTitle:
|
||||||
self.fetchBooksByTitle()
|
self.fetchBooksByTitle()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.fetchBooksByAuthor()
|
self.fetchBooksByAuthor()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateHTMLDescriptions()
|
self.generateHTMLDescriptions()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateHTMLByTitle()
|
self.generateHTMLByTitle()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateHTMLByAuthor()
|
self.generateHTMLByAuthor()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateHTMLByTags()
|
self.generateHTMLByTags()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateThumbnails()
|
self.generateThumbnails()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateOPF()
|
self.generateOPF()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateNCXHeader()
|
self.generateNCXHeader()
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateNCXDescriptions("Descriptions")
|
self.generateNCXDescriptions("Descriptions")
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateNCXByTitle("Titles", single_article_per_section=False)
|
self.generateNCXByTitle("Titles", single_article_per_section=False)
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateNCXByAuthor("Authors", single_article_per_section=False)
|
self.generateNCXByAuthor("Authors", single_article_per_section=False)
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.generateNCXByTags("Genres")
|
self.generateNCXByTags("Genres")
|
||||||
|
|
||||||
if self.reporter.cancelRequested: return 1
|
if self.reporter.cancel_requested: return 1
|
||||||
self.writeNCX()
|
self.writeNCX()
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
@ -2523,8 +2519,7 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
self.reporter(self.progressInt, self.progressString)
|
self.reporter(self.progressInt, self.progressString)
|
||||||
return "%d%% %s" % (self.progressInt, self.progressString)
|
return "%d%% %s" % (self.progressInt, self.progressString)
|
||||||
|
|
||||||
def run(self, path_to_output, opts, db):
|
def run(self, path_to_output, opts, db, notification=DummyReporter()):
|
||||||
from calibre.ebooks.conversion.cli import main as ebook_convert
|
|
||||||
from calibre.utils.logging import Log
|
from calibre.utils.logging import Log
|
||||||
|
|
||||||
log = Log()
|
log = Log()
|
||||||
@ -2551,28 +2546,25 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
log(" %s: %s" % (key, opts_dict[key]))
|
log(" %s: %s" % (key, opts_dict[key]))
|
||||||
|
|
||||||
# Launch the Catalog builder
|
# Launch the Catalog builder
|
||||||
catalog = self.CatalogBuilder(db, opts, self)
|
catalog = self.CatalogBuilder(db, opts, self, notification=notification)
|
||||||
catalog.createDirectoryStructure()
|
catalog.createDirectoryStructure()
|
||||||
catalog.copyResources()
|
catalog.copyResources()
|
||||||
catalog.buildSources()
|
catalog.buildSources()
|
||||||
|
|
||||||
cmd_line_args = ['ebook-convert',
|
recommendations = []
|
||||||
os.path.join(catalog.catalogPath,
|
|
||||||
opts.basename + '.opf'),
|
|
||||||
path_to_output]
|
|
||||||
|
|
||||||
if opts.fmt == 'mobi':
|
if opts.fmt == 'mobi' and opts.output_profile.startswith("kindle"):
|
||||||
# options
|
recommendations.append(('output_profile', opts.output_profile,
|
||||||
if opts.output_profile.startswith("kindle"):
|
OptionRecommendation.HIGH))
|
||||||
cmd_line_args.append("--output-profile=%s" % str(opts.output_profile))
|
recommendations.append(('no_inline_toc', True,
|
||||||
cmd_line_args.append("--no-inline-toc")
|
OptionRecommendation.HIGH))
|
||||||
|
|
||||||
|
|
||||||
elif opts.fmt == 'epub':
|
|
||||||
pass
|
|
||||||
|
|
||||||
# Run ebook-convert
|
# Run ebook-convert
|
||||||
ebook_convert(args=cmd_line_args)
|
from calibre.ebooks.conversion.plumber import Plumber
|
||||||
|
plumber = Plumber(os.path.join(catalog.catalogPath,
|
||||||
|
opts.basename + '.opf'), path_to_output, log, report_progress=notification,
|
||||||
|
abort_after_input_dump=False)
|
||||||
|
plumber.merge_ui_recommendations(recommendations)
|
||||||
|
|
||||||
|
plumber.run()
|
||||||
|
|
||||||
return None
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user