Merge from trunk

This commit is contained in:
Sengian 2010-11-01 22:52:40 +01:00
commit 6259647329

View File

@ -13,6 +13,7 @@ from calibre.utils.titlecase import titlecase
from calibre.utils.html2text import html2text from calibre.utils.html2text import html2text
from calibre.customize import Plugin from calibre.customize import Plugin
from calibre.ebooks.metadata.covers import check_for_cover from calibre.ebooks.metadata.covers import check_for_cover
from calibre.utils.html2text import html2text
metadata_config = None metadata_config = None
@ -51,6 +52,11 @@ class MetadataSource(Plugin): # {{{
#: member. #: member.
string_customization_help = None string_customization_help = None
#: Set this to true if your plugin returns HTML markup in comments.
#: Then if the user disables HTML, calibre will automagically convert
#: the HTML to Markdown.
has_html_comments = False
type = _('Metadata download') type = _('Metadata download')
def __call__(self, title, author, publisher, isbn, verbose, log=None, def __call__(self, title, author, publisher, isbn, verbose, log=None,
@ -85,6 +91,13 @@ class MetadataSource(Plugin): # {{{
mi.comments = html2text(mi.comments) mi.comments = html2text(mi.comments)
if not c.get('tags', True): if not c.get('tags', True):
mi.tags = [] mi.tags = []
if self.has_html_comments and mi.comments and \
c.get('textcomments', False):
try:
mi.comments = html2text(mi.comments)
except:
traceback.print_exc()
mi.comments = None
except Exception, e: except Exception, e:
self.exception = e self.exception = e
@ -138,17 +151,17 @@ class MetadataSource(Plugin): # {{{
setattr(w, '_'+x, cb) setattr(w, '_'+x, cb)
cb.setChecked(c.get(x, True)) cb.setChecked(c.get(x, True))
w._layout.addWidget(cb) w._layout.addWidget(cb)
#textconvert for comments
cb = QCheckBox(_('Convert comments from %s to text')%(self.name)) cb = QCheckBox(_('Convert comments downloaded from %s to plain text')%(self.name))
setattr(w, '_textconvert', cb) setattr(w, '_textcomments', cb)
cb.setChecked(c.get('textconvert', False)) cb.setChecked(c.get('textcomments', False))
w._layout.addWidget(cb) w._layout.addWidget(cb)
return w return w
def save_settings(self, w): def save_settings(self, w):
dl_settings = {} dl_settings = {}
for x in ('rating', 'tags', 'comments', 'textconvert'): for x in ('rating', 'tags', 'comments', 'textcomments'):
dl_settings[x] = getattr(w, '_'+x).isChecked() dl_settings[x] = getattr(w, '_'+x).isChecked()
c = self.config_store() c = self.config_store()
c.set(self.name, dl_settings) c.set(self.name, dl_settings)
@ -222,6 +235,8 @@ class Amazon(MetadataSource): # {{{
metadata_type = 'social' metadata_type = 'social'
description = _('Downloads social metadata from amazon.com') description = _('Downloads social metadata from amazon.com')
has_html_comments = True
def fetch(self): def fetch(self):
if not self.isbn: if not self.isbn:
return return