Merge from trunk

This commit is contained in:
Sengian 2010-07-16 18:15:05 +02:00
commit 0c9dd29f6a
6 changed files with 75 additions and 22 deletions

View File

@ -0,0 +1,38 @@
from calibre.web.feeds.news import BasicNewsRecipe
class AdvancedUserRecipe1279258912(BasicNewsRecipe):
title = u'Orlando Sentinel'
oldest_article = 3
max_articles_per_feed = 100
feeds = [
(u'News', u'http://feeds.feedburner.com/orlandosentinel/news'),
(u'Opinion', u'http://feeds.feedburner.com/orlandosentinel/news/opinion'),
(u'Business', u'http://feeds.feedburner.com/orlandosentinel/business'),
(u'Technology', u'http://feeds.feedburner.com/orlandosentinel/technology'),
(u'Space and Science', u'http://feeds.feedburner.com/orlandosentinel/news/space'),
(u'Entertainment', u'http://feeds.feedburner.com/orlandosentinel/entertainment'),
(u'Life and Family', u'http://feeds.feedburner.com/orlandosentinel/features/lifestyle'),
]
__author__ = 'rty'
pubisher = 'OrlandoSentinel.com'
description = 'Orlando, Florida, Newspaper'
category = 'News, Orlando, Florida'
remove_javascript = True
use_embedded_content = False
no_stylesheets = True
language = 'en'
encoding = 'utf-8'
conversion_options = {'linearize_tables':True}
masthead_url = 'http://www.orlandosentinel.com/media/graphic/2009-07/46844851.gif'
keep_only_tags = [
dict(name='div', attrs={'class':'story'})
]
remove_tags = [
dict(name='div', attrs={'class':['articlerail','tools','comment-group','clearfix']}),
]
remove_tags_after = [
dict(name='p', attrs={'class':'copyright'}),
]

View File

@ -72,13 +72,13 @@ class Book(MetaInformation):
def thumbnail(self): def thumbnail(self):
return None return None
def smart_update(self, other): def smart_update(self, other, replace_metadata=False):
''' '''
Merge the information in C{other} into self. In case of conflicts, the information Merge the information in C{other} into self. In case of conflicts, the information
in C{other} takes precedence, unless the information in C{other} is NULL. in C{other} takes precedence, unless the information in C{other} is NULL.
''' '''
MetaInformation.smart_update(self, other, replace_tags=True) MetaInformation.smart_update(self, other, replace_metadata)
for attr in self.BOOK_ATTRS: for attr in self.BOOK_ATTRS:
if hasattr(other, attr): if hasattr(other, attr):
@ -116,7 +116,7 @@ class BookList(_BookList):
self.append(book) self.append(book)
return True return True
if replace_metadata: if replace_metadata:
self[b].smart_update(book) self[b].smart_update(book, replace_metadata=True)
return True return True
return False return False

View File

@ -268,10 +268,12 @@ class MetaInformation(object):
): ):
prints(x, getattr(self, x, 'None')) prints(x, getattr(self, x, 'None'))
def smart_update(self, mi, replace_tags=False): def smart_update(self, mi, replace_metadata=False):
''' '''
Merge the information in C{mi} into self. In case of conflicts, the information Merge the information in C{mi} into self. In case of conflicts, the
in C{mi} takes precedence, unless the information in mi is NULL. information in C{mi} takes precedence, unless the information in mi is
NULL. If replace_metadata is True, then the information in mi always
takes precedence.
''' '''
if mi.title and mi.title != _('Unknown'): if mi.title and mi.title != _('Unknown'):
self.title = mi.title self.title = mi.title
@ -285,13 +287,16 @@ class MetaInformation(object):
'cover', 'guide', 'book_producer', 'cover', 'guide', 'book_producer',
'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate', 'rights', 'timestamp', 'lccn', 'lcc', 'ddc', 'pubdate', 'rights',
'publication_type', 'uuid'): 'publication_type', 'uuid'):
if hasattr(mi, attr): if replace_metadata:
setattr(self, attr, getattr(mi, attr, 1.0 if \
attr == 'series_index' else None))
elif hasattr(mi, attr):
val = getattr(mi, attr) val = getattr(mi, attr)
if val is not None: if val is not None:
setattr(self, attr, val) setattr(self, attr, val)
if mi.tags: if mi.tags:
if replace_tags: if replace_metadata:
self.tags = mi.tags self.tags = mi.tags
else: else:
self.tags += mi.tags self.tags += mi.tags

View File

