From a6840fb4625760631d9a321b0df958136718354e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 4 Jan 2021 22:15:31 +0530 Subject: [PATCH] pep8 --- recipes/wirtscafts_woche.recipe | 143 +++++++++--------- .../gui2/dialogs/saved_search_editor.py | 2 +- src/calibre/gui2/preferences/coloring.py | 2 +- 3 files changed, 77 insertions(+), 70 deletions(-) diff --git a/recipes/wirtscafts_woche.recipe b/recipes/wirtscafts_woche.recipe index 5f3fd389c6..4148d5ffa6 100644 --- a/recipes/wirtscafts_woche.recipe +++ b/recipes/wirtscafts_woche.recipe @@ -1,101 +1,108 @@ -__license__ = 'GPL v3' +__license__ = 'GPL v3' __copyright__ = '2013, Armin Geller' ## -## Written: May 2013 (new coding) -## Version: 4.4 -## Last update: 2020-12-29 -## - +# Written: May 2013 (new coding) +# Version: 4.4 +# Last update: 2020-12-29 +## ''' Fetch WirtschaftsWoche Online ''' +import re from calibre.web.feeds.news import BasicNewsRecipe + + class WirtschaftsWocheOnline(BasicNewsRecipe): - title = u'WirtschaftsWoche Online' - __author__ = 'Armin Geller' # Update AGE 2013-01-05; 2018-03-01 - description = u'German Online Portal of WirtschaftsWoche' - publisher = 'Verlagsgruppe Handelsblatt GmbH Redaktion WirtschaftsWoche Online' - category = 'business, economy, news, Germany' - publication_type = 'weekly magazine' - oldest_article = 7 + title = u'WirtschaftsWoche Online' + __author__ = 'Armin Geller' # Update AGE 2013-01-05; 2018-03-01 + description = u'German Online Portal of WirtschaftsWoche' + publisher = 'Verlagsgruppe Handelsblatt GmbH Redaktion WirtschaftsWoche Online' + category = 'business, economy, news, Germany' + publication_type = 'weekly magazine' + oldest_article = 7 max_articles_per_feed = 100 - - auto_cleanup = False - no_stylesheets = True - remove_javascript = True - remove_empty_feeds = True - timefmt = ' [%a, %d %b %Y]' - language = 'de_DE' - encoding = 'UTF-8' - cover_source = 'https://www.ikiosk.de/shop/epaper/wirtschaftswoche.html' - masthead_url = 'http://www.wiwo.de/images/wiwo_logo/5748610/1-formatOriginal.png' - - + + auto_cleanup = False + no_stylesheets = True + remove_javascript = True + remove_empty_feeds = True + timefmt = ' [%a, %d %b %Y]' + language = 'de_DE' + encoding = 'UTF-8' + cover_source = 'https://www.ikiosk.de/shop/epaper/wirtschaftswoche.html' + masthead_url = 'http://www.wiwo.de/images/wiwo_logo/5748610/1-formatOriginal.png' def get_cover_url(self): - cover_source_soup = self.index_to_soup(self.cover_source) - preview_image_div = cover_source_soup.find(attrs={'class':'gallery'}) - return preview_image_div.a.img['src'] - + cover_source_soup = self.index_to_soup(self.cover_source) + preview_image_div = cover_source_soup.find(attrs={'class': 'gallery'}) + return preview_image_div.a.img['src'] - extra_css = ''' + extra_css = ''' h1, h2 {font-size: 1.6em; text-align: left} .c-leadtext {font-size: 1em; font-style: italic; font-weight: normal} h4 {font-size: 1.3em;text-align: left} h5, h6, a {font-size: 1em;text-align: left} .c-metadata {font-size: .75em;text-align: left; font-style: italic} - ''' + ''' - keep_only_tags = [ - dict(name='div', attrs={'class':['o-article__element', - 'o-article__content c-richText', - 'o-article__content-element o-article__content-element--richtext' - ]}) - ] + keep_only_tags = [ + dict( + name='div', + attrs={ + 'class': [ + 'o-article__element', 'o-article__content c-richText', + 'o-article__content-element o-article__content-element--richtext' + ] + } + ) + ] remove_tags = [ - dict(name='div', attrs={'class':['c-pagination u-flex', - 'c-standard-article-teaser', - 'c-pagination u-flex ajaxify', - 'c-socialshare u-margin-xxl ', - 'c-list', #AGe 2020-12-29 - ]}) - ] + dict( + name='div', + attrs={ + 'class': [ + 'c-pagination u-flex', + 'c-standard-article-teaser', + 'c-pagination u-flex ajaxify', + 'c-socialshare u-margin-xxl ', + 'c-list', # AGe 2020-12-29 + ] + } + ) + ] feeds = [ - (u'Schlagzeilen', u'http://www.wiwo.de/contentexport/feed/rss/schlagzeilen'), - (u'Exklusiv', u'http://www.wiwo.de/contentexport/feed/rss/exklusiv'), -# (u'Themen', u'http://www.wiwo.de/contentexport/feed/rss/themen'), # AGE no print version - (u'Unternehmen', u'http://www.wiwo.de/contentexport/feed/rss/unternehmen'), - (u'Finanzen', u'http://www.wiwo.de/contentexport/feed/rss/finanzen'), - (u'Politik', u'http://www.wiwo.de/contentexport/feed/rss/politik'), - (u'Erfolg', u'http://www.wiwo.de/contentexport/feed/rss/erfolg'), - (u'Technologie', u'http://www.wiwo.de/contentexport/feed/rss/technologie'), -# (u'Green-WiWo', u'http://green.wiwo.de/feed/rss/') # AGE offline - ] + (u'Schlagzeilen', u'http://www.wiwo.de/contentexport/feed/rss/schlagzeilen'), + (u'Exklusiv', u'http://www.wiwo.de/contentexport/feed/rss/exklusiv'), + # (u'Themen', u'http://www.wiwo.de/contentexport/feed/rss/themen'), # AGE no print version + (u'Unternehmen', u'http://www.wiwo.de/contentexport/feed/rss/unternehmen'), + (u'Finanzen', u'http://www.wiwo.de/contentexport/feed/rss/finanzen'), + (u'Politik', u'http://www.wiwo.de/contentexport/feed/rss/politik'), + (u'Erfolg', u'http://www.wiwo.de/contentexport/feed/rss/erfolg'), + (u'Technologie', u'http://www.wiwo.de/contentexport/feed/rss/technologie'), + # (u'Green-WiWo', u'http://green.wiwo.de/feed/rss/') # AGE offline + ] -# For hegi # AGE new 2018-03-21 + # For hegi # AGE new 2018-03-21 # Add ': ' between headline part one and two # Wandel kostet Milliarden + ': ' + SUV und China sollen Audi wieder nach vorne bringen # https://www.wiwo.de/unternehmen/auto/wandel-kostet-milliarden-suv-und-china-sollen-audi-wieder-nach-vorne-bringen/21069566.html - # debug: - # input:

