From 0be7f76c1262365013b28d657b03cb88cce75b63 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 1 Jul 2008 14:32:52 -0700 Subject: [PATCH] Add recipe for The New Yorker --- src/calibre/gui2/dialogs/metadata_single.py | 2 +- src/calibre/gui2/main.py | 2 +- src/calibre/libunrar.py | 4 ++-- src/calibre/web/feeds/news.py | 9 +++++++++ src/calibre/web/feeds/recipes/__init__.py | 2 +- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/calibre/gui2/dialogs/metadata_single.py b/src/calibre/gui2/dialogs/metadata_single.py index f4fce00482..d4b9819af2 100644 --- a/src/calibre/gui2/dialogs/metadata_single.py +++ b/src/calibre/gui2/dialogs/metadata_single.py @@ -262,7 +262,7 @@ class MetadataSingleDialog(QDialog, Ui_MetadataSingleDialog): self.cover_changed = True self.cpixmap = pix except LibraryThingError, err: - error_dialog(self, _('Could not fetch cover'), _('Could not fetch cover.
')+str(err)).exec_() + error_dialog(self, _('Could not fetch cover'), _('Could not fetch cover.
')+unicode(err)).exec_() finally: self.fetch_cover_button.setEnabled(True) self.unsetCursor() diff --git a/src/calibre/gui2/main.py b/src/calibre/gui2/main.py index e6f0df58e6..01a7056d88 100644 --- a/src/calibre/gui2/main.py +++ b/src/calibre/gui2/main.py @@ -1112,7 +1112,7 @@ class Main(MainWindow, Ui_MainWindow): msg = ' '.join(msgs) print >>file, msg - def safe_unicode(self, arg): + def safe_unicode(arg): if not arg: arg = unicode(repr(arg)) if isinstance(arg, str): diff --git a/src/calibre/libunrar.py b/src/calibre/libunrar.py index 3348019bac..149b83d1b1 100644 --- a/src/calibre/libunrar.py +++ b/src/calibre/libunrar.py @@ -7,10 +7,10 @@ See ftp://ftp.rarlabs.com/rar/unrarsrc-3.7.5.tar.gz """ import os, ctypes from ctypes import Structure, c_char_p, c_uint, c_void_p, POINTER, \ - byref, c_wchar_p, CFUNCTYPE, c_int, c_long, c_char, c_wchar + byref, c_wchar_p, c_int, c_char, c_wchar from StringIO import StringIO -from calibre import iswindows, isosx, load_library +from calibre import iswindows, load_library _librar_name = 'libunrar' cdll = ctypes.cdll diff --git a/src/calibre/web/feeds/news.py b/src/calibre/web/feeds/news.py index dc9ed6527d..06ab13d913 100644 --- a/src/calibre/web/feeds/news.py +++ b/src/calibre/web/feeds/news.py @@ -9,6 +9,7 @@ __docformat__ = "restructuredtext en" import logging, os, cStringIO, time, traceback, re, urlparse from collections import defaultdict +from functools import partial from calibre import browser, __appname__, iswindows, LoggingInterface, strftime from calibre.ebooks.BeautifulSoup import BeautifulSoup, NavigableString, CData, Tag @@ -812,6 +813,14 @@ class BasicNewsRecipe(object, LoggingInterface): strings.append(item['alt']) return u''.join(strings) + @classmethod + def soup(cls, raw): + entity_replace = [(re.compile(ur'&(\S+?);'), partial(entity_to_unicode, + exceptions=[]))] + nmassage = list(BeautifulSoup.MARKUP_MASSAGE) + nmassage.extend(entity_replace) + return BeautifulSoup(raw, markupMassage=nmassage) + class Profile2Recipe(BasicNewsRecipe): ''' Used to migrate the old news Profiles to the new Recipes. Uses the settings diff --git a/src/calibre/web/feeds/recipes/__init__.py b/src/calibre/web/feeds/recipes/__init__.py index a531f990cd..62fc473488 100644 --- a/src/calibre/web/feeds/recipes/__init__.py +++ b/src/calibre/web/feeds/recipes/__init__.py @@ -8,7 +8,7 @@ recipes = [ 'newsweek', 'atlantic', 'economist', 'portfolio', 'nytimes', 'usatoday', 'outlook_india', 'bbc', 'greader', 'wsj', 'wired', 'globe_and_mail', 'smh', 'espn', 'business_week', - 'ars_technica', 'upi', + 'ars_technica', 'upi', 'new_yorker', ] import re, imp, inspect, time