@ -28,9 +28,10 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
if not db or not book_id: if not db or not book_id:
self.button_box.addButton(QDialogButtonBox.Open) self.button_box.addButton(QDialogButtonBox.Open)
else: elif not self.select_format(db, book_id):
self.select_format(db, book_id) self.cancelled = True
return
self.cancelled = False
self.connect(self.button_box, SIGNAL('clicked(QAbstractButton*)'), self.button_clicked) self.connect(self.button_box, SIGNAL('clicked(QAbstractButton*)'), self.button_clicked)
self.connect(self.regex, SIGNAL('textChanged(QString)'), self.regex_valid) self.connect(self.regex, SIGNAL('textChanged(QString)'), self.regex_valid)
self.connect(self.test, SIGNAL('clicked()'), self.do_test) self.connect(self.test, SIGNAL('clicked()'), self.do_test)
@ -79,10 +80,12 @@ class RegexBuilder(QDialog, Ui_RegexBuilder):
format = d.format() format = d.format()
if not format: if not format:
error_dialog(self, _('No formats available'), _('Cannot build regex using the GUI builder without a book.')) error_dialog(self, _('No formats available'),
QDialog.reject() _('Cannot build regex using the GUI builder without a book.'),
else: show=True)
return False
self.open_book(db.format_abspath(book_id, format, index_is_id=True)) self.open_book(db.format_abspath(book_id, format, index_is_id=True))
return True
def open_book(self, pathtoebook): def open_book(self, pathtoebook):
self.iterator = EbookIterator(pathtoebook) self.iterator = EbookIterator(pathtoebook)
@ -117,6 +120,8 @@ class RegexEdit(QWidget, Ui_Edit):
def builder(self): def builder(self):
bld = RegexBuilder(self.db, self.book_id, self.edit.text(), self) bld = RegexBuilder(self.db, self.book_id, self.edit.text(), self)
if bld.cancelled:
return
if bld.exec_() == bld.Accepted: if bld.exec_() == bld.Accepted:
self.edit.setText(bld.regex.text()) self.edit.setText(bld.regex.text())

View File

@ -1439,7 +1439,8 @@ class DeviceMixin(object): # {{{
for book in booklist: for book in booklist:
if getattr(book, 'uuid', None) in self.db_book_uuid_cache: if getattr(book, 'uuid', None) in self.db_book_uuid_cache:
if update_metadata: if update_metadata:
book.smart_update(self.db_book_uuid_cache[book.uuid]) book.smart_update(self.db_book_uuid_cache[book.uuid],
replace_metadata=True)
book.in_library = True book.in_library = True
# ensure that the correct application_id is set # ensure that the correct application_id is set
book.application_id = \ book.application_id = \
@ -1454,12 +1455,14 @@ class DeviceMixin(object): # {{{
if getattr(book, 'application_id', None) in d['db_ids']: if getattr(book, 'application_id', None) in d['db_ids']:
book.in_library = True book.in_library = True
if update_metadata: if update_metadata:
book.smart_update(d['db_ids'][book.application_id]) book.smart_update(d['db_ids'][book.application_id],
replace_metadata=True)
continue continue
if book.db_id in d['db_ids']: if book.db_id in d['db_ids']:
book.in_library = True book.in_library = True
if update_metadata: if update_metadata:
book.smart_update(d['db_ids'][book.db_id]) book.smart_update(d['db_ids'][book.db_id],
replace_metadata=True)
continue continue
if book.authors: if book.authors:
# Compare against both author and author sort, because # Compare against both author and author sort, because
@ -1469,11 +1472,13 @@ class DeviceMixin(object): # {{{
if book_authors in d['authors']: if book_authors in d['authors']:
book.in_library = True book.in_library = True
if update_metadata: if update_metadata:
book.smart_update(d['authors'][book_authors]) book.smart_update(d['authors'][book_authors],
replace_metadata=True)
elif book_authors in d['author_sort']: elif book_authors in d['author_sort']:
book.in_library = True book.in_library = True
if update_metadata: if update_metadata:
book.smart_update(d['author_sort'][book_authors]) book.smart_update(d['author_sort'][book_authors],
replace_metadata=True)
# Set author_sort if it isn't already # Set author_sort if it isn't already
asort = getattr(book, 'author_sort', None) asort = getattr(book, 'author_sort', None)
if not asort and book.authors: if not asort and book.authors:

View File

@ -138,7 +138,7 @@ class LocationModel(QAbstractListModel): # {{{
class LocationView(QListView): class LocationView(QListView):
unmount_device = pyqtSignal() umount_device = pyqtSignal()
location_selected = pyqtSignal(object) location_selected = pyqtSignal(object)
def __init__(self, parent): def __init__(self, parent):
@ -174,7 +174,7 @@ class LocationView(QListView):
self.setMinimumWidth(400) self.setMinimumWidth(400)
def eject_clicked(self, *args): def eject_clicked(self, *args):
self.unmount_device.emit() self.umount_device.emit()
def count_changed(self, new_count): def count_changed(self, new_count):
self.model().count = new_count self.model().count = new_count