From 0bef23bc6f6775086373826e49b196c68d417dd8 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Sep 2011 18:18:24 -0600 Subject: [PATCH 1/2] Fix #840448 (Various bugs for past isbn button) --- src/calibre/gui2/metadata/basic_widgets.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py index 95b963efac..a349b8ca92 100644 --- a/src/calibre/gui2/metadata/basic_widgets.py +++ b/src/calibre/gui2/metadata/basic_widgets.py @@ -1227,7 +1227,9 @@ class IdentifiersEdit(QLineEdit): # {{{ val[k] = v ids = sorted(val.iteritems(), key=keygen) txt = ', '.join(['%s:%s'%(k.lower(), v) for k, v in ids]) - self.setText(txt.strip()) + # Use clear + insert instead of setText so that undo works + self.clear() + self.insert(txt.strip()) self.setCursorPosition(0) return property(fget=fget, fset=fset) @@ -1319,7 +1321,7 @@ class ISBNDialog(QDialog) : # {{{ self.line_edit.setStyleSheet('QLineEdit { background-color: %s }'%col) def text(self): - return unicode(self.line_edit.text()) + return check_isbn(unicode(self.line_edit.text())) # }}} From 91b769bd1fca0dbbf480b9d5e52b7c672d6a7a85 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 3 Sep 2011 20:05:28 -0600 Subject: [PATCH 2/2] Updated Counterpunch. Fixes #840717 (Fixed counterpunch.recipe) --- recipes/counterpunch.recipe | 40 +++++-------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/recipes/counterpunch.recipe b/recipes/counterpunch.recipe index 5fefc86cb4..abcee3cd8f 100644 --- a/recipes/counterpunch.recipe +++ b/recipes/counterpunch.recipe @@ -1,40 +1,10 @@ -import re -from lxml.html import parse from calibre.web.feeds.news import BasicNewsRecipe class Counterpunch(BasicNewsRecipe): - ''' - Parses counterpunch.com for articles - ''' - title = 'Counterpunch' - description = 'Daily political opinion from www.Counterpunch.com' - language = 'en' - __author__ = 'O. Emmerson' - keep_only_tags = [dict(name='td', attrs={'width': '522'})] - max_articles_per_feed = 10 + title = u'Counterpunch' + oldest_article = 7 + max_articles_per_feed = 100 + auto_cleanup = True - def parse_index(self): - feeds = [] - title, url = 'Counterpunch', 'http://www.counterpunch.com' - articles = self.parse_page(url) - if articles: - feeds.append((title, articles)) - return feeds - - def parse_page(self, url): - parsed_page = parse(url).getroot() - articles = [] - unwanted_text = re.compile('Website\ of\ the|I\ urge\ you|Subscribe\ now|DONATE|\@asis\.com|donation\ button|click\ over\ to\ our') - parsed_articles = [a for a in parsed_page.cssselect("html>body>table tr>td>p[class='style2']") if not unwanted_text.search(a.text_content())] - for art in parsed_articles: - try: - author = art.text - title = art.cssselect("a")[0].text + ' by {0}'.format(author) - art_url = 'http://www.counterpunch.com/' + art.cssselect("a")[0].attrib['href'] - articles.append({'title': title, 'url': art_url}) - except Exception as e: - e - #print('Handler Error: ', e, 'title :', a.text_content()) - pass - return articles + feeds = [(u'Counterpunch', u'http://www.counterpunch.org/category/article/feed/')]