mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
43e6b36e15
commit
e6d838ad45
@ -2,7 +2,6 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
|
|||||||
from calibre import browser
|
from calibre import browser
|
||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
|
|
||||||
|
|
||||||
class Bloomberg(BasicNewsRecipe):
|
class Bloomberg(BasicNewsRecipe):
|
||||||
@ -86,7 +85,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
else:
|
else:
|
||||||
data = json.loads(m2[0].text)
|
data = json.loads(m2[0].text)
|
||||||
data = data['props']['pageProps']['story']
|
data = data['props']['pageProps']['story']
|
||||||
|
|
||||||
title = '<h1>' + data['headline'] + '</h1>'
|
title = '<h1>' + data['headline'] + '</h1>'
|
||||||
|
|
||||||
cat = subhead = lede = auth = caption = ''
|
cat = subhead = lede = auth = caption = ''
|
||||||
@ -110,7 +109,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
if 'ledeImageUrl' in data:
|
if 'ledeImageUrl' in data:
|
||||||
if data['ledeImageUrl'] is not None:
|
if data['ledeImageUrl'] is not None:
|
||||||
lede = '<p><img src="{}">'.format(data['ledeImageUrl'])
|
lede = '<p><img src="{}">'.format(data['ledeImageUrl'])
|
||||||
|
|
||||||
if 'ledeDescription' in data:
|
if 'ledeDescription' in data:
|
||||||
if data['ledeDescription'] is not None:
|
if data['ledeDescription'] is not None:
|
||||||
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
|
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
|
||||||
@ -121,7 +120,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
if data['lede']['alt'] is not None:
|
if data['lede']['alt'] is not None:
|
||||||
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
|
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
|
||||||
|
|
||||||
if m:
|
if m:
|
||||||
body = data['body']
|
body = data['body']
|
||||||
else:
|
else:
|
||||||
body = ''
|
body = ''
|
||||||
@ -133,7 +132,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
|
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
|
||||||
if objects['type'] == 'paragraph' or 'heading':
|
if objects['type'] == 'paragraph' or 'heading':
|
||||||
body += '<p>'
|
body += '<p>'
|
||||||
if not 'content' in objects:
|
if 'content' not in objects:
|
||||||
continue
|
continue
|
||||||
for content in objects['content']:
|
for content in objects['content']:
|
||||||
if 'value' in content:
|
if 'value' in content:
|
||||||
|
@ -3,7 +3,6 @@ from calibre import browser
|
|||||||
from html5_parser import parse
|
from html5_parser import parse
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
import json
|
import json
|
||||||
import re
|
|
||||||
|
|
||||||
class Bloomberg(BasicNewsRecipe):
|
class Bloomberg(BasicNewsRecipe):
|
||||||
title = u'Bloomberg'
|
title = u'Bloomberg'
|
||||||
@ -14,7 +13,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
remove_attributes = ['style', 'height', 'width']
|
remove_attributes = ['style', 'height', 'width']
|
||||||
ignore_duplicate_articles = {'url', 'title'}
|
ignore_duplicate_articles = {'url', 'title'}
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
|
|
||||||
delay = 5 # seconds
|
delay = 5 # seconds
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
@ -116,7 +115,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
if data['lede']['alt'] is not None:
|
if data['lede']['alt'] is not None:
|
||||||
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
|
caption = '<span id="cap">' + data['lede']['alt'] + '</span>'
|
||||||
|
|
||||||
if m:
|
if m:
|
||||||
body = data['body']
|
body = data['body']
|
||||||
else:
|
else:
|
||||||
body = ''
|
body = ''
|
||||||
@ -128,7 +127,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
|
body += '<span id="cap">' + objects['data']['photo']['caption'] + '</span></p>'
|
||||||
if objects['type'] == 'paragraph' or 'heading': # lists are missed :(
|
if objects['type'] == 'paragraph' or 'heading': # lists are missed :(
|
||||||
body += '<p>'
|
body += '<p>'
|
||||||
if not 'content' in objects:
|
if 'content' not in objects:
|
||||||
continue
|
continue
|
||||||
for content in objects['content']:
|
for content in objects['content']:
|
||||||
if 'value' in content:
|
if 'value' in content:
|
||||||
|
@ -1251,11 +1251,15 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
filter_by = self.filter_categories_by
|
filter_by = self.filter_categories_by
|
||||||
|
|
||||||
if prefs['use_primary_find_in_search']:
|
if prefs['use_primary_find_in_search']:
|
||||||
final_equals = lambda x, y: primary_strcmp(x, y) == 0
|
def final_equals(x, y):
|
||||||
final_contains = primary_contains
|
return primary_strcmp(x, y) == 0
|
||||||
|
def final_contains(x, y):
|
||||||
|
return primary_contains(x, y)
|
||||||
else:
|
else:
|
||||||
final_equals = lambda x, y: strcmp(x, y) == 0
|
def final_equals(x, y):
|
||||||
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
|
return strcmp(x, y) == 0
|
||||||
|
def final_contains(filt, txt):
|
||||||
|
return contains(filt, icu_lower(txt))
|
||||||
|
|
||||||
for category in data.keys():
|
for category in data.keys():
|
||||||
if use_exact_match:
|
if use_exact_match:
|
||||||
@ -1853,11 +1857,15 @@ class TagsModel(QAbstractItemModel): # {{{
|
|||||||
start_path = []
|
start_path = []
|
||||||
|
|
||||||
if prefs['use_primary_find_in_search']:
|
if prefs['use_primary_find_in_search']:
|
||||||
final_equals = lambda x, y: primary_strcmp(x, y) == 0
|
def final_equals(x, y):
|
||||||
final_contains = primary_contains
|
return primary_strcmp(x, y) == 0
|
||||||
|
def final_contains(x, y):
|
||||||
|
return primary_contains(x, y)
|
||||||
else:
|
else:
|
||||||
final_equals = lambda x, y: strcmp(x, y) == 0
|
def final_equals(x, y):
|
||||||
final_contains = lambda filt, txt: contains(filt, icu_lower(txt))
|
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):
|
def process_tag(depth, tag_index, tag_item, start_path):
|
||||||
path = self.path_for_index(tag_index)
|
path = self.path_for_index(tag_index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user