diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe index 8b241b1dee..e22fa0cba6 100644 --- a/recipes/bloomberg-business-week.recipe +++ b/recipes/bloomberg-business-week.recipe @@ -2,7 +2,6 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes from calibre import browser from html5_parser import parse import json -import re class Bloomberg(BasicNewsRecipe): @@ -86,7 +85,7 @@ class Bloomberg(BasicNewsRecipe): else: data = json.loads(m2[0].text) data = data['props']['pageProps']['story'] - + title = '
'.format(data['ledeImageUrl'])
-
+
if 'ledeDescription' in data:
if data['ledeDescription'] is not None:
caption = '' + data['ledeDescription'] + ''
@@ -121,7 +120,7 @@ class Bloomberg(BasicNewsRecipe):
if data['lede']['alt'] is not None:
caption = '' + data['lede']['alt'] + ''
- if m:
+ if m:
body = data['body']
else:
body = ''
@@ -133,7 +132,7 @@ class Bloomberg(BasicNewsRecipe):
body += '' + objects['data']['photo']['caption'] + '
' - if not 'content' in objects: + if 'content' not in objects: continue for content in objects['content']: if 'value' in content: diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe index d24e2f9696..9162f4dd04 100644 --- a/recipes/bloomberg.recipe +++ b/recipes/bloomberg.recipe @@ -3,7 +3,6 @@ from calibre import browser from html5_parser import parse from calibre.ptempfile import PersistentTemporaryFile import json -import re class Bloomberg(BasicNewsRecipe): title = u'Bloomberg' @@ -14,7 +13,7 @@ class Bloomberg(BasicNewsRecipe): remove_attributes = ['style', 'height', 'width'] ignore_duplicate_articles = {'url', 'title'} resolve_internal_links = True - + delay = 5 # seconds extra_css = ''' @@ -116,7 +115,7 @@ class Bloomberg(BasicNewsRecipe): if data['lede']['alt'] is not None: caption = '' + data['lede']['alt'] + '' - if m: + if m: body = data['body'] else: body = '' @@ -128,7 +127,7 @@ class Bloomberg(BasicNewsRecipe): body += '' + objects['data']['photo']['caption'] + '
' if objects['type'] == 'paragraph' or 'heading': # lists are missed :( body += '' - if not 'content' in objects: + if 'content' not in objects: continue for content in objects['content']: if 'value' in content: diff --git a/src/calibre/gui2/tag_browser/model.py b/src/calibre/gui2/tag_browser/model.py index c86ea4494b..0f04d8ebd1 100644 --- a/src/calibre/gui2/tag_browser/model.py +++ b/src/calibre/gui2/tag_browser/model.py @@ -1251,11 +1251,15 @@ class TagsModel(QAbstractItemModel): # {{{ filter_by = self.filter_categories_by if prefs['use_primary_find_in_search']: - final_equals = lambda x, y: primary_strcmp(x, y) == 0 - final_contains = primary_contains + def final_equals(x, y): + return primary_strcmp(x, y) == 0 + def final_contains(x, y): + return primary_contains(x, y) else: - final_equals = lambda x, y: strcmp(x, y) == 0 - final_contains = lambda filt, txt: contains(filt, icu_lower(txt)) + def final_equals(x, y): + return strcmp(x, y) == 0 + def final_contains(filt, txt): + return contains(filt, icu_lower(txt)) for category in data.keys(): if use_exact_match: @@ -1853,11 +1857,15 @@ class TagsModel(QAbstractItemModel): # {{{ start_path = [] if prefs['use_primary_find_in_search']: - final_equals = lambda x, y: primary_strcmp(x, y) == 0 - final_contains = primary_contains + def final_equals(x, y): + return primary_strcmp(x, y) == 0 + def final_contains(x, y): + return primary_contains(x, y) else: - final_equals = lambda x, y: strcmp(x, y) == 0 - final_contains = lambda filt, txt: contains(filt, icu_lower(txt)) + def final_equals(x, y): + return strcmp(x, y) == 0 + def final_contains(filt, txt): + return contains(filt, icu_lower(txt)) def process_tag(depth, tag_index, tag_item, start_path): path = self.path_for_index(tag_index)