Wandel kostet Milliarden SUV und China sollen Audi wieder nach vorne bringen

- # parsed:

Wandel kostet Milliarden SUV und China sollen Audi wieder nach vorne bringen

- # processed:

Wandel kostet Milliarden SUV und China sollen Audi wieder nach vorne bringen

- # structure:

Wandel kostet Milliarden SUV und China sollen Audi wieder nach vorne bringen

- # epub:

Wandel kostet Milliarden SUV und China sollen Audi wieder nach vorne bringen

+ preprocess_regexps = [ + ( + re.compile( + r'(c-overline--article">[^>]*)()', re.DOTALL | re.IGNORECASE + ), lambda match: match.group(1) + ': ' + match.group(2) + ), + ] - preprocess_regexps = [ - (re.compile(r'(c-overline--article">[^>]*)()', re.DOTALL|re.IGNORECASE), lambda match: match.group(1) + ': ' + match.group(2)), - ] + # /For hegi -# /For hegi - -# one page n times url: https://www.wiwo.de/finanzen/geldanlage/bla-bla/21020646.html -# all in one page article url: https://www.wiwo.de/finanzen/geldanlage/bla-bla/21020646-all.html + # one page n times url: https://www.wiwo.de/finanzen/geldanlage/bla-bla/21020646.html + # all in one page article url: https://www.wiwo.de/finanzen/geldanlage/bla-bla/21020646-all.html def print_version(self, url): main, sep, rest = url.rpartition('.') diff --git a/src/calibre/gui2/dialogs/saved_search_editor.py b/src/calibre/gui2/dialogs/saved_search_editor.py index 96b4c00f26..21c1723ac3 100644 --- a/src/calibre/gui2/dialogs/saved_search_editor.py +++ b/src/calibre/gui2/dialogs/saved_search_editor.py @@ -192,7 +192,7 @@ class SavedSearchEditor(Dialog): self.current_index_changed(self.slist.currentItem()) def duplicate_msg(self, name): - return _('A saved search with the name {} already exists. Choose another name').format(name) + return _('A saved search with the name {} already exists. Choose another name').format(name) def validate_edit(self, name, expression): q = self.current_search_name diff --git a/src/calibre/gui2/preferences/coloring.py b/src/calibre/gui2/preferences/coloring.py index 61882f5c1a..1eceef4a5c 100644 --- a/src/calibre/gui2/preferences/coloring.py +++ b/src/calibre/gui2/preferences/coloring.py @@ -788,7 +788,7 @@ class RulesModel(QAbstractListModel): # {{{ if row >= 0 and row < len(self.rules): self.beginResetModel() t = self.rules.pop(row-delta) - self.rules.insert(row, t) # does append if row >= len(rules) + self.rules.insert(row, t) # does append if row >= len(rules) self.endResetModel() idx = self.index(row) return idx