From 263c6d72471eda2626b9af2edb848d3615b62d1a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 3 Dec 2008 23:58:28 -0800 Subject: [PATCH] Recipe for The London Review of Books (thanks to Darko Miletic) --- src/calibre/gui2/dialogs/scheduler.py | 1 + src/calibre/gui2/dialogs/scheduler.ui | 7 +++++ src/calibre/gui2/library.py | 4 +-- src/calibre/gui2/main.py | 17 ++++++++++-- src/calibre/translations/ru.po | 2 +- src/calibre/web/feeds/recipes/__init__.py | 2 +- src/calibre/web/feeds/recipes/lrb.py | 34 +++++++++++++++++++++++ src/calibre/web/fetch/simple.py | 7 +++-- 8 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 src/calibre/web/feeds/recipes/lrb.py diff --git a/src/calibre/gui2/dialogs/scheduler.py b/src/calibre/gui2/dialogs/scheduler.py index d220cbadcc..afb8c5d916 100644 --- a/src/calibre/gui2/dialogs/scheduler.py +++ b/src/calibre/gui2/dialogs/scheduler.py @@ -231,6 +231,7 @@ class SchedulerDialog(QDialog, Ui_Dialog): self.connect(self.download, SIGNAL('clicked()'), self.download_now) self.search.setFocus(Qt.OtherFocusReason) self.old_news.setValue(gconf['oldest_news']) + self.rnumber.setText(_('%d recipes')%self._model.rowCount(None)) def download_now(self): recipe = self._model.data(self.recipes.currentIndex(), Qt.UserRole) diff --git a/src/calibre/gui2/dialogs/scheduler.ui b/src/calibre/gui2/dialogs/scheduler.ui index e265915f47..818282da89 100644 --- a/src/calibre/gui2/dialogs/scheduler.ui +++ b/src/calibre/gui2/dialogs/scheduler.ui @@ -30,6 +30,13 @@ + + + + + + + diff --git a/src/calibre/gui2/library.py b/src/calibre/gui2/library.py index 45c8031510..664d3980cb 100644 --- a/src/calibre/gui2/library.py +++ b/src/calibre/gui2/library.py @@ -473,8 +473,8 @@ class BooksModel(QAbstractTableModel): if role in (Qt.DisplayRole, Qt.EditRole): ans = self.dc[self.column_map[index.column()]](index.row()) return NONE if ans is None else QVariant(ans) - elif role == Qt.TextAlignmentRole and self.column_map[index.column()] in ('size', 'timestamp'): - return QVariant(Qt.AlignCenter | Qt.AlignVCenter) + #elif role == Qt.TextAlignmentRole and self.column_map[index.column()] in ('size', 'timestamp'): + # return QVariant(Qt.AlignVCenter | Qt.AlignCenter) #elif role == Qt.ToolTipRole and index.isValid(): # if self.column_map[index.column()] in self.editable_cols: # return QVariant(_("Double click to edit me

")) diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index 261e25aa5c..6c04126939 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -99,12 +99,18 @@ class Main(MainWindow, Ui_MainWindow): self.donate_action = self.system_tray_menu.addAction(QIcon(':/images/donate.svg'), _('&Donate')) self.quit_action = QAction(QIcon(':/images/window-close.svg'), _('&Quit'), self) self.addAction(self.quit_action) + self.action_restart = QAction(_('&Restart'), self) + self.addAction(self.action_restart) self.system_tray_menu.addAction(self.quit_action) self.quit_action.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_Q)) + self.action_restart.setShortcut(QKeySequence(Qt.CTRL + Qt.Key_R)) self.system_tray_icon.setContextMenu(self.system_tray_menu) self.connect(self.quit_action, SIGNAL('triggered(bool)'), self.quit) self.connect(self.donate_action, SIGNAL('triggered(bool)'), self.donate) self.connect(self.restore_action, SIGNAL('triggered(bool)'), lambda c : self.show()) + def restart_app(c): + self.quit(None, restart=True) + self.connect(self.action_restart, SIGNAL('triggered(bool)'), restart_app) def sta(r): if r == QSystemTrayIcon.Trigger: self.hide() if self.isVisible() else self.show() @@ -1275,8 +1281,9 @@ in which you want to store your books files. Any existing books will be automati if self.device_connected: self.memory_view.write_settings() - def quit(self, checked): + def quit(self, checked, restart=False): if self.shutdown(): + self.restart_after_quit = restart QApplication.instance().quit() def donate(self): @@ -1411,7 +1418,13 @@ def main(args=sys.argv): sys.excepthook = main.unhandled_exception if len(args) > 1: main.add_filesystem_book(args[1]) - return app.exec_() + ret = app.exec_() + if getattr(main, 'restart_after_quit', False): + e = sys.executable if getattr(sys, 'froze', False) else sys.argv[0] + print 'Restarting with:', e, sys.argv + os.execvp(e, sys.argv) + else: + return ret return 0 diff --git a/src/calibre/translations/ru.po b/src/calibre/translations/ru.po index 64171f2855..fb58f3b7bb 100644 --- a/src/calibre/translations/ru.po +++ b/src/calibre/translations/ru.po @@ -129,7 +129,7 @@ msgid "" "threshold number of chapters were detected." msgstr "" "Максимальное количество ссылок вставленных в TOC. Для блокировки, выставите " -"0 . По умолчанию : %default. \n" +"0. По умолчанию: %default. " "Если будет вставлено в TOC значение ссылок больше, чем --toc-threshold, то " "некоторое количество глав будет обнаруженно." diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index 1c5f87f1a3..3eabaf532a 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -17,7 +17,7 @@ recipe_modules = [ 'blic', 'novosti', 'danas', 'vreme', 'times_online', 'the_scotsman', 'nytimes_sub', 'security_watch', 'cyberpresse', 'st_petersburg_times', 'clarin', 'financial_times', 'heise', 'le_monde', 'harpers', 'science_aas', - 'science_news', 'the_nation' + 'science_news', 'the_nation', 'lrb' ] import re, imp, inspect, time, os diff --git a/src/calibre/web/feeds/recipes/lrb.py b/src/calibre/web/feeds/recipes/lrb.py new file mode 100644 index 0000000000..a31e4a32e7 --- /dev/null +++ b/src/calibre/web/feeds/recipes/lrb.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python + +__license__ = 'GPL v3' +__copyright__ = '2008, Darko Miletic ' +''' +lrb.co.uk +''' + +from calibre.web.feeds.news import BasicNewsRecipe + +class LondonReviewOfBooks(BasicNewsRecipe): + title = u'London Review of Books' + __author__ = u'Darko Miletic' + description = u'Literary review publishing essay-length book reviews and topical articles on politics, literature, history, philosophy, science and the arts by leading writers and thinkers' + oldest_article = 7 + max_articles_per_feed = 100 + no_stylesheets = True + use_embedded_content = False + encoding = 'cp1252' + + remove_tags = [ + dict(name='div' , attrs={'id' :'otherarticles'}) + ,dict(name='div' , attrs={'class':'pagetools' }) + ,dict(name='div' , attrs={'id' :'mainmenu' }) + ,dict(name='div' , attrs={'id' :'precontent' }) + ,dict(name='div' , attrs={'class':'nocss' }) + ,dict(name='span', attrs={'class':'inlineright' }) + ] + + feeds = [(u'London Review of Books', u'http://www.lrb.co.uk/lrbrss.xml')] + + def print_version(self, url): + main, split, rest = url.rpartition('/') + return main + '/print/' + rest diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py index 8880de4baa..2a8b03a545 100644 --- a/src/calibre/web/fetch/simple.py +++ b/src/calibre/web/fetch/simple.py @@ -68,9 +68,10 @@ def save_soup(soup, target): class response(str): - def __init__(self, *args): - str.__init__(self, *args) - self.newurl = None + def __new__(cls, *args): + obj = super(response, cls).__new__(cls, *args) + obj.newurl = None + return obj class DummyLock(object):