diff --git a/recipes/1843.recipe b/recipes/1843.recipe index 4c5a016581..252f36d1c6 100644 --- a/recipes/1843.recipe +++ b/recipes/1843.recipe @@ -61,7 +61,7 @@ if use_archive: data = json.loads(raw) body = root.xpath('//body')[0] article = E(body, 'article') - E(article, 'div', data['flyTitle'] , style='color: red; font-size:small; font-weight:bold;') + E(article, 'div', data['flyTitle'], style='color: red; font-size:small; font-weight:bold;') E(article, 'h1', data['title'], title=safe_dict(data, 'url', 'canonical') or '') E(article, 'div', data['rubric'], style='font-style: italic; color:#202020;') try: @@ -96,7 +96,7 @@ else: for child in tuple(body): body.remove(child) article = E(body, 'article') - E(article, 'div', replace_entities(data['subheadline']) , style='color: red; font-size:small; font-weight:bold;') + E(article, 'div', replace_entities(data['subheadline']), style='color: red; font-size:small; font-weight:bold;') E(article, 'h1', replace_entities(data['headline'])) E(article, 'div', replace_entities(data['description']), style='font-style: italic; color:#202020;') if data['dateline'] is None: diff --git a/recipes/aktualne.cz.recipe b/recipes/aktualne.cz.recipe index ed1d647b8b..d1a8701769 100644 --- a/recipes/aktualne.cz.recipe +++ b/recipes/aktualne.cz.recipe @@ -32,7 +32,7 @@ class aktualneRecipe(BasicNewsRecipe): remove_attributes = [] remove_tags_before = dict(name='h1', attrs={'class': ['titulek-clanku']}) filter_regexps = [r'img.aktualne.centrum.cz'] - remove_tags = [dict(name='div', attrs={'id': ['social-bookmark']}), + remove_tags = [dict(name='div', attrs={'id': ['social-bookmark']}), dict(name='div', attrs={'class': ['box1', 'svazane-tagy']}), dict(name='div', attrs={'class': 'itemcomment id0'}), dict(name='div', attrs={'class': 'hlavicka'}), diff --git a/recipes/al_jazeera.recipe b/recipes/al_jazeera.recipe index 20817e7ca9..0e94bdc5dd 100644 --- a/recipes/al_jazeera.recipe +++ b/recipes/al_jazeera.recipe @@ -55,7 +55,7 @@ class AlJazeera(BasicNewsRecipe): u'http://www.aljazeera.com/xml/rss/all.xml')] def get_article_url(self, article): - artlurl = article.get('link', None) + artlurl = article.get('link', None) return artlurl def preprocess_html(self, soup): diff --git a/recipes/am730.recipe b/recipes/am730.recipe index bf8b3c1ded..9b87b779a4 100644 --- a/recipes/am730.recipe +++ b/recipes/am730.recipe @@ -58,7 +58,7 @@ class AM730(BasicNewsRecipe): articles = [] for aTag in soup.findAll('a',attrs={'class':'newsimglink'}): href = aTag.get('href',False) - if not href.encode('utf-8').startswith(url.encode('utf-8')) : + if not href.encode('utf-8').startswith(url.encode('utf-8')): continue # not in same section title = href.split('/')[-1].split('-')[0] diff --git a/recipes/barrons.recipe b/recipes/barrons.recipe index 898abe230b..007605fd0e 100644 --- a/recipes/barrons.recipe +++ b/recipes/barrons.recipe @@ -119,7 +119,7 @@ class barrons(BasicNewsRecipe): byl = articles.find(**prefixed_classes('BarronsTheme--byline--')) if byl: desc += self.tag_to_string(byl) - ttr = articles.find(**prefixed_classes('BarronsTheme--time-to-read--')) + ttr = articles.find(**prefixed_classes('BarronsTheme--time-to-read--')) if ttr: desc += self.tag_to_string(ttr) summ = articles.find(**prefixed_classes('BarronsTheme--summary--')) diff --git a/recipes/before_we_go.recipe b/recipes/before_we_go.recipe index 8423a69af2..cb0516083c 100644 --- a/recipes/before_we_go.recipe +++ b/recipes/before_we_go.recipe @@ -26,7 +26,7 @@ class BeforeWeGo(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'id': 'author-bio'}) # remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'nectar-scrolling-text font_size_10vh custom_color has-custom-divider'}), dict(name='span', attrs={'class': 'meta-comment-count'}), dict(name='p', attrs={'id': 'breadcrumbs'}) diff --git a/recipes/blesk.recipe b/recipes/blesk.recipe index 0b3380ea60..3a50ee8b8b 100644 --- a/recipes/blesk.recipe +++ b/recipes/blesk.recipe @@ -33,9 +33,9 @@ class bleskRecipe(BasicNewsRecipe): remove_attributes = [] remove_tags_before = dict(name='div', attrs={'id': ['boxContent']}) remove_tags_after = dict(name='div', attrs={'class': ['artAuthors']}) - remove_tags = [dict(name='div', attrs={'class': ['link_clanek']}), - dict(name='div', attrs={'id': ['partHeader']}), - dict(name='div', attrs={'id': ['top_bottom_box', 'lista_top']})] + remove_tags = [dict(name='div', attrs={'class': ['link_clanek']}), + dict(name='div', attrs={'id': ['partHeader']}), + dict(name='div', attrs={'id': ['top_bottom_box', 'lista_top']})] preprocess_regexps = [(re.compile(r'
')] diff --git a/recipes/calgary_herald.recipe b/recipes/calgary_herald.recipe index 01e2f0584d..741f507811 100644 --- a/recipes/calgary_herald.recipe +++ b/recipes/calgary_herald.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/cherta.recipe b/recipes/cherta.recipe index a821fbf195..62ae6a18dc 100644 --- a/recipes/cherta.recipe +++ b/recipes/cherta.recipe @@ -22,7 +22,7 @@ class Cherta(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class':'single-page__footer-info'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'single-content-link'}), dict(name='div', attrs={'class': 'single-page__footer-info_links clearfix'}), dict(name='div', attrs={'class': 'single-article-tags-wrapper'}) diff --git a/recipes/clarin.recipe b/recipes/clarin.recipe index 4138eca284..898a10a7f8 100644 --- a/recipes/clarin.recipe +++ b/recipes/clarin.recipe @@ -85,11 +85,11 @@ class Clarin(BasicNewsRecipe): self.oldest_article = float(d) keep_only_tags = [ - dict(name='p' , attrs={'class' : 'volanta'}), - dict(name='h1' , attrs={'id': 'title'}), - dict(name='div', attrs={'class' : 'bajada'}), - dict(name='div', attrs={'id' : 'galeria-trigger'}), - dict(name='div', attrs={'class' : 'body-nota'}) + dict(name='p', attrs={'class': 'volanta'}), + dict(name='h1', attrs={'id': 'title'}), + dict(name='div', attrs={'class': 'bajada'}), + dict(name='div', attrs={'id': 'galeria-trigger'}), + dict(name='div', attrs={'class': 'body-nota'}) ] diff --git a/recipes/coda_ru.recipe b/recipes/coda_ru.recipe index fb701b46e7..45147ceae6 100644 --- a/recipes/coda_ru.recipe +++ b/recipes/coda_ru.recipe @@ -22,7 +22,7 @@ class Coda(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'article'}) - remove_tags = [ + remove_tags = [ dict(name='li', attrs={'class': 'material-meta__type'}), dict(name='div', attrs={'class': 'more'}) ] diff --git a/recipes/computer_weekly.recipe b/recipes/computer_weekly.recipe index ed63d407d0..7aad0dde7f 100644 --- a/recipes/computer_weekly.recipe +++ b/recipes/computer_weekly.recipe @@ -25,7 +25,7 @@ class ComputerWeekly(BasicNewsRecipe): ('Financial services IT news', 'https://www.computerweekly.com/rss/Financial-services-IT-news.xml'), ('Public sector IT news', 'https://www.computerweekly.com/rss/Public-sector-IT-news.xml'), ('Enterprise software', 'https://www.computerweekly.com/rss/Enterprise-software.xml'), - ('SME IT news' , 'https://www.computerweekly.com/rss/SME-IT-news.xml'), + ('SME IT news', 'https://www.computerweekly.com/rss/SME-IT-news.xml'), ('Datacenter and cloud computing', 'https://www.computerweekly.com/rss/Datacentre-and-cloud-computing.xml'), ('Storage', 'https://www.computerweekly.com/rss/Storage.xml'), ('Information Management', 'https://www.computerweekly.com/rss/Information-management.xml'), diff --git a/recipes/contropiano.recipe b/recipes/contropiano.recipe index 26108dec66..31edae46b8 100644 --- a/recipes/contropiano.recipe +++ b/recipes/contropiano.recipe @@ -27,25 +27,18 @@ class AdvancedUserRecipe(BasicNewsRecipe): remove_tags_after = dict(name='p', attrs={'class': ['firma-redazione']}) feeds = [ - (u'Politica', - u'http://contropiano.org/news/politica-news/feed'), - (u'Internazionale', - u'http://contropiano.org/news/internazionale-news/feed'), - (u'Aggiornamenti in breve', u'http://contropiano.org/news/aggiornamenti-in-breve/feed'), - (u'Economia', - u'http://contropiano.org/news/news-economia/feed'), - (u'Ambiente', - u'http://contropiano.org/news/ambiente-news/feed'), - (u'Scienza', - u'http://contropiano.org/news/scienza-news/feed'), - (u'Cultura', - u'http://contropiano.org/news/cultura-news/feed'), + (u'Politica', u'http://contropiano.org/news/politica-news/feed'), + (u'Internazionale', u'http://contropiano.org/news/internazionale-news/feed'), + (u'Aggiornamenti in breve', u'http://contropiano.org/news/aggiornamenti-in-breve/feed'), + (u'Economia', u'http://contropiano.org/news/news-economia/feed'), + (u'Ambiente', u'http://contropiano.org/news/ambiente-news/feed'), + (u'Scienza', u'http://contropiano.org/news/scienza-news/feed'), + (u'Cultura', u'http://contropiano.org/news/cultura-news/feed'), (u'Locali', u'http://contropiano.org/regionali/feed'), (u'Lavoro', u'http://contropiano.org/news/lavoro-conflitto-news/feed'), - (u'Malapolizia', u'http://contropiano.org/news/malapolizia-news/feed'), + (u'Malapolizia', u'http://contropiano.org/news/malapolizia-news/feed'), (u'Interventi', u'http://contropiano.org/interventi/feed'), (u'Documenti', u'http://contropiano.org/documenti/feed'), (u'Vignette', u'http://contropiano.org/vignette/feed'), - (u'Altro', - u'http://contropiano.org/altro/feed') + (u'Altro', u'http://contropiano.org/altro/feed') ] diff --git a/recipes/cumhuriyet.recipe b/recipes/cumhuriyet.recipe index 5284d33082..e7c56aac36 100644 --- a/recipes/cumhuriyet.recipe +++ b/recipes/cumhuriyet.recipe @@ -31,8 +31,8 @@ class Cumhuriyet(BasicNewsRecipe): ] feeds = [ - ('Gundem', 'https://www.cumhuriyet.com.tr/rss/9999'), - ('Dünya', 'https://www.cumhuriyet.com.tr/rss/4'), + ('Gundem', 'https://www.cumhuriyet.com.tr/rss/9999'), + ('Dünya', 'https://www.cumhuriyet.com.tr/rss/4'), ('Türkiye', 'https://www.cumhuriyet.com.tr/rss/3'), ('Ekonomi', 'https://www.cumhuriyet.com.tr/rss/5'), ('Kultur Sanat', 'https://www.cumhuriyet.com.tr/rss/6'), diff --git a/recipes/degentenaar.recipe b/recipes/degentenaar.recipe index fd42704dad..ca62cf9bb6 100644 --- a/recipes/degentenaar.recipe +++ b/recipes/degentenaar.recipe @@ -63,7 +63,7 @@ class DeGentenaarOnline(BasicNewsRecipe): return url.replace('/Detail.aspx?articleid', '/PrintArticle.aspx?ArticleID') def get_article_url(self, article): - return article.get('guid', None) + return article.get('guid', None) def preprocess_html(self, soup): del soup.body['onload'] diff --git a/recipes/denik_referendum.recipe b/recipes/denik_referendum.recipe index 35fdd1248c..486524ab67 100644 --- a/recipes/denik_referendum.recipe +++ b/recipes/denik_referendum.recipe @@ -25,4 +25,4 @@ class denikReferendumRecipe(BasicNewsRecipe): remove_tags = [dict(name='div', attrs={'class': ['box boxLine', 'box noprint', 'box']}), dict(name='h3', attrs={'class': 'head alt'})] - keep_only_tags = [dict(name='div', attrs={'id': ['content']})] + keep_only_tags = [dict(name='div', attrs={'id': ['content']})] diff --git a/recipes/deutschland_funk.recipe b/recipes/deutschland_funk.recipe index 379fef1b59..d742b8fd41 100644 --- a/recipes/deutschland_funk.recipe +++ b/recipes/deutschland_funk.recipe @@ -29,7 +29,7 @@ class AdvancedUserRecipe1432200863(BasicNewsRecipe): max_articles_per_feed = 100 auto_cleanup = False - extra_css = ''' + extra_css = ''' h1, h2 {font-size: 1.6em; text-align: left} .article-header-description {font-size: 1em; font-style: italic; font-weight: normal;margin-bottom: 1em} .b-image-figure, .caption-figure.is-left, .b-image-credits {font-size: .75em; font-weight: normal;margin-bottom: .75em} diff --git a/recipes/dev_ua.recipe b/recipes/dev_ua.recipe index d9730454ea..49e32138d4 100644 --- a/recipes/dev_ua.recipe +++ b/recipes/dev_ua.recipe @@ -24,7 +24,7 @@ class WiComix(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'article__body'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'article__reference article__reference_header'}), dict(name='div', attrs={'class': 'my-lg-5'}), dict(name='div', attrs={'class': 'video '}), diff --git a/recipes/echo_moskvy.recipe b/recipes/echo_moskvy.recipe index 303ca03858..1f2600f77d 100644 --- a/recipes/echo_moskvy.recipe +++ b/recipes/echo_moskvy.recipe @@ -22,7 +22,7 @@ class EchoMsk(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='span', attrs={'class': 'sc-7b4cbb79-0 guzUFC'}), dict(name='div', attrs={'class': 'sc-f94c4ef5-0 frGiYu'}), dict(name='div', attrs={'class': 'sc-f94c4ef5-0 frGiYu'}) diff --git a/recipes/economist_espresso.recipe b/recipes/economist_espresso.recipe index 6766cdae82..ed94653431 100644 --- a/recipes/economist_espresso.recipe +++ b/recipes/economist_espresso.recipe @@ -57,7 +57,7 @@ def load_article_from_json(raw, root): data = json.loads(raw) body = root.xpath('//body')[0] article = E(body, 'article') - E(article, 'div', data['flyTitle'] , style='color: red; font-size:small; font-weight:bold;') + E(article, 'div', data['flyTitle'], style='color: red; font-size:small; font-weight:bold;') E(article, 'h1', data['title'], title=safe_dict(data, 'url', 'canonical') or '') E(article, 'div', data['rubric'], style='font-style: italic; color:#202020;') E(article, 'div', data['byline'], style='font-style: italic; color:#202020;') diff --git a/recipes/edmonton_journal.recipe b/recipes/edmonton_journal.recipe index 55be31438a..ade2091412 100644 --- a/recipes/edmonton_journal.recipe +++ b/recipes/edmonton_journal.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/el_pais.recipe b/recipes/el_pais.recipe index b2d1bd90a5..d1a929c506 100644 --- a/recipes/el_pais.recipe +++ b/recipes/el_pais.recipe @@ -114,7 +114,7 @@ div.a_md_a {text-align: center; text-transform: uppercase; font-size: .8rem;} from datetime import date cover = ('https://srv00.epimg.net/pdf/elpais/snapshot/' + str(date.today().year) + '/' + date.today().strftime('%m') + '/elpais/' + - str(date.today().year) + date.today().strftime('%m') + date.today().strftime('%d') + 'Big.jpg') + str(date.today().year) + date.today().strftime('%m') + date.today().strftime('%d') + 'Big.jpg') br = BasicNewsRecipe.get_browser(self) try: br.open(cover) diff --git a/recipes/epoch_times.recipe b/recipes/epoch_times.recipe index 26998ea5e3..576676a199 100644 --- a/recipes/epoch_times.recipe +++ b/recipes/epoch_times.recipe @@ -13,7 +13,7 @@ class EpochTimes(BasicNewsRecipe): max_articles_per_feed = 20 ignore_duplicate_articles = {'url'} remove_attributes = ['height', 'width', 'style'] - remove_empty_feeds = True + remove_empty_feeds = True no_stylesheets = True resolve_internal_links = True masthead_url = 'https://epochtimes-ny.newsmemory.com/eeLayout/epochtimes/1.0.a/images/webapp/banner.png' diff --git a/recipes/fastcompany.recipe b/recipes/fastcompany.recipe index aeb295b973..84af8ec54c 100644 --- a/recipes/fastcompany.recipe +++ b/recipes/fastcompany.recipe @@ -45,7 +45,7 @@ class FastCompany(BasicNewsRecipe): feeds = [(u'All News', u'http://feeds.feedburner.com/fastcompany/headlines')] def get_article_url(self, article): - return article.get('guid', None) + return article.get('guid', None) def preprocess_html(self, soup): soup.html['xml:lang'] = self.lang diff --git a/recipes/faz_net.recipe b/recipes/faz_net.recipe index 2a785e364a..e1ac34f1b4 100644 --- a/recipes/faz_net.recipe +++ b/recipes/faz_net.recipe @@ -93,24 +93,24 @@ class FazNet(BasicNewsRecipe): # original by Armin Geller # overhaul to deal with changes in the faz.net websites - title = 'FAZ.NET' - __author__ = 'Unknown' - description = 'Frankfurter Allgemeine Zeitung' - publisher = 'Frankfurter Allgemeine Zeitung GmbH' - category = 'news, politics, Germany' - cover_url = 'https://upload.wikimedia.org/wikipedia/commons/7/72/Frankfurter_Allgemeine_logo.svg' - encoding = 'utf-8' - language = 'de' - ignore_duplicate_articles = {'title', 'url'} - max_articles_per_feed = 30 - no_stylesheets = True - remove_javascript = True - scale_news_images = (10,100) - delay = 1 + title = 'FAZ.NET' + __author__ = 'Unknown' + description = 'Frankfurter Allgemeine Zeitung' + publisher = 'Frankfurter Allgemeine Zeitung GmbH' + category = 'news, politics, Germany' + cover_url = 'https://upload.wikimedia.org/wikipedia/commons/7/72/Frankfurter_Allgemeine_logo.svg' + encoding = 'utf-8' + language = 'de' + ignore_duplicate_articles = {'title', 'url'} + max_articles_per_feed = 30 + no_stylesheets = True + remove_javascript = True + scale_news_images = (10,100) + delay = 1 test_feed = 'https://www.faz.net/rss/aktuell/feuilleton/kunst-und-architektur/berlinische-galerie-zeigt-edvard-munch-die-ganze-gefuehlsskala-des-lebens-19180631.html?printPagedArticle=true#pageIndex_2' - extra_css = ''' + extra_css = ''' .header-title,.scrolly-title {font-size: 1.5em; font-weight:bold; text-align:left;} .quote {font-size: 1.5em; font-weight:bold; text-align:center;} .author {font-size: 0.7em; font-weight:bold; text-align:center; display:block; diff --git a/recipes/fluter_de.recipe b/recipes/fluter_de.recipe index e8eb764f46..525ce1706f 100644 --- a/recipes/fluter_de.recipe +++ b/recipes/fluter_de.recipe @@ -26,7 +26,7 @@ class AdvancedUserRecipe1313693926(BasicNewsRecipe): max_articles_per_feed = 50 auto_cleanup = False - feeds = [ + feeds = [ (u'Inhalt:', u'https://www.fluter.de/rss.xml') ] @@ -38,6 +38,6 @@ class AdvancedUserRecipe1313693926(BasicNewsRecipe): dict(name='h2', attrs={'class':'element-invisible'}) ] - extra_css = ''' + extra_css = ''' .field-group-format, .group_additional_info, .additional-info {display: inline-block; min-width: 8rem; text-align: center} ''' diff --git a/recipes/folhadesaopaulo_sub.recipe b/recipes/folhadesaopaulo_sub.recipe index eed2870645..1dc33272e2 100644 --- a/recipes/folhadesaopaulo_sub.recipe +++ b/recipes/folhadesaopaulo_sub.recipe @@ -125,7 +125,7 @@ img { background: none !important; float: none; margin: 0px; } break elif strpost.startswith(' post: ', post) diff --git a/recipes/footballua.recipe b/recipes/footballua.recipe index fbcb7ba362..649bc88cca 100644 --- a/recipes/footballua.recipe +++ b/recipes/footballua.recipe @@ -25,7 +25,7 @@ class FootballUA(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'bottom-info'}), dict(name='div', attrs={'class': 'social-buttons'}) ] diff --git a/recipes/foreignaffairs.recipe b/recipes/foreignaffairs.recipe index 3d049036a8..71a319d52a 100644 --- a/recipes/foreignaffairs.recipe +++ b/recipes/foreignaffairs.recipe @@ -188,7 +188,7 @@ class ForeignAffairsRecipe(BasicNewsRecipe): for by in soup.findAll(**classes('topper__byline topper__date font-style-italic')): by.name = 'div' for img in soup.find_all('img', attrs={'srcset': True}): - img['src'] = re.sub(r'_webp_small_\dx', '_webp_large_1x',img['srcset'].split()[0]) + img['src'] = re.sub(r'_webp_small_\dx', '_webp_large_1x', img['srcset'].split()[0]) return soup def get_browser(self): diff --git a/recipes/gagadget_de.recipe b/recipes/gagadget_de.recipe index 0fdc24ee06..3c19ccf8e5 100644 --- a/recipes/gagadget_de.recipe +++ b/recipes/gagadget_de.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_en.recipe b/recipes/gagadget_en.recipe index 7ae5110f9f..5d29a797bc 100644 --- a/recipes/gagadget_en.recipe +++ b/recipes/gagadget_en.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_es.recipe b/recipes/gagadget_es.recipe index 47a16ce9c2..e50af1e27d 100644 --- a/recipes/gagadget_es.recipe +++ b/recipes/gagadget_es.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_fr.recipe b/recipes/gagadget_fr.recipe index 535d5b2cff..e82efc797e 100644 --- a/recipes/gagadget_fr.recipe +++ b/recipes/gagadget_fr.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_it.recipe b/recipes/gagadget_it.recipe index 45c001e9c0..58325232ba 100644 --- a/recipes/gagadget_it.recipe +++ b/recipes/gagadget_it.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_nb.recipe b/recipes/gagadget_nb.recipe index 19dc15a06c..d3365e34b4 100644 --- a/recipes/gagadget_nb.recipe +++ b/recipes/gagadget_nb.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_nl.recipe b/recipes/gagadget_nl.recipe index 73709506dc..01e446f209 100644 --- a/recipes/gagadget_nl.recipe +++ b/recipes/gagadget_nl.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_ru.recipe b/recipes/gagadget_ru.recipe index 74405b3672..524b470b14 100644 --- a/recipes/gagadget_ru.recipe +++ b/recipes/gagadget_ru.recipe @@ -33,7 +33,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only # remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - # remove_tags = [ + # remove_tags = [ # dict(name='div', attrs={'class': 'footer-content'}), # ] diff --git a/recipes/gagadget_ua.recipe b/recipes/gagadget_ua.recipe index 06858d7454..14ba4461f3 100644 --- a/recipes/gagadget_ua.recipe +++ b/recipes/gagadget_ua.recipe @@ -32,7 +32,7 @@ class Gagadget(BasicNewsRecipe): # Ukrainian version only remove_tags_after = dict(name='div', attrs={'class': 'top20 bottom20 post-links'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'footer-content'}), ] diff --git a/recipes/gazetaua_ru.recipe b/recipes/gazetaua_ru.recipe index beecf13bff..f3a3c22476 100644 --- a/recipes/gazetaua_ru.recipe +++ b/recipes/gazetaua_ru.recipe @@ -23,7 +23,7 @@ class GazetaUA(BasicNewsRecipe): remove_tags_after = dict(name='section', attrs={'class': 'article-content clearfix'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'mt5'}), dict(name='div', attrs={'class': 'interview-block'}), dict(name='p', attrs={'id': 'mce_0'}), diff --git a/recipes/gazetaua_ua.recipe b/recipes/gazetaua_ua.recipe index 3899ac96bf..02a50c9a59 100644 --- a/recipes/gazetaua_ua.recipe +++ b/recipes/gazetaua_ua.recipe @@ -23,7 +23,7 @@ class GazetaUA(BasicNewsRecipe): remove_tags_after = dict(name='section', attrs={'class': 'article-content clearfix'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'mt5'}), dict(name='div', attrs={'class': 'interview-block'}), dict(name='p', attrs={'id': 'mce_0'}), diff --git a/recipes/geekcity.recipe b/recipes/geekcity.recipe index b62bfb4efa..4e8aa97845 100644 --- a/recipes/geekcity.recipe +++ b/recipes/geekcity.recipe @@ -21,7 +21,7 @@ class GeekCity(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'term-badges floated'}), dict(name='div', attrs={'class': 'post-meta single-post-meta'}), dict(name='div', attrs={'class': 'post-share single-post-share top-share clearfix style-1'}), diff --git a/recipes/gorky.recipe b/recipes/gorky.recipe index c82fd41b69..8bc7988cc4 100644 --- a/recipes/gorky.recipe +++ b/recipes/gorky.recipe @@ -22,7 +22,7 @@ class Gorky(BasicNewsRecipe): remove_tags_after = dict(name='footer') - remove_tags = [ + remove_tags = [ dict(name='footer'), dict(name='nav', attrs={'class': 'navbar'}), dict(name='div', attrs={'class': 'hide'}), diff --git a/recipes/hindustan.recipe b/recipes/hindustan.recipe index 8ca4efe0bd..262ef267f1 100644 --- a/recipes/hindustan.recipe +++ b/recipes/hindustan.recipe @@ -28,7 +28,7 @@ class LiveHindustan(BasicNewsRecipe): remove_tags_after = [classes('stry-bdy')] feeds = [ - ('प्रमुख खबरें' ,'https://feed.livehindustan.com/rss/3127'), + ('प्रमुख खबरें', 'https://feed.livehindustan.com/rss/3127'), ('देश', 'https://feed.livehindustan.com/rss/4911'), ('विदेश', 'https://feed.livehindustan.com/rss/4913'), ('ओपिनियन', 'https://feed.livehindustan.com/rss/5165'), diff --git a/recipes/idnes.recipe b/recipes/idnes.recipe index cca9499fb1..3375979f0a 100644 --- a/recipes/idnes.recipe +++ b/recipes/idnes.recipe @@ -26,9 +26,8 @@ class iHeuteRecipe(BasicNewsRecipe): no_stylesheets = True remove_attributes = ['width', 'height'] - remove_tags = [dict(name='div', attrs={'id': ['zooming']}), - dict(name='div', attrs={ - 'class': ['related', 'mapa-wrapper']}), + remove_tags = [dict(name='div', attrs={'id': ['zooming']}), + dict(name='div', attrs={'class': ['related', 'mapa-wrapper']}), dict(name='table', attrs={'id': ['opener-img', 'portal']}), dict(name='table', attrs={'class': ['video-16ku9']})] remove_tags_after = [ diff --git a/recipes/il_fatto.recipe b/recipes/il_fatto.recipe index 66af6e3d2f..800749978d 100644 --- a/recipes/il_fatto.recipe +++ b/recipes/il_fatto.recipe @@ -10,29 +10,21 @@ class AdvancedUserRecipe1286477122(BasicNewsRecipe): __author__ = 'egilh' feeds = [ - (u'Politica & Palazzo', - u'http://www.ilfattoquotidiano.it/category/politica-palazzo/feed/'), - (u'Giustizia & impunit\xe0', - u'http://www.ilfattoquotidiano.it/category/giustizia-impunita/feed/'), - (u'Media & regime', u'http://www.ilfattoquotidiano.it/category/media-regime/feed/'), - (u'Economia & Lobby', - u'http://www.ilfattoquotidiano.it/category/economia-lobby/feed/'), - (u'Lavoro & precari', - u'http://www.ilfattoquotidiano.it/category/lavoro-precari/feed/'), - (u'Ambiente & Veleni', - u'http://www.ilfattoquotidiano.it/category/ambiente-veleni/feed/'), - (u'Sport & miliardi', - u'http://www.ilfattoquotidiano.it/category/sport-miliardi/feed/'), + (u'Politica & Palazzo', u'http://www.ilfattoquotidiano.it/category/politica-palazzo/feed/'), + (u'Giustizia & impunit\xe0', u'http://www.ilfattoquotidiano.it/category/giustizia-impunita/feed/'), + (u'Media & regime', u'http://www.ilfattoquotidiano.it/category/media-regime/feed/'), + (u'Economia & Lobby', u'http://www.ilfattoquotidiano.it/category/economia-lobby/feed/'), + (u'Lavoro & precari', u'http://www.ilfattoquotidiano.it/category/lavoro-precari/feed/'), + (u'Ambiente & Veleni', u'http://www.ilfattoquotidiano.it/category/ambiente-veleni/feed/'), + (u'Sport & miliardi', u'http://www.ilfattoquotidiano.it/category/sport-miliardi/feed/'), (u'Cronaca', u'http://www.ilfattoquotidiano.it/category/cronaca/feed/'), (u'Mondo', u'http://www.ilfattoquotidiano.it/category/mondo/feed/'), - (u'Societ\xe0', u'http://www.ilfattoquotidiano.it/category/societa/feed/'), + (u'Societ\xe0', u'http://www.ilfattoquotidiano.it/category/societa/feed/'), (u'Scuola', u'http://www.ilfattoquotidiano.it/category/scuola/feed/'), (u'Tecno', u'http://www.ilfattoquotidiano.it/category/tecno/feed/'), (u'Terza pagina', u'http://www.ilfattoquotidiano.it/category/terza-pagina/feed/'), - (u'Piacere quotidiano', - u'http://www.ilfattoquotidiano.it/category/piacere-quotidiano/feed/'), - (u'Cervelli in fuga', - u'http://www.ilfattoquotidiano.it/category/cervelli-in-fuga/feed/'), + (u'Piacere quotidiano', u'http://www.ilfattoquotidiano.it/category/piacere-quotidiano/feed/'), + (u'Cervelli in fuga', u'http://www.ilfattoquotidiano.it/category/cervelli-in-fuga/feed/'), (u'Documentati!', u'http://www.ilfattoquotidiano.it/category/documentati/feed/'), (u'Misfatto', u'http://www.ilfattoquotidiano.it/category/misfatto/feed/') ] diff --git a/recipes/il_messaggero.recipe b/recipes/il_messaggero.recipe index 43b67cf76a..7225877c54 100644 --- a/recipes/il_messaggero.recipe +++ b/recipes/il_messaggero.recipe @@ -36,7 +36,7 @@ class IlMessaggero(BasicNewsRecipe): dict(name='h2', attrs={ 'class': ['sottotitLettura', 'grigio16']}), dict(name='span', attrs={'class': 'testoArticoloG'}), - dict(name='div', attrs={'id': 'testodim'}) + dict(name='div', attrs={'id': 'testodim'}) ] def get_cover_url(self): diff --git a/recipes/ilmanifesto.recipe b/recipes/ilmanifesto.recipe index e39ce9bf74..5f252204a1 100644 --- a/recipes/ilmanifesto.recipe +++ b/recipes/ilmanifesto.recipe @@ -34,7 +34,7 @@ class IlManifesto(BasicNewsRecipe): startSoup = self.index_to_soup(startUrl) lastEdition = startSoup.findAll('div', id='accordion_inedicola')[ 1].find('a')['href'] - del (startSoup) + del startSoup self.manifesto_index = MANIFESTO_BASEURL + lastEdition urlsplit = lastEdition.split('/') self.manifesto_datestr = urlsplit[-1] @@ -106,5 +106,5 @@ class IlManifesto(BasicNewsRecipe): summary = sommNode template = "%(title)s

%(title)s

%(subtitle)s

%(author)s

%(summary)s
%(content)s
" # noqa: E501 - del (bs) + del bs return template % dict(title=title, subtitle=subtitle, author=author, summary=summary, content=content) diff --git a/recipes/india_today.recipe b/recipes/india_today.recipe index d5b1594e07..0b6f15ef91 100644 --- a/recipes/india_today.recipe +++ b/recipes/india_today.recipe @@ -115,6 +115,6 @@ class IndiaToday(BasicNewsRecipe): imagecap = '
' + data['image_caption'] + '
' html = '' + slug + '

' + title + '

\n' + desc + '
'\ - + author + ' ' + city + ' UPDATED: ' + date + '
\n' + image + imagecap + body\ + + author + ' ' + city + ' UPDATED: ' + date + '
\n' + image + imagecap + body\ + '' return html diff --git a/recipes/irish_times.recipe b/recipes/irish_times.recipe index 90cbdd1a87..9f0637435e 100644 --- a/recipes/irish_times.recipe +++ b/recipes/irish_times.recipe @@ -121,7 +121,7 @@ class IrishTimes(BasicNewsRecipe): 'sec-fetch-site': 'same-origin', 'sec-fetch-dest': 'empty', 'sec-fetch-mode': 'cors', - }, data=urlencode({'username': self.username, 'password': self.password, 'deviceid':deviceid, 'persistent':'on', 'rid': ''})) + }, data=urlencode({'username': self.username, 'password': self.password, 'deviceid':deviceid, 'persistent':'on', 'rid': ''})) r = br.open(rq) raw = r.read() diff --git a/recipes/jot_down.recipe b/recipes/jot_down.recipe index b1b9deccd7..b078edd90c 100644 --- a/recipes/jot_down.recipe +++ b/recipes/jot_down.recipe @@ -47,7 +47,7 @@ class jotdown(BasicNewsRecipe): dict(name='div', attrs={'id':'respond'}) ] - remove_tags_after = dict(name='div' , attrs={'id':'respond'}) + remove_tags_after = dict(name='div', attrs={'id':'respond'}) preprocess_regexps = [ # To change the small size of the text diff --git a/recipes/kompiutierra.recipe b/recipes/kompiutierra.recipe index d34a60b365..6e2064ddb1 100644 --- a/recipes/kompiutierra.recipe +++ b/recipes/kompiutierra.recipe @@ -26,7 +26,7 @@ class Computerra(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='ul', attrs={'class': 'breadcrumbs'}), dict(name='div', attrs={'class': 'post-info__likes post-info-likes'}), dict(name='div', attrs={'class': 'cta-row'}), diff --git a/recipes/kudy_z_nudy.recipe b/recipes/kudy_z_nudy.recipe index 963d3185a9..29aa54e224 100644 --- a/recipes/kudy_z_nudy.recipe +++ b/recipes/kudy_z_nudy.recipe @@ -30,7 +30,7 @@ class kudyznudyRecipe(BasicNewsRecipe): name='div', attrs={'class': ['C_WholeContentPadding']}) remove_tags_after = dict( name='div', attrs={'class': ['SurroundingsContainer']}) - remove_tags = [dict(name='div', attrs={ + remove_tags = [dict(name='div', attrs={ 'class': ['Details', 'buttons', 'SurroundingsContainer', 'breadcrumb']})] keep_only_tags = [] diff --git a/recipes/la_jornada.recipe b/recipes/la_jornada.recipe index ea13c1cf7d..355d6a6017 100644 --- a/recipes/la_jornada.recipe +++ b/recipes/la_jornada.recipe @@ -111,7 +111,7 @@ class LaJornada_mx(BasicNewsRecipe): def get_article_url(self, article): # Get link to original article URL - rurl = article.get('guid', None) + rurl = article.get('guid', None) if not rurl: # Use the "link" attribute as failover return article.get('link', None) diff --git a/recipes/libertad_digital.recipe b/recipes/libertad_digital.recipe index b3a571345b..834166e00c 100644 --- a/recipes/libertad_digital.recipe +++ b/recipes/libertad_digital.recipe @@ -50,7 +50,7 @@ class LibertadDigital(BasicNewsRecipe): ] def get_article_url(self, article): - return article.get('guid', None) + return article.get('guid', None) def print_version(self, url): art, sep, rest = url.rpartition('/') diff --git a/recipes/lrb.recipe b/recipes/lrb.recipe index 01e958e83c..37b1150608 100644 --- a/recipes/lrb.recipe +++ b/recipes/lrb.recipe @@ -12,7 +12,7 @@ def classes(classes): def absolutize(href): if href.startswith('/'): - href = 'https://www.lrb.co.uk' + href + href = 'https://www.lrb.co.uk' + href return href diff --git a/recipes/marca.recipe b/recipes/marca.recipe index 0235ce8ff4..48c0b436f0 100644 --- a/recipes/marca.recipe +++ b/recipes/marca.recipe @@ -46,4 +46,4 @@ class Marca(BasicNewsRecipe): return soup def get_article_url(self, article): - return article.get('guid', None) + return article.get('guid', None) diff --git a/recipes/mediapart.recipe b/recipes/mediapart.recipe index a69df9fb41..9aa66689c6 100644 --- a/recipes/mediapart.recipe +++ b/recipes/mediapart.recipe @@ -95,7 +95,7 @@ class Mediapart(BasicNewsRecipe): for feed in feeds: feed_name = feed.title.lower() for article in feed.articles: - if feed_name != 'autres' and feed_name not in article.url: + if feed_name != 'autres' and feed_name not in article.url: feed.articles.remove(article) if feed_name == 'autres' and any(section in article.url for section in self.sections): feed.articles.remove(article) diff --git a/recipes/montreal_gazette.recipe b/recipes/montreal_gazette.recipe index 1ae5c6743a..bb8b4b25eb 100644 --- a/recipes/montreal_gazette.recipe +++ b/recipes/montreal_gazette.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/moscowtimes_en.recipe b/recipes/moscowtimes_en.recipe index 6045055486..8ab1832838 100644 --- a/recipes/moscowtimes_en.recipe +++ b/recipes/moscowtimes_en.recipe @@ -22,7 +22,7 @@ class MoscowTimes(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'article__tags'}) - remove_tags = [ + remove_tags = [ dict(name='aside'), dict(name='footer'), dict(name='section', attrs={'class': 'cluster'}), diff --git a/recipes/naszdziennik.recipe b/recipes/naszdziennik.recipe index c88a89e4aa..4868171f2d 100644 --- a/recipes/naszdziennik.recipe +++ b/recipes/naszdziennik.recipe @@ -60,7 +60,7 @@ class naszdziennik(BasicNewsRecipe): article_title_datetime.find('h4')) # zebrane elementy dodajemy do listy zadeklarowanej w linijce 44 articles[section].append( - {'title': article_title, 'url': article_url, 'date': article_date}) + {'title': article_title, 'url': article_url, 'date': article_date}) # po dodaniu wszystkich artykułów dodajemy sekcje do listy feedów, # korzystając z list sekcji znajdujących się w słowniku for section in sections: diff --git a/recipes/navy_times.recipe b/recipes/navy_times.recipe index bd3f297e65..021b3ca26d 100644 --- a/recipes/navy_times.recipe +++ b/recipes/navy_times.recipe @@ -27,12 +27,12 @@ class NavyTimes(BasicNewsRecipe): ('Home page', 'https://www.navytimes.com/arc/outboundfeeds/rss/?outputType=xml'), ('News', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/news/?outputType=xml'), ('Your Navy', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/news/your-navy/?outputType=xml'), - ('Your Army', 'https://www.armytimes.com/arc/outboundfeeds/rss/category/news/your-army/?outputType=xml'), + ('Your Army', 'https://www.armytimes.com/arc/outboundfeeds/rss/category/news/your-army/?outputType=xml'), ('Your Air Force', 'https://www.airforcetimes.com/arc/outboundfeeds/rss/category/news/your-air-force?outputType=xml'), - ('Your Marine Core', 'https://www.marinecorpstimes.com/arc/outboundfeeds/rss/category/news/your-marine-corps/?outputType=xml'), - ('Pentagon and Congress', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/news/pentagon-congress/?outputType=xml'), - ('Pay and Benefits', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/pay-benefits/?outputType=xml'), - ('Veterans', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/veterans/?outputType=xml'), - ('Education and Transition', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/education-transition/?outputType=xml'), - ('Flashpoints', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/flashpoints/?outputType=xml'), + ('Your Marine Core', 'https://www.marinecorpstimes.com/arc/outboundfeeds/rss/category/news/your-marine-corps/?outputType=xml'), + ('Pentagon and Congress', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/news/pentagon-congress/?outputType=xml'), + ('Pay and Benefits', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/pay-benefits/?outputType=xml'), + ('Veterans', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/veterans/?outputType=xml'), + ('Education and Transition', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/education-transition/?outputType=xml'), + ('Flashpoints', 'https://www.navytimes.com/arc/outboundfeeds/rss/category/flashpoints/?outputType=xml'), ] diff --git a/recipes/nepszabadsag.recipe b/recipes/nepszabadsag.recipe index a0b9f5279d..51612d42b8 100644 --- a/recipes/nepszabadsag.recipe +++ b/recipes/nepszabadsag.recipe @@ -29,7 +29,7 @@ class nepszabadsag(BasicNewsRecipe): remove_attributes = [] remove_tags_before = dict(name='div', attrs={'class': ['d-source']}) remove_tags_after = dict(name='div', attrs={'class': ['tags']}) - remove_tags = [dict(name='div', attrs={'class': ['h']}), + remove_tags = [dict(name='div', attrs={'class': ['h']}), dict(name='tfoot')] keep_only_tags = [dict(name='table', attrs={'class': 'article-box'})] diff --git a/recipes/nikkei_news.recipe b/recipes/nikkei_news.recipe index afc88e86ec..7c4f02cfb6 100644 --- a/recipes/nikkei_news.recipe +++ b/recipes/nikkei_news.recipe @@ -80,7 +80,7 @@ class NikkeiNet_paper_subscription(BasicNewsRecipe): sections = soup.findAll(attrs={'class': re.compile(r'.*cmn-article_title.*')}) for sect in sections: - sect_title = sect.find(attrs={'class' : re.compile(r'.*cmnc-((large)|(middle)|(small)).*')}) + sect_title = sect.find(attrs={'class': re.compile(r'.*cmnc-((large)|(middle)|(small)).*')}) if sect_title is None: continue sect_title = sect_title.contents[0] diff --git a/recipes/novinky.cz.recipe b/recipes/novinky.cz.recipe index c30dc259d7..e131e798e8 100644 --- a/recipes/novinky.cz.recipe +++ b/recipes/novinky.cz.recipe @@ -24,12 +24,12 @@ class novinkyRecipe(BasicNewsRecipe): remove_javascript = True no_stylesheets = True - remove_tags = [dict(name='div', attrs={'id': ['pictureInnerBox']}), - dict(name='div', attrs={'id': ['discussionEntry']}), - dict(name='span', attrs={ + remove_tags = [dict(name='div', attrs={'id': ['pictureInnerBox']}), + dict(name='div', attrs={'id': ['discussionEntry']}), + dict(name='span', attrs={ 'id': ['mynews-hits', 'mynews-author']}), - dict(name='div', attrs={'class': ['related']}), - dict(name='div', attrs={'id': ['multimediaInfo']})] + dict(name='div', attrs={'class': ['related']}), + dict(name='div', attrs={'id': ['multimediaInfo']})] remove_tags_before = dict(name='div', attrs={'class': ['articleHeader']}) remove_tags_after = dict(name='div', attrs={'class': 'related'}) diff --git a/recipes/nu.recipe b/recipes/nu.recipe index 80dd9a19f0..a40d392304 100644 --- a/recipes/nu.recipe +++ b/recipes/nu.recipe @@ -49,4 +49,4 @@ class Nu(BasicNewsRecipe): (u'Podcast Algemeen nieuws', u'http://www.nu.nl/podcast.php')] def get_article_url(self, article): - return article.get('guid', None) + return article.get('guid', None) diff --git a/recipes/old_games.recipe b/recipes/old_games.recipe index a7e3655e1f..508eba0a85 100644 --- a/recipes/old_games.recipe +++ b/recipes/old_games.recipe @@ -24,7 +24,7 @@ class OGRU(BasicNewsRecipe): remove_attributes = ['style'] - remove_tags = [ + remove_tags = [ dict(name='p', attrs={'id': 'pageDescription'}), dict(name='div', attrs={'class': 'pageNavLinkGroup'}), dict(name='div', attrs={'class': 'tagBlock TagContainer'}), diff --git a/recipes/ottawa_citizen.recipe b/recipes/ottawa_citizen.recipe index 68342217d5..9db1eb7c04 100644 --- a/recipes/ottawa_citizen.recipe +++ b/recipes/ottawa_citizen.recipe @@ -214,7 +214,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/pagina12.recipe b/recipes/pagina12.recipe index 0bff247ba1..3276fa4c7f 100644 --- a/recipes/pagina12.recipe +++ b/recipes/pagina12.recipe @@ -76,22 +76,22 @@ class Pagina12(BasicNewsRecipe): return br feeds = [ - (u'Diario de hoy' , u'https://www.pagina12.com.ar/rss/edicion-impresa'), - (u'Espectaculos' , u'https://www.pagina12.com.ar/rss/suplementos/cultura-y-espectaculos/notas'), - (u'Radar' , u'https://www.pagina12.com.ar/rss/suplementos/radar/notas'), - (u'Radar libros' , u'https://www.pagina12.com.ar/rss/suplementos/radar-libros/notas'), - (u'Cash' , u'https://www.pagina12.com.ar/rss/suplementos/cash/notas'), - (u'NO' , u'https://www.pagina12.com.ar/rss/suplementos/no/notas'), - (u'Las 12' , u'https://www.pagina12.com.ar/rss/suplementos/las12/notas'), - (u'Soy' , u'https://www.pagina12.com.ar/rss/suplementos/soy/notas'), - (u'M2' , u'https://www.pagina12.com.ar/rss/suplementos/m2/notas'), - (u'Rosario 12' , u'https://www.pagina12.com.ar/rss/suplementos/rosario12/notas') + (u'Diario de hoy', u'https://www.pagina12.com.ar/rss/edicion-impresa'), + (u'Espectaculos', u'https://www.pagina12.com.ar/rss/suplementos/cultura-y-espectaculos/notas'), + (u'Radar', u'https://www.pagina12.com.ar/rss/suplementos/radar/notas'), + (u'Radar libros', u'https://www.pagina12.com.ar/rss/suplementos/radar-libros/notas'), + (u'Cash', u'https://www.pagina12.com.ar/rss/suplementos/cash/notas'), + (u'NO', u'https://www.pagina12.com.ar/rss/suplementos/no/notas'), + (u'Las 12', u'https://www.pagina12.com.ar/rss/suplementos/las12/notas'), + (u'Soy', u'https://www.pagina12.com.ar/rss/suplementos/soy/notas'), + (u'M2', u'https://www.pagina12.com.ar/rss/suplementos/m2/notas'), + (u'Rosario 12', u'https://www.pagina12.com.ar/rss/suplementos/rosario12/notas') ] def get_cover_url(self): lurl = strftime('https://www.pagina12.com.ar/edicion-impresa/%d-%m-%Y') soup = self.index_to_soup(lurl) - mydiv = soup.find('div', {'class' : lambda x: x and 'printed-edition-cover' in x.split()}) + mydiv = soup.find('div', {'class': lambda x: x and 'printed-edition-cover' in x.split()}) if mydiv: for image in mydiv.findAll('img'): if image['src'].startswith('https://images.pagina12.com.ar/styles/width700/public/'): diff --git a/recipes/paperpaper.recipe b/recipes/paperpaper.recipe index 73d5c7daed..5bb6705753 100644 --- a/recipes/paperpaper.recipe +++ b/recipes/paperpaper.recipe @@ -24,7 +24,7 @@ class PaperPaper(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'bottom-block '}), dict(name='div', attrs={'class': 'bottom-block news'}) ] diff --git a/recipes/parlamentni_listy.recipe b/recipes/parlamentni_listy.recipe index 27bd17b4e3..adcfc3b259 100644 --- a/recipes/parlamentni_listy.recipe +++ b/recipes/parlamentni_listy.recipe @@ -32,4 +32,4 @@ class plRecipe(BasicNewsRecipe): preprocess_regexps = [(re.compile(r'<(span|strong)[^>]*>\s*Ptejte se politik.*', re.DOTALL | re.IGNORECASE), lambda match: '')] - keep_only_tags = [dict(name='div', attrs={'class': ['article-detail']})] + keep_only_tags = [dict(name='div', attrs={'class': ['article-detail']})] diff --git a/recipes/popscience.recipe b/recipes/popscience.recipe index 002b266e9f..e86741c363 100644 --- a/recipes/popscience.recipe +++ b/recipes/popscience.recipe @@ -26,7 +26,7 @@ class AdvancedUserRecipe1282101454(BasicNewsRecipe): classes('Article-header Article-excerpt Article-author Article-thumbnail Article-bodyText article-title article-dek article-paragraph articlebody'), ] remove_tags = [ - dict(name='section', attrs={'class': ['recurrent-share']}) + dict(name='section', attrs={'class': ['recurrent-share']}) ] def parse_section_index(self, slug): diff --git a/recipes/private_eye.recipe b/recipes/private_eye.recipe index 03a03c3e18..f00ffaf4d4 100644 --- a/recipes/private_eye.recipe +++ b/recipes/private_eye.recipe @@ -137,7 +137,7 @@ class PrivateEyeRecipe(BasicNewsRecipe): # We remove vast swathes of HTML which is not part of the articles. # Remove sibling content - remove_tags_before = [ + remove_tags_before = [ {'name': 'div', 'class': 'article'}, {'name': 'div', 'id': 'page'}, {'name': 'div', 'id': 'page-wide'}, diff --git a/recipes/pro_physik.recipe b/recipes/pro_physik.recipe index 2cdf2e5fac..be1e30e2cf 100644 --- a/recipes/pro_physik.recipe +++ b/recipes/pro_physik.recipe @@ -31,7 +31,7 @@ class AdvancedUserRecipe1303841067(BasicNewsRecipe): # cover_url = file:///c:/Users/YOUR_USERNAME/AppData/Roaming/calibre/resources/images/news_covers/Pro_Physik.png - extra_css = ''' + extra_css = ''' h1 {font-size: 1.6em; text-align: left} h2, h3 {font-size: 1.3em;text-align: left} h2.subtitle {font-size: 1.2em;text-align: left;font-style: italic} diff --git a/recipes/prosleduet.recipe b/recipes/prosleduet.recipe index 896c69b37b..3900da0be7 100644 --- a/recipes/prosleduet.recipe +++ b/recipes/prosleduet.recipe @@ -26,7 +26,7 @@ class ProSleduet(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'container'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'ya-share2 ya-share2_inited'}) ] diff --git a/recipes/radio_canada.recipe b/recipes/radio_canada.recipe index 1138635a46..1316a844f0 100644 --- a/recipes/radio_canada.recipe +++ b/recipes/radio_canada.recipe @@ -104,7 +104,7 @@ class RadioCanada(BasicNewsRecipe): ('Grands titres', 'https://ici.radio-canada.ca/rss/771'), ('Football', 'https://ici.radio-canada.ca/rss/1000057'), ('Hockey', 'https://ici.radio-canada.ca/rss/1000056'), - ('Olympiques', 'https://ici.radio-canada.ca/rss/64852'), + ('Olympiques', 'https://ici.radio-canada.ca/rss/64852'), ('Podium', 'https://ici.radio-canada.ca/rss/555082'), ('Soccer', 'https://ici.radio-canada.ca/rss/1000058'), ('Tennis', 'https://ici.radio-canada.ca/rss/1000059'), diff --git a/recipes/real_clear.recipe b/recipes/real_clear.recipe index 60e2c51460..13a0650e5e 100644 --- a/recipes/real_clear.recipe +++ b/recipes/real_clear.recipe @@ -35,9 +35,9 @@ class RealClear(BasicNewsRecipe): # Numeric parameter is type, controls whether we look for feedsets = [ - ['Politics', 'http://www.realclearpolitics.com/index.xml', 0], - ['Policy', 'http://www.realclearpolicy.com/index.xml', 0], - ['Science', 'http://www.realclearscience.com/index.xml', 0], + ['Politics', 'http://www.realclearpolitics.com/index.xml', 0], + ['Policy', 'http://www.realclearpolicy.com/index.xml', 0], + ['Science', 'http://www.realclearscience.com/index.xml', 0], ['Tech', 'http://www.realcleartechnology.com/index.xml', 0], # The feedburner is essentially the same as the top feed, politics. # ["Politics Burner", "http://feeds.feedburner.com/realclearpolitics/qlMj", 1], @@ -45,7 +45,7 @@ class RealClear(BasicNewsRecipe): ['Markets Home', 'http://www.realclearmarkets.com/index.xml', 0], ['Markets', 'http://www.realclearmarkets.com/articles/index.xml', 0], ['World', 'http://www.realclearworld.com/index.xml', 0], - ['World Blog', 'http://www.realclearworld.com/blog/index.xml', 2] + ['World Blog', 'http://www.realclearworld.com/blog/index.xml', 2] ] # Hints to extractPrintURL. # First column is the URL snippet. Then the string to search for as text, @@ -53,12 +53,11 @@ class RealClear(BasicNewsRecipe): # drill down. phUrlSnip, phLinkText, phMainSearch, phHrefSearch = range(4) - printhints = [['realclear', '', '', 'printpage'], - ['billoreilly.com', 'Print this entry', 'a', ''], - ['billoreilly.com', 'Print This Article', 'a', ''], - ['politico.com', 'Print', - 'a', 'share-print'], - ['nationalreview.com', '>Print<', 'a', ''], + printhints = [['realclear', '', '', 'printpage'], + ['billoreilly.com', 'Print this entry', 'a', ''], + ['billoreilly.com', 'Print This Article', 'a', ''], + ['politico.com', 'Print', 'a', 'share-print'], + ['nationalreview.com', '>Print<', 'a', ''], ['reason.com', '', 'a', 'printer'] # The following are not supported due to JavaScripting, and would require obfuscated_article to handle # forbes, diff --git a/recipes/respekt_magazine.recipe b/recipes/respekt_magazine.recipe index 1325aabb11..0bdf144b72 100644 --- a/recipes/respekt_magazine.recipe +++ b/recipes/respekt_magazine.recipe @@ -125,7 +125,7 @@ class respektRecipe(BasicNewsRecipe): else: if next.getchildren(): next_child = next.getchildren()[0] - next_child.text = next_child.text + u' • ' + text + next_child.text = next_child.text + u' • ' + text par.getparent().remove(par) # Insert text length text = root.xpath("//div[@id='postcontent']")[0] @@ -171,4 +171,4 @@ class respektRecipe(BasicNewsRecipe): o.getparent().replace(o,e) except: pass - return (BeautifulSoup(lxml.etree.tostring(root,encoding='unicode'))) + return BeautifulSoup(lxml.etree.tostring(root,encoding='unicode')) diff --git a/recipes/rnd.recipe b/recipes/rnd.recipe index e4ac4c3647..c7e2e62e2f 100644 --- a/recipes/rnd.recipe +++ b/recipes/rnd.recipe @@ -60,7 +60,7 @@ class RND(BasicNewsRecipe): feeds = [ ('Politik', 'https://www.rnd.de/arc/outboundfeeds/rss/category/politik/'), - ('Wirtschaft', 'https://www.rnd.de/arc/outboundfeeds/rss/category/wirtschaft/'), + ('Wirtschaft', 'https://www.rnd.de/arc/outboundfeeds/rss/category/wirtschaft/'), ('Sport', 'https://www.rnd.de/arc/outboundfeeds/rss/category/sport/'), ('Panorama', 'https://www.rnd.de/arc/outboundfeeds/rss/category/panorama/'), # ('Promis', 'https://www.rnd.de/arc/outboundfeeds/rss/category/promis/'), diff --git a/recipes/saechsische.recipe b/recipes/saechsische.recipe index c08d238395..508cceec0a 100644 --- a/recipes/saechsische.recipe +++ b/recipes/saechsische.recipe @@ -61,7 +61,7 @@ class Saechsische(BasicNewsRecipe): feeds = [ # ('Alle Artikel der SZ', 'https://www.saechsische.de/arc/outboundfeeds/rss/'), - ('Stadt Dresden', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/dresden'), + ('Stadt Dresden', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/dresden'), # ('Altstadt', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/dresden/altstadt'), # ('Blasewitz', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/dresden/blasewitz'), # ('Cotta', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/dresden/cotta'), @@ -152,7 +152,7 @@ class Saechsische(BasicNewsRecipe): # ('Vogtlandkreis', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/vogtland'), # ('Plauen', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/lokales/vogtland/plauen'), # ('Tschechien', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/tschechien'), - ('Sachsen', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/sachsen'), + ('Sachsen', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/sachsen'), # ('Der Osten', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/der-osten'), # ('Politik in Sachsen', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/politik/regional'), # ('Wirtschaft in Sachsen', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/wirtschaft/regional'), @@ -172,10 +172,10 @@ class Saechsische(BasicNewsRecipe): # ('Genuss und Kochen', 'https://www.saechsische.de/arc/outboundfeeds/rss/tags_slug/genuss-und-kochen'), # ('Sächsische Schweiz', 'https://www.saechsische.de/arc/outboundfeeds/rss/tags_slug/saechsische-schweiz'), # ('Sachsenkompass', 'https://www.saechsische.de/arc/outboundfeeds/rss/tags_slug/sachsenkompass'), - ('Politik', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/politik'), - ('Wirtschaft', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/wirtschaft'), + ('Politik', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/politik'), + ('Wirtschaft', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/wirtschaft'), # ('Sport', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/sport'), - ('Panorama', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/panorama'), + ('Panorama', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/panorama'), # ('Promis', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/promis'), # ('Reise', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/reise'), # ('Medien & TV', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/medien'), diff --git a/recipes/scmp.recipe b/recipes/scmp.recipe index f536972676..7ac31a48bf 100644 --- a/recipes/scmp.recipe +++ b/recipes/scmp.recipe @@ -54,7 +54,7 @@ def load_article_from_json(raw, root): for child in tuple(body): body.remove(child) article = E(body, 'article') - E(article, 'div', replace_entities(data['firstTopic']['name']) , style='color: gray; font-size:small; font-weight:bold;') + E(article, 'div', replace_entities(data['firstTopic']['name']), style='color: gray; font-size:small; font-weight:bold;') E(article, 'h1', replace_entities(data['headline'])) # E(article, 'p', replace_entities(data['subHeadline']['text']), style='font-style: italic; color:#202020;') for subh in data['subHeadline']['json']: diff --git a/recipes/sobaka.recipe b/recipes/sobaka.recipe index d4fe8946cf..9b4856114c 100644 --- a/recipes/sobaka.recipe +++ b/recipes/sobaka.recipe @@ -22,7 +22,7 @@ class Sobaka(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'b-post-view__foot'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'b-post-view__telegram-promo'}), dict(name='div', attrs={'class': 'b-post-view__tgb'}), dict(name='div', attrs={'id': 'comments'}), diff --git a/recipes/sotavision.recipe b/recipes/sotavision.recipe index 740011fd7a..ba3a195e6d 100644 --- a/recipes/sotavision.recipe +++ b/recipes/sotavision.recipe @@ -21,7 +21,7 @@ class Sotavision(BasicNewsRecipe): remove_tags_after = dict(name='span', attrs={'style': 'border-color:#EBEBEB;border-width:1px;width:100%;'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'td_block_wrap tdb_mobile_menu tdi_7 td-pb-border-top td_block_template_1 tdb-header-align'}), dict(name='div', attrs={'class': 'td_block_wrap tdb_single_author tdi_52 td-pb-border-top td_block_template_1 tdb-post-meta'}), dict(name='div', attrs={'class': 'td_block_wrap tdb_single_date tdi_53 td-pb-border-top td_block_template_1 tdb-post-meta'}), diff --git a/recipes/spectator_magazine.recipe b/recipes/spectator_magazine.recipe index e40b4bc297..84b29306b8 100644 --- a/recipes/spectator_magazine.recipe +++ b/recipes/spectator_magazine.recipe @@ -5,7 +5,7 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes def absurl(url): if url.startswith('/'): - url = 'https://www.spectator.co.uk' + url + url = 'https://www.spectator.co.uk' + url return url diff --git a/recipes/straitstimes.recipe b/recipes/straitstimes.recipe index bf9506f28c..8b8e3bcaa0 100644 --- a/recipes/straitstimes.recipe +++ b/recipes/straitstimes.recipe @@ -39,16 +39,16 @@ class StraitsTimes(BasicNewsRecipe): ] feeds = [ - (u'World' , u'https://www.straitstimes.com/news/world/rss.xml') - (u'Business' , u'https://www.straitstimes.com/news/business/rss.xml'), - (u'Life' , u'https://www.straitstimes.com/news/life/rss.xml'), - (u'Tech' , u'https://www.straitstimes.com/news/tech/rss.xml'), - (u'Opinion' , u'https://www.straitstimes.com/news/opinion/rss.xml'), - (u'Life' , u'https://www.straitstimes.com/news/life/rss.xml'), - (u'Singapore' , u'https://www.straitstimes.com/news/singapore/rss.xml'), - (u'Asia' , u'https://www.straitstimes.com/news/asia/rss.xml'), - (u'Multimedia' , u'https://www.straitstimes.com/news/multimedia/rss.xml'), - (u'Sport' , u'https://www.straitstimes.com/news/sport/rss.xml'), + (u'World', u'https://www.straitstimes.com/news/world/rss.xml'), + (u'Business', u'https://www.straitstimes.com/news/business/rss.xml'), + (u'Life', u'https://www.straitstimes.com/news/life/rss.xml'), + (u'Tech', u'https://www.straitstimes.com/news/tech/rss.xml'), + (u'Opinion', u'https://www.straitstimes.com/news/opinion/rss.xml'), + (u'Life', u'https://www.straitstimes.com/news/life/rss.xml'), + (u'Singapore', u'https://www.straitstimes.com/news/singapore/rss.xml'), + (u'Asia', u'https://www.straitstimes.com/news/asia/rss.xml'), + (u'Multimedia', u'https://www.straitstimes.com/news/multimedia/rss.xml'), + (u'Sport', u'https://www.straitstimes.com/news/sport/rss.xml'), ] def preprocess_html(self, soup): diff --git a/recipes/t_invariant_en.recipe b/recipes/t_invariant_en.recipe index 2b640ac77d..03a2f342b2 100644 --- a/recipes/t_invariant_en.recipe +++ b/recipes/t_invariant_en.recipe @@ -29,7 +29,7 @@ class TInvariant(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'media mg-info-author-block'}), dict(name='div', attrs={'class': 'mg-blog-category mb-1'}), dict(name='span', attrs={'class': 'newses-tags'}), diff --git a/recipes/t_invariant_ru.recipe b/recipes/t_invariant_ru.recipe index 9320f176ee..1dd5348403 100644 --- a/recipes/t_invariant_ru.recipe +++ b/recipes/t_invariant_ru.recipe @@ -29,7 +29,7 @@ class TInvariant(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'media mg-info-author-block'}), dict(name='div', attrs={'class': 'mg-blog-category mb-1'}), dict(name='span', attrs={'class': 'newses-tags'}), diff --git a/recipes/t_invariant_ua.recipe b/recipes/t_invariant_ua.recipe index f7a69588de..24ec2a69d5 100644 --- a/recipes/t_invariant_ua.recipe +++ b/recipes/t_invariant_ua.recipe @@ -29,7 +29,7 @@ class TInvariant(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'media mg-info-author-block'}), dict(name='div', attrs={'class': 'mg-blog-category mb-1'}), dict(name='span', attrs={'class': 'newses-tags'}), diff --git a/recipes/the_philippine_daily_inquirer.recipe b/recipes/the_philippine_daily_inquirer.recipe index 222414159a..c9a449d9e1 100644 --- a/recipes/the_philippine_daily_inquirer.recipe +++ b/recipes/the_philippine_daily_inquirer.recipe @@ -51,73 +51,80 @@ class PhilippineDailyInquirer(BasicNewsRecipe): feeds = [ - ('Headlines', 'http://newsinfo.inquirer.net/category/inquirer-headlines/feed'), - ('Latest Stories' , 'http://newsinfo.inquirer.net/category/latest-stories/feed'), - ('Nation' , 'http://newsinfo.inquirer.net/category/nation/feed'), - ('Nation - Latest Stories' , 'http://newsinfo.inquirer.net/category/latest-stories/nation-latest-stories/feed'), - ('Metro' , 'http://newsinfo.inquirer.net/category/metro/feed'), - ('Metro - Latest Stories' , 'http://newsinfo.inquirer.net/category/latest-stories/metro-latest-stories/feed'), - ('Regions' , 'http://newsinfo.inquirer.net/category/regions/feed'), - ('Regions - Latest Stories' , 'http://newsinfo.inquirer.net/category/latest-stories/regions-latest-stories/feed'), - ('News' , 'http://www.inquirer.net/fullfeed'), - ('More News' , 'http://newsinfo.inquirer.net/feed') - , - ('Global Nation' , 'http://globalnation.inquirer.net/feed'), - ('Global Nation - Latest Stories', 'http://globalnation.inquirer.net/category/latest-stories/feed'), - ('Global Nation - Philippines', 'http://globalnation.inquirer.net/category/news/philippines/feed'), - ('Global Nation - Asia & Pacific', 'http://globalnation.inquirer.net/category/news/asiaaustralia/feed'), - ('Global Nation - Americas', 'http://globalnation.inquirer.net/category/news/uscanada/feed'), - ('Global Nation - Middle East & Africa', 'http://globalnation.inquirer.net/category/news/middle-eastafrica/feed'), - ('Global Nation - Europe' , 'http://globalnation.inquirer.net/category/news/europe/feed'), - ('Global Nation - Global Pinoy', 'http://globalnation.inquirer.net/category/global-pinoy/feed'), - ('Global Nation - Events' , 'http://globalnation.inquirer.net/category/events/feed'), - ('Business' , 'http://business.inquirer.net/feed'), - ('Business - Latest Stories' , 'http://business.inquirer.net/category/latest-stories/feed'), - ('Business - Money' , 'http://business.inquirer.net/category/money/feed'), + ('Headlines', 'http://newsinfo.inquirer.net/category/inquirer-headlines/feed'), + ('Latest Stories', 'http://newsinfo.inquirer.net/category/latest-stories/feed'), + ('Nation', 'http://newsinfo.inquirer.net/category/nation/feed'), + ('Nation - Latest Stories', 'http://newsinfo.inquirer.net/category/latest-stories/nation-latest-stories/feed'), + ('Metro', 'http://newsinfo.inquirer.net/category/metro/feed'), + ('Metro - Latest Stories', 'http://newsinfo.inquirer.net/category/latest-stories/metro-latest-stories/feed'), + ('Regions', 'http://newsinfo.inquirer.net/category/regions/feed'), + ('Regions - Latest Stories', 'http://newsinfo.inquirer.net/category/latest-stories/regions-latest-stories/feed'), + ('News', 'http://www.inquirer.net/fullfeed'), + ('More News', 'http://newsinfo.inquirer.net/feed'), + + ('Global Nation', 'http://globalnation.inquirer.net/feed'), + ('Global Nation - Latest Stories', 'http://globalnation.inquirer.net/category/latest-stories/feed'), + ('Global Nation - Philippines', 'http://globalnation.inquirer.net/category/news/philippines/feed'), + ('Global Nation - Asia & Pacific', 'http://globalnation.inquirer.net/category/news/asiaaustralia/feed'), + ('Global Nation - Americas', 'http://globalnation.inquirer.net/category/news/uscanada/feed'), + ('Global Nation - Middle East & Africa', 'http://globalnation.inquirer.net/category/news/middle-eastafrica/feed'), + ('Global Nation - Europe', 'http://globalnation.inquirer.net/category/news/europe/feed'), + ('Global Nation - Global Pinoy', 'http://globalnation.inquirer.net/category/global-pinoy/feed'), + ('Global Nation - Events', 'http://globalnation.inquirer.net/category/events/feed'), + + ('Business', 'http://business.inquirer.net/feed'), + ('Business - Latest Stories', 'http://business.inquirer.net/category/latest-stories/feed'), + ('Business - Money', 'http://business.inquirer.net/category/money/feed'), ('Business - Science & Health', 'http://business.inquirer.net/category/science-and-health/feed'), - ('Business - Motoring' , 'http://business.inquirer.net/category/motoring/feed'), - ('Business - Property Guide' , 'http://business.inquirer.net/category/property-guide/feed'), - ('Business - Columnists' , 'http://business.inquirer.net/category/columnists/feed'), - ('Sports' , 'http://sports.inquirer.net/feed'), - ('Sports - Latest Stories' , 'http://sports.inquirer.net/category/latest-stories/feed'), - ('Sports - Basketball' , 'http://sports.inquirer.net/category/section/basketball/feed'), - ('Sports - Boxing & MMA', 'http://sports.inquirer.net/category/section/boxing-mma/feed'), - ('Sports - Golf' , 'http://sports.inquirer.net/category/section/golf/feed'), - ('Sports - Football' , 'http://sports.inquirer.net/category/section/other-sports/football/feed'), - ('Sports - Other Sports' , 'http://sports.inquirer.net/category/section/other-sports/feed'), - ('Technology' , 'http://technology.inquirer.net/feed'), - ('Technology Latest Stories', 'http://technology.inquirer.net/category/latest-stories/feed'), - ('Entertainment' , 'http://entertainment.inquirer.net/feed'), - ('Entertainment - Headlines', 'http://entertainment.inquirer.net/category/headlines/feed'), - ('Entertainment - Latest Stories', 'http://entertainment.inquirer.net/category/latest-stories/feed'), - ('Entertainment - Movies' , 'http://movies.inquirer.net/feed'), - ('Lifestyle' , 'http://lifestyle.inquirer.net/feed'), - ('Lifestyle - Latest Stories', 'http://lifestyle.inquirer.net/category/latest-stories/feed'), - ('Lifestyle - Arts & Books' , 'http://lifestyle.inquirer.net/category/arts-and-books/feed'), - ('Lifestyle - Wellness' , 'http://lifestyle.inquirer.net/category/wellness/feed'), + ('Business - Motoring', 'http://business.inquirer.net/category/motoring/feed'), + ('Business - Property Guide', 'http://business.inquirer.net/category/property-guide/feed'), + ('Business - Columnists', 'http://business.inquirer.net/category/columnists/feed'), + + ('Sports', 'http://sports.inquirer.net/feed'), + ('Sports - Latest Stories', 'http://sports.inquirer.net/category/latest-stories/feed'), + ('Sports - Basketball', 'http://sports.inquirer.net/category/section/basketball/feed'), + ('Sports - Boxing & MMA', 'http://sports.inquirer.net/category/section/boxing-mma/feed'), + ('Sports - Golf', 'http://sports.inquirer.net/category/section/golf/feed'), + ('Sports - Football', 'http://sports.inquirer.net/category/section/other-sports/football/feed'), + ('Sports - Other Sports', 'http://sports.inquirer.net/category/section/other-sports/feed'), + + ('Technology', 'http://technology.inquirer.net/feed'), + ('Technology Latest Stories', 'http://technology.inquirer.net/category/latest-stories/feed'), + + ('Entertainment', 'http://entertainment.inquirer.net/feed'), + ('Entertainment - Headlines', 'http://entertainment.inquirer.net/category/headlines/feed'), + ('Entertainment - Latest Stories', 'http://entertainment.inquirer.net/category/latest-stories/feed'), + ('Entertainment - Movies', 'http://movies.inquirer.net/feed'), + + ('Lifestyle', 'http://lifestyle.inquirer.net/feed'), + ('Lifestyle - Latest Stories', 'http://lifestyle.inquirer.net/category/latest-stories/feed'), + ('Lifestyle - Arts & Books', 'http://lifestyle.inquirer.net/category/arts-and-books/feed'), + ('Lifestyle - Wellness', 'http://lifestyle.inquirer.net/category/wellness/feed'), ('Lifestyle - Home & Entertaining', 'http://lifestyle.inquirer.net/category/home-and-entertaining/feed'), - ('Lifestyle - Parenting' , 'http://lifestyle.inquirer.net/category/parenting/feed'), - ('Lifestyle - Food' , 'http://lifestyle.inquirer.net/category/food/feed'), - ('Lifestyle - Fashion & Beauty', 'http://lifestyle.inquirer.net/category/fashion-and-beauty/feed'), - ('Lifestyle - Super' , 'http://lifestyle.inquirer.net/category/super/feed'), - ('Lifestyle - 2BU' , 'http://lifestyle.inquirer.net/category/2bu/feed'), - ('Lifestyle - Sunday Lifestyle', 'http://lifestyle.inquirer.net/category/sunday-lifestyle/feed'), - ('Lifestyle - Wedding' , 'http://lifestyle.inquirer.net/category/sunday-lifestyle/wedding/feed'), - ('Lifestyle - Travel' , 'http://lifestyle.inquirer.net/category/sunday-lifestyle/travel/feed'), - ('Lifestyle - Relationship' , 'http://lifestyle.inquirer.net/category/sunday-lifestyle/relationship/feed'), - ('Opinion' , 'http://opinion.inquirer.net/feed'), - ('Opinion - Viewpoints' , 'http://opinion.inquirer.net/category/viewpoints/feed'), - ('Opinion - Talk of the Town', 'http://opinion.inquirer.net/category/inquirer-opinion/talk-of-the-town/feed'), - ('Editorial' , 'http://opinion.inquirer.net/category/editorial/feed'), - ('Letters to the Editor' , 'http://opinion.inquirer.net/category/letters-to-the-editor/feed'), - ('Columns' , 'http://opinion.inquirer.net/category/columns/feed'), - ('Citizens Journalism' , 'http://newsinfo.inquirer.net/category/citizens-journalism/feed'), - ('Cebu - Daily News' , 'http://newsinfo.inquirer.net/category/cdn/feed'), - ('Cebu - More News' , 'http://newsinfo.inquirer.net/category/cdn/cdn-news/feed'), - ('Cebu - Community' , 'http://newsinfo.inquirer.net/category/cdn/cdn-community/feed'), - ('Cebu - Metro' , 'http://newsinfo.inquirer.net/category/cdn/cdn-metro/feed'), - ('Cebu - Business' , 'http://newsinfo.inquirer.net/category/cdn/cdn-enterprise/feed'), - ('Cebu - Sports' , 'http://newsinfo.inquirer.net/category/cdn/cdn-sports/feed'), - ('Cebu - Visayas' , 'http://newsinfo.inquirer.net/category/cdn/cdn-visayas/feed'), - ('Cebu - Opinion' , 'http://newsinfo.inquirer.net/category/cdn/cdn-opinion/feed') + ('Lifestyle - Parenting', 'http://lifestyle.inquirer.net/category/parenting/feed'), + ('Lifestyle - Food', 'http://lifestyle.inquirer.net/category/food/feed'), + ('Lifestyle - Fashion & Beauty', 'http://lifestyle.inquirer.net/category/fashion-and-beauty/feed'), + ('Lifestyle - Super', 'http://lifestyle.inquirer.net/category/super/feed'), + ('Lifestyle - 2BU', 'http://lifestyle.inquirer.net/category/2bu/feed'), + ('Lifestyle - Sunday Lifestyle', 'http://lifestyle.inquirer.net/category/sunday-lifestyle/feed'), + ('Lifestyle - Wedding', 'http://lifestyle.inquirer.net/category/sunday-lifestyle/wedding/feed'), + ('Lifestyle - Travel', 'http://lifestyle.inquirer.net/category/sunday-lifestyle/travel/feed'), + ('Lifestyle - Relationship', 'http://lifestyle.inquirer.net/category/sunday-lifestyle/relationship/feed'), + + ('Opinion', 'http://opinion.inquirer.net/feed'), + ('Opinion - Viewpoints', 'http://opinion.inquirer.net/category/viewpoints/feed'), + ('Opinion - Talk of the Town', 'http://opinion.inquirer.net/category/inquirer-opinion/talk-of-the-town/feed'), + ('Editorial', 'http://opinion.inquirer.net/category/editorial/feed'), + ('Letters to the Editor', 'http://opinion.inquirer.net/category/letters-to-the-editor/feed'), + ('Columns', 'http://opinion.inquirer.net/category/columns/feed'), + + ('Citizens Journalism', 'http://newsinfo.inquirer.net/category/citizens-journalism/feed'), + ('Cebu - Daily News', 'http://newsinfo.inquirer.net/category/cdn/feed'), + ('Cebu - More News', 'http://newsinfo.inquirer.net/category/cdn/cdn-news/feed'), + ('Cebu - Community', 'http://newsinfo.inquirer.net/category/cdn/cdn-community/feed'), + ('Cebu - Metro', 'http://newsinfo.inquirer.net/category/cdn/cdn-metro/feed'), + ('Cebu - Business', 'http://newsinfo.inquirer.net/category/cdn/cdn-enterprise/feed'), + ('Cebu - Sports', 'http://newsinfo.inquirer.net/category/cdn/cdn-sports/feed'), + ('Cebu - Visayas', 'http://newsinfo.inquirer.net/category/cdn/cdn-visayas/feed'), + ('Cebu - Opinion', 'http://newsinfo.inquirer.net/category/cdn/cdn-opinion/feed'), ] diff --git a/recipes/theoldie.recipe b/recipes/theoldie.recipe index eb1cfac995..3c6de3a841 100644 --- a/recipes/theoldie.recipe +++ b/recipes/theoldie.recipe @@ -217,7 +217,7 @@ class PrivateEyeRecipe(BasicNewsRecipe): ] # We remove vast swathes of HTML which is not part of the articles. - remove_tags_before = [ + remove_tags_before = [ {'name': 'div', 'class': 'container'}, {'name': 'div', 'class': 'content-wrapper'}, {'name': 'div', 'class': 'only-in-the-magazine'}, diff --git a/recipes/tmz.recipe b/recipes/tmz.recipe index c78264be2f..d217f7729c 100644 --- a/recipes/tmz.recipe +++ b/recipes/tmz.recipe @@ -30,21 +30,21 @@ class AdvancedUserRecipe1282101454(BasicNewsRecipe): ('TOP 20', 'http://www.tmz.com/rss.xml'), ('Exclusives', 'http://www.tmz.com/category/exclusives/rss.xml'), ('Celeb Justice', 'http://www.tmz.com/category/celebrity-justice/rss.xml'), - ('Celeb Feuds', 'http://www.tmz.com/category/celebrity-feuds/rss.xml'), - ('Politix', 'http://www.tmz.com/category/politix/rss.xml'), - ('Music', 'http://www.tmz.com/category/music/rss.xml'), - ('Movies', 'http://www.tmz.com/category/movies/rss.xml'), - ('TV', 'http://www.tmz.com/category/tv/rss.xml'), - ('Sports', 'http://www.tmz.com/category/TMZsports/rss.xml'), - ('Hook-Ups', 'http://www.tmz.com/category/hook-ups/rss.xml'), - ('Beauty', 'http://www.tmz.com/category/beauty/rss.xml'), - ('Fashion', 'http://www.tmz.com/category/fashion/rss.xml'), - ('Gossip & Rumor', 'http://www.tmz.com/category/gossip-rumors/rss.xml'), - ('Hot Mama', 'http://www.tmz.com/category/hot-mamas/rss.xml'), - ('Party All The Time', 'http://www.tmz.com/category/party-all-the-time/rss.xml'), - ('Ride Me!', 'http://www.tmz.com/category/ride-me/rss.xml'), - ('Stars in Heat', 'http://www.tmz.com/category/stars-in-heat/rss.xml'), - ('Vegas', 'http://www.tmz.com/category/hot-vegas/rss.xml') + ('Celeb Feuds', 'http://www.tmz.com/category/celebrity-feuds/rss.xml'), + ('Politix', 'http://www.tmz.com/category/politix/rss.xml'), + ('Music', 'http://www.tmz.com/category/music/rss.xml'), + ('Movies', 'http://www.tmz.com/category/movies/rss.xml'), + ('TV', 'http://www.tmz.com/category/tv/rss.xml'), + ('Sports', 'http://www.tmz.com/category/TMZsports/rss.xml'), + ('Hook-Ups', 'http://www.tmz.com/category/hook-ups/rss.xml'), + ('Beauty', 'http://www.tmz.com/category/beauty/rss.xml'), + ('Fashion', 'http://www.tmz.com/category/fashion/rss.xml'), + ('Gossip & Rumor', 'http://www.tmz.com/category/gossip-rumors/rss.xml'), + ('Hot Mama', 'http://www.tmz.com/category/hot-mamas/rss.xml'), + ('Party All The Time', 'http://www.tmz.com/category/party-all-the-time/rss.xml'), + ('Ride Me!', 'http://www.tmz.com/category/ride-me/rss.xml'), + ('Stars in Heat', 'http://www.tmz.com/category/stars-in-heat/rss.xml'), + ('Vegas', 'http://www.tmz.com/category/hot-vegas/rss.xml') ] def print_version(self, url): diff --git a/recipes/toi.recipe b/recipes/toi.recipe index 023bcf2f8b..31505f7eb2 100644 --- a/recipes/toi.recipe +++ b/recipes/toi.recipe @@ -73,7 +73,7 @@ class TheEconomicTimes(BasicNewsRecipe): return citem['content'] def get_article_url(self, article): - rurl = article.get('guid', None) + rurl = article.get('guid', None) if '/articleshow/' in rurl: return rurl diff --git a/recipes/ua_fooball.recipe b/recipes/ua_fooball.recipe index 91416aca86..3de987dc1e 100644 --- a/recipes/ua_fooball.recipe +++ b/recipes/ua_fooball.recipe @@ -39,7 +39,7 @@ class UAFootball(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'show-post'}) - remove_tags = [ + remove_tags = [ dict(name='form'), dict(name='iframe'), dict(name='div', attrs={'class': 'language'}), diff --git a/recipes/ukrinform_es.recipe b/recipes/ukrinform_es.recipe index 17a8c547f1..d73c2650d3 100644 --- a/recipes/ukrinform_es.recipe +++ b/recipes/ukrinform_es.recipe @@ -22,7 +22,7 @@ class UkrInform(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ dict(name='aside'), dict(name='img', attrs={'class': 'pixel'}), dict(name='section', attrs={'class': 'read'}), diff --git a/recipes/vancouver_province.recipe b/recipes/vancouver_province.recipe index 473156ebc5..a022ea415f 100644 --- a/recipes/vancouver_province.recipe +++ b/recipes/vancouver_province.recipe @@ -227,7 +227,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/vancouver_sun.recipe b/recipes/vancouver_sun.recipe index c66cac483a..0399aa9f00 100644 --- a/recipes/vancouver_sun.recipe +++ b/recipes/vancouver_sun.recipe @@ -215,7 +215,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] pgall = soup.find('div', attrs={'id': 'storyphoto'}) if pgall is not None: # photo gallery perhaps diff --git a/recipes/version2.recipe b/recipes/version2.recipe index b9e94f59a5..a665502bc0 100644 --- a/recipes/version2.recipe +++ b/recipes/version2.recipe @@ -38,7 +38,7 @@ class version2(BasicNewsRecipe): dict(name='span', attrs={'class': 'article-link-id'}), dict(name='section', attrs={'class': 'social-tools-pane'}), dict(name='section', attrs={'class': 'article-timeline'}), - dict(name='div', attrs={'id' : 'mini-panel-comments_and_form'}), + dict(name='div', attrs={'id': 'mini-panel-comments_and_form'}), dict(name='div', attrs={'class': 'related-articles top-three'}), dict(name='div', attrs={'id': 'mini-panel-jobfinder_1'}), dict(name='section', attrs={'id': 'mini-panel-frontpage_debat_zone'}), @@ -53,7 +53,7 @@ class version2(BasicNewsRecipe): dict(name='section', attrs={'class': 'jobs-list'}), dict(name='footer', attrs={'id': 'footer'}), dict(name='section', attrs={'class': 'banner'}), - dict(name='div', attrs={'class' : 'fast-track-frontpage'}), + dict(name='div', attrs={'class': 'fast-track-frontpage'}), dict(name='a', attrs={'class': 'byline-comments'}) ] diff --git a/recipes/vikna_ru.recipe b/recipes/vikna_ru.recipe index a80e7713f9..4176215ed4 100644 --- a/recipes/vikna_ru.recipe +++ b/recipes/vikna_ru.recipe @@ -23,7 +23,7 @@ class ViknaSTB(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'class': 'content-wrapper'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'share-content-wrapper flex-wrapper'}), dict(name='div', attrs={'class': 'sticky-wrapper'}), dict(name='div', attrs={'class': 'promo-wrapper'}), diff --git a/recipes/weblogs_sl.recipe b/recipes/weblogs_sl.recipe index 7517fc0a9f..94f400ae47 100644 --- a/recipes/weblogs_sl.recipe +++ b/recipes/weblogs_sl.recipe @@ -101,7 +101,7 @@ class weblogssl(BasicNewsRecipe): dict(name='div', attrs={'id':'comments'}) ] - remove_tags_after = dict(name='div' , attrs={'id':'comments'}) + remove_tags_after = dict(name='div', attrs={'id':'comments'}) def print_version(self, url): if url.startswith('http://www'): diff --git a/recipes/wicomix.recipe b/recipes/wicomix.recipe index 58d33f659c..b97f1a5825 100644 --- a/recipes/wicomix.recipe +++ b/recipes/wicomix.recipe @@ -24,7 +24,7 @@ class WiComix(BasicNewsRecipe): remove_tags_after = dict(name='article') - remove_tags = [ + remove_tags = [ # dict(name='div', attrs={'class': 'author-meta'}), dict(name='div', attrs={'id': 'jp-post-flair'}), dict(name='footer', attrs={'class': 'entry-meta'}) diff --git a/recipes/windows_star.recipe b/recipes/windows_star.recipe index 7694b50a1a..714011f6de 100644 --- a/recipes/windows_star.recipe +++ b/recipes/windows_star.recipe @@ -57,7 +57,7 @@ class CanWestPaper(BasicNewsRecipe): divtags = soup.findAll('div', attrs={'id': ''}) if divtags: for div in divtags: - del (div['id']) + del div['id'] return soup def parse_index(self): diff --git a/recipes/wired.recipe b/recipes/wired.recipe index 86e64b7929..8d438fbcad 100644 --- a/recipes/wired.recipe +++ b/recipes/wired.recipe @@ -57,7 +57,7 @@ class WiredDailyNews(BasicNewsRecipe): self.log('Parsing index page', currenturl) soup = self.index_to_soup(currenturl) baseurl = 'https://www.wired.com' - for a in soup.find('div', {'class' : 'multi-packages'}).findAll('a', href=True): + for a in soup.find('div', {'class': 'multi-packages'}).findAll('a', href=True): url = a['href'] if url.startswith('/story') and url.endswith('/'): title = self.tag_to_string(a.parent.find('h3')) diff --git a/recipes/wsj_free.recipe b/recipes/wsj_free.recipe index 8eb2c077d4..db05c4b22a 100644 --- a/recipes/wsj_free.recipe +++ b/recipes/wsj_free.recipe @@ -155,7 +155,7 @@ class WSJ(BasicNewsRecipe): # br.set_debug_http(True) res = br.open(start_url) sso_url = res.geturl() - query = urlparse.parse_qs(urlparse.urlparse(sso_url).query) + query = urlparse.parse_qs(urlparse.urlparse(sso_url).query) query = {k:v[0] for k, v in query.items()} # pprint(query) request_query = { diff --git a/recipes/zeitde.recipe b/recipes/zeitde.recipe index 6b5593432a..d10c212b52 100644 --- a/recipes/zeitde.recipe +++ b/recipes/zeitde.recipe @@ -115,7 +115,7 @@ class ZeitDe(BasicNewsRecipe): def print_version(self, url): # If there is a complete page, use that one req = Request(url=url+'/komplettansicht') - req.get_method = lambda : 'HEAD' + req.get_method = lambda: 'HEAD' try: urlopen(req) return url + '/komplettansicht' diff --git a/recipes/zerkalo.recipe b/recipes/zerkalo.recipe index d134147fc5..daa1aa41fb 100644 --- a/recipes/zerkalo.recipe +++ b/recipes/zerkalo.recipe @@ -21,7 +21,7 @@ class Zerkalo(BasicNewsRecipe): remove_tags_after = dict(name='div', attrs={'id': 'article_body'}) - remove_tags = [ + remove_tags = [ dict(name='div', attrs={'class': 'b-addition m-single m-simplify'}), dict(name='div', attrs={'class': 'b-addition m-simplify'}), dict(name='iframe'), diff --git a/setup/iso_codes.py b/setup/iso_codes.py index 1f9ed9a426..2da0088b87 100644 --- a/setup/iso_codes.py +++ b/setup/iso_codes.py @@ -22,7 +22,7 @@ def iso_codes_data(): class ISOData(Command): description = 'Get ISO codes name localization data' - top_level_filename = 'iso-codes-main' + top_level_filename = 'iso-codes-main' _zip_data = None def add_options(self, parser): diff --git a/setup/plugins_mirror.py b/setup/plugins_mirror.py index d33e4b5893..019b508bbd 100644 --- a/setup/plugins_mirror.py +++ b/setup/plugins_mirror.py @@ -326,7 +326,7 @@ def parse_plugin(raw, names, zf): def get_plugin_init(zf): metadata = None - names = {x.decode('utf-8') if isinstance(x, bytes) else x : x for x in zf.namelist()} + names = {x.decode('utf-8') if isinstance(x, bytes) else x: x for x in zf.namelist()} inits = [x for x in names if x.rpartition('/')[-1] == '__init__.py'] inits.sort(key=lambda x:x.count('/')) if inits and inits[0] == '__init__.py': @@ -378,7 +378,7 @@ def fetch_plugin(old_index, entry): # Previously downloaded plugin lm = datetime(*tuple(map(int, re.split(r'\D', plugin['last_modified'])))[:6]) request = Request(url) - request.get_method = lambda : 'HEAD' + request.get_method = lambda: 'HEAD' with closing(urlopen(request)) as response: info = response.info() slm = datetime(*parsedate(info.get('Last-Modified'))[:6]) diff --git a/setup/translations.py b/setup/translations.py index e205da504d..29f0228914 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -566,7 +566,7 @@ class Translations(POT): # {{{ srcbase = self.j(self.d(self.SRC), 'translations', 'manual') destbase = self.j(self.d(self.SRC), 'manual', 'locale') complete = {} - all_stats = defaultdict(lambda : {'translated': 0, 'untranslated': 0}) + all_stats = defaultdict(lambda: {'translated': 0, 'untranslated': 0}) files = [] for x in os.listdir(srcbase): q = self.j(srcbase, x) diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py index 6513b9de1f..d7a69bfe19 100644 --- a/src/calibre/__init__.py +++ b/src/calibre/__init__.py @@ -266,10 +266,10 @@ def get_parsed_proxy(typ='http', debug=True): if match: try: ans = { - 'host' : match.group('host'), - 'port' : match.group('port'), - 'user' : match.group('user'), - 'pass' : match.group('pass') + 'host': match.group('host'), + 'port': match.group('port'), + 'user': match.group('user'), + 'pass': match.group('pass') } if ans['port']: ans['port'] = int(ans['port']) @@ -452,11 +452,11 @@ def my_unichr(num): XML_ENTITIES = { - '"' : '"', - "'" : ''', - '<' : '<', - '>' : '>', - '&' : '&' + '"': '"', + "'": ''', + '<': '<', + '>': '>', + '&': '&' } diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 2a5cce0df6..497f08e345 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -1171,7 +1171,7 @@ class ActionPluginUpdater(InterfaceActionBase): plugins += [ActionAdd, ActionAllActions, ActionFetchAnnotations, ActionGenerateCatalog, ActionConvert, ActionDelete, ActionEditMetadata, ActionView, ActionFetchNews, ActionSaveToDisk, ActionQuickview, ActionPolish, - ActionShowBookDetails,ActionRestart, ActionOpenFolder, ActionConnectShare, + ActionShowBookDetails, ActionRestart, ActionOpenFolder, ActionConnectShare, ActionSendToDevice, ActionHelp, ActionPreferences, ActionSimilarBooks, ActionAddToLibrary, ActionEditCollections, ActionMatchBooks, ActionShowMatchedBooks, ActionChooseLibrary, ActionCopyToLibrary, ActionTweakEpub, ActionUnpackBook, ActionNextMatch, ActionStore, @@ -1605,7 +1605,7 @@ class StoreBNStore(StoreBase): class StoreBeamEBooksDEStore(StoreBase): name = 'Beam EBooks DE' author = 'Charles Haley' - description = 'Bei uns finden Sie: Tausende deutschsprachige e-books; Alle e-books ohne hartes DRM; PDF, ePub und Mobipocket Format; Sofortige Verfügbarkeit - 24 Stunden am Tag; Günstige Preise; e-books für viele Lesegeräte, PC,Mac und Smartphones; Viele Gratis e-books' # noqa: E501 + description = 'Bei uns finden Sie: Tausende deutschsprachige e-books; Alle e-books ohne hartes DRM; PDF, ePub und Mobipocket Format; Sofortige Verfügbarkeit - 24 Stunden am Tag; Günstige Preise; e-books für viele Lesegeräte, PC, Mac und Smartphones; Viele Gratis e-books' # noqa: E501 actual_plugin = 'calibre.gui2.store.stores.beam_ebooks_de_plugin:BeamEBooksDEStore' drm_free_only = True diff --git a/src/calibre/db/adding.py b/src/calibre/db/adding.py index 749983681d..11a8fa65a6 100644 --- a/src/calibre/db/adding.py +++ b/src/calibre/db/adding.py @@ -78,7 +78,7 @@ def metadata_extensions(): # but not actually added) global _metadata_extensions if _metadata_extensions is None: - _metadata_extensions = frozenset(BOOK_EXTENSIONS) | {'opf'} + _metadata_extensions = frozenset(BOOK_EXTENSIONS) | {'opf'} return _metadata_extensions diff --git a/src/calibre/db/constants.py b/src/calibre/db/constants.py index 0e9aee7cb0..b412bbda05 100644 --- a/src/calibre/db/constants.py +++ b/src/calibre/db/constants.py @@ -7,7 +7,7 @@ from dataclasses import dataclass COVER_FILE_NAME = 'cover.jpg' METADATA_FILE_NAME = 'metadata.opf' DEFAULT_TRASH_EXPIRY_TIME_SECONDS = 14 * 86400 -TRASH_DIR_NAME = '.caltrash' +TRASH_DIR_NAME = '.caltrash' NOTES_DIR_NAME = '.calnotes' NOTES_DB_NAME = 'notes.db' DATA_DIR_NAME = 'data' diff --git a/src/calibre/db/fields.py b/src/calibre/db/fields.py index 885a722097..0380734746 100644 --- a/src/calibre/db/fields.py +++ b/src/calibre/db/fields.py @@ -97,7 +97,7 @@ class Field: self._default_sort_key = '' if self.name == 'languages': - self._sort_key = lambda x:sort_key(calibre_langcode_to_name(x)) + self._sort_key = lambda x: sort_key(calibre_langcode_to_name(x)) self.is_multiple = (bool(self.metadata['is_multiple']) or self.name == 'formats') self.sort_sort_key = True @@ -224,8 +224,8 @@ class OneToOneField(Field): ans = dk return ans return none_safe_key - return lambda book_id:bcmg(book_id, dk) - return lambda book_id:sk(bcmg(book_id, dk)) + return lambda book_id: bcmg(book_id, dk) + return lambda book_id: sk(bcmg(book_id, dk)) def iter_searchable_values(self, get_metadata, candidates, default_value=None): cbm = self.table.book_col_map @@ -339,8 +339,8 @@ class CompositeField(OneToOneField): gv = self.get_value_with_cache sk = self._sort_key if sk is IDENTITY: - return lambda book_id:gv(book_id, get_metadata) - return lambda book_id:sk(gv(book_id, get_metadata)) + return lambda book_id: gv(book_id, get_metadata) + return lambda book_id: sk(gv(book_id, get_metadata)) def iter_searchable_values(self, get_metadata, candidates, default_value=None): val_map = defaultdict(set) @@ -517,7 +517,7 @@ class ManyToOneField(Field): def sort_keys_for_books(self, get_metadata, lang_map): sk_map = LazySortMap(self._default_sort_key, self._sort_key, self.table.id_map) bcmg = self.table.book_col_map.get - return lambda book_id:sk_map(bcmg(book_id, None)) + return lambda book_id: sk_map(bcmg(book_id, None)) def iter_searchable_values(self, get_metadata, candidates, default_value=None): cbm = self.table.col_book_map diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py index 4a7161cdf5..5af14916e2 100644 --- a/src/calibre/db/legacy.py +++ b/src/calibre/db/legacy.py @@ -514,7 +514,7 @@ class LibraryDatabase: with self.new_api.safe_read_lock: book_ids = self.new_api._books_for_field('series', series_id) ff = self.new_api._field_for - return sorted(book_ids, key=lambda x:ff('series_index', x)) + return sorted(book_ids, key=lambda x: ff('series_index', x)) def books_in_series_of(self, index, index_is_id=False): book_id = index if index_is_id else self.id(index) @@ -892,10 +892,10 @@ LibraryDatabase.get_tags = lambda self, book_id:set(self.new_api.field_for('tags LibraryDatabase.get_categories = lambda self, sort='name', ids=None:self.new_api.get_categories(sort=sort, book_ids=ids) LibraryDatabase.get_identifiers = lambda self, index, index_is_id=False: self.new_api.field_for('identifiers', index if index_is_id else self.id(index)) LibraryDatabase.isbn = lambda self, index, index_is_id=False: self.get_identifiers(index, index_is_id=index_is_id).get('isbn', None) -LibraryDatabase.get_books_for_category = lambda self, category, id_:self.new_api.get_books_for_category(category, id_) +LibraryDatabase.get_books_for_category = lambda self, category, id_: self.new_api.get_books_for_category(category, id_) LibraryDatabase.get_data_as_dict = get_data_as_dict -LibraryDatabase.find_identical_books = lambda self, mi:self.new_api.find_identical_books(mi) -LibraryDatabase.get_top_level_move_items = lambda self:self.new_api.get_top_level_move_items() +LibraryDatabase.find_identical_books = lambda self, mi: self.new_api.find_identical_books(mi) +LibraryDatabase.get_top_level_move_items = lambda self: self.new_api.get_top_level_move_items() # }}} # Legacy setter API {{{ @@ -955,7 +955,7 @@ for field in ('authors', 'tags', 'publisher', 'series'): return func name = field[:-1] if field in {'authors', 'tags'} else field setattr(LibraryDatabase, 'all_%s_names' % name, getter(field)) -LibraryDatabase.all_formats = lambda self:self.new_api.all_field_names('formats') +LibraryDatabase.all_formats = lambda self: self.new_api.all_field_names('formats') LibraryDatabase.all_custom = lambda self, label=None, num=None:self.new_api.all_field_names(self.custom_field_name(label, num)) for func, field in iteritems({'all_authors':'authors', 'all_titles':'title', 'all_tags2':'tags', 'all_series':'series', 'all_publishers':'publisher'}): @@ -1030,12 +1030,12 @@ for meth in ('get_next_series_num_for', 'has_book',): return func setattr(LibraryDatabase, meth, getter(meth)) -LibraryDatabase.saved_search_names = lambda self:self.new_api.saved_search_names() -LibraryDatabase.saved_search_lookup = lambda self, x:self.new_api.saved_search_lookup(x) -LibraryDatabase.saved_search_set_all = lambda self, smap:self.new_api.saved_search_set_all(smap) -LibraryDatabase.saved_search_delete = lambda self, x:self.new_api.saved_search_delete(x) -LibraryDatabase.saved_search_add = lambda self, x, y:self.new_api.saved_search_add(x, y) -LibraryDatabase.saved_search_rename = lambda self, x, y:self.new_api.saved_search_rename(x, y) +LibraryDatabase.saved_search_names = lambda self: self.new_api.saved_search_names() +LibraryDatabase.saved_search_lookup = lambda self, x: self.new_api.saved_search_lookup(x) +LibraryDatabase.saved_search_set_all = lambda self, smap: self.new_api.saved_search_set_all(smap) +LibraryDatabase.saved_search_delete = lambda self, x: self.new_api.saved_search_delete(x) +LibraryDatabase.saved_search_add = lambda self, x, y: self.new_api.saved_search_add(x, y) +LibraryDatabase.saved_search_rename = lambda self, x, y: self.new_api.saved_search_rename(x, y) LibraryDatabase.commit_dirty_cache = lambda self: self.new_api.commit_dirty_cache() LibraryDatabase.author_sort_from_authors = lambda self, x: self.new_api.author_sort_from_authors(x) # Cleaning is not required anymore diff --git a/src/calibre/db/search.py b/src/calibre/db/search.py index fea68f7cac..649fda2703 100644 --- a/src/calibre/db/search.py +++ b/src/calibre/db/search.py @@ -416,7 +416,7 @@ class SavedSearchQueries: # {{{ self._db = weakref.ref(db) except TypeError: # db could be None - self._db = lambda : None + self._db = lambda: None self.load_from_db() def load_from_db(self): diff --git a/src/calibre/db/tests/legacy.py b/src/calibre/db/tests/legacy.py index c2e0ded3e0..86e157aa6f 100644 --- a/src/calibre/db/tests/legacy.py +++ b/src/calibre/db/tests/legacy.py @@ -462,7 +462,7 @@ class LegacyTest(BaseTest): 'find_books_in_directory', 'import_book_directory', 'import_book_directory_multiple', 'recursive_import', # Internal API - 'clean_user_categories', 'cleanup_tags', 'books_list_filter', 'conn', 'connect', 'construct_file_name', + 'clean_user_categories', 'cleanup_tags', 'books_list_filter', 'conn', 'connect', 'construct_file_name', 'construct_path_name', 'clear_dirtied', 'initialize_database', 'initialize_dynamic', 'run_import_plugins', 'vacuum', 'set_path', 'row_factory', 'rows', 'rmtree', 'series_index_pat', 'import_old_database', 'dirtied_lock', 'dirtied_cache', 'dirty_books_referencing', diff --git a/src/calibre/db/tests/reading.py b/src/calibre/db/tests/reading.py index b9c099be42..f30eeaa81b 100644 --- a/src/calibre/db/tests/reading.py +++ b/src/calibre/db/tests/reading.py @@ -26,12 +26,12 @@ class ReadingTest(BaseTest): 'Test the reading of data from the database' cache = self.init_cache(self.library_path) tests = { - 3 : { + 3: { 'title': 'Unknown', 'sort': 'Unknown', 'authors': ('Unknown',), 'author_sort': 'Unknown', - 'series' : None, + 'series': None, 'series_index': 1.0, 'rating': None, 'tags': (), @@ -58,12 +58,12 @@ class ReadingTest(BaseTest): 'size':None, }, - 2 : { + 2: { 'title': 'Title One', 'sort': 'One', 'authors': ('Author One',), 'author_sort': 'One, Author', - 'series' : 'A Series One', + 'series': 'A Series One', 'series_index': 1.0, 'tags':('Tag One', 'Tag Two'), 'formats': ('FMT1',), @@ -88,12 +88,12 @@ class ReadingTest(BaseTest): '#comments': '
My Comments One

', 'size':9, }, - 1 : { + 1: { 'title': 'Title Two', 'sort': 'Title Two', 'authors': ('Author Two', 'Author One'), 'author_sort': 'Two, Author & One, Author', - 'series' : 'A Series One', + 'series': 'A Series One', 'series_index': 2.0, 'rating': 6.0, 'tags': ('Tag One', 'News'), @@ -217,7 +217,7 @@ class ReadingTest(BaseTest): cache.set_field('#two', {10:2}) cache.set_field('#three', {i:i for i in range(1, 11)}) ae(list(range(1, 11)), cache.multisort([('#one', True), ('#two', True)], ids_to_sort=sorted(cache.all_book_ids()))) - ae([4, 5, 1, 2, 3, 7,8, 9, 10, 6], cache.multisort([('#one', True), ('#two', False)], ids_to_sort=sorted(cache.all_book_ids()))) + ae([4, 5, 1, 2, 3, 7, 8, 9, 10, 6], cache.multisort([('#one', True), ('#two', False)], ids_to_sort=sorted(cache.all_book_ids()))) ae([5, 4, 3, 2, 1, 10, 9, 8, 7, 6], cache.multisort([('#one', True), ('#two', False), ('#three', False)], ids_to_sort=sorted(cache.all_book_ids()))) # }}} diff --git a/src/calibre/db/tests/writing.py b/src/calibre/db/tests/writing.py index 801dc67377..929b54b5e1 100644 --- a/src/calibre/db/tests/writing.py +++ b/src/calibre/db/tests/writing.py @@ -829,7 +829,7 @@ class WritingTest(BaseTest): changes = [] cache.backend.conn.setupdatehook(lambda typ, dbname, tblname, rowid: changes.append(rowid)) prefs = cache.backend.prefs - prefs['test mutable'] = [1, 2, 3] + prefs['test mutable'] = [1, 2, 3] self.assertEqual(len(changes), 1) a = prefs['test mutable'] a.append(4) diff --git a/src/calibre/db/utils.py b/src/calibre/db/utils.py index b79fc38bde..1adf98b927 100644 --- a/src/calibre/db/utils.py +++ b/src/calibre/db/utils.py @@ -225,7 +225,7 @@ class ThumbnailCache: except OSError as err: self.log('Failed to read thumbnail cache dir:', as_unicode(err)) - self.items = OrderedDict(sorted(items, key=lambda x:order.get(x[0], 0))) + self.items = OrderedDict(sorted(items, key=lambda x: order.get(x[0], 0))) self._apply_size() def _invalidate_sizes(self): diff --git a/src/calibre/debug.py b/src/calibre/debug.py index e0959616f8..ddadff37da 100644 --- a/src/calibre/debug.py +++ b/src/calibre/debug.py @@ -56,15 +56,15 @@ as a shebang in scripts, like this: help=_('Subset the specified font. Use -- after this option to pass option to the font subsetting program.')) parser.add_option('-d', '--debug-device-driver', default=False, action='store_true', help=_('Debug device detection')) - parser.add_option('-g', '--gui', default=False, action='store_true', + parser.add_option('-g', '--gui', default=False, action='store_true', help=_('Run the GUI with debugging enabled. Debug output is ' 'printed to stdout and stderr.')) - parser.add_option('--gui-debug', default=None, + parser.add_option('--gui-debug', default=None, help=_('Run the GUI with a debug console, logging to the' ' specified path. For internal use only, use the -g' ' option to run the GUI in debug mode')) parser.add_option('--run-without-debug', default=False, action='store_true', help=_("Don't run with the DEBUG flag set")) - parser.add_option('-w', '--viewer', default=False, action='store_true', + parser.add_option('-w', '--viewer', default=False, action='store_true', help=_('Run the E-book viewer in debug mode')) parser.add_option('--paths', default=False, action='store_true', help=_('Output the paths necessary to setup the calibre environment')) diff --git a/src/calibre/devices/android/driver.py b/src/calibre/devices/android/driver.py index 8b73d96d12..08964f3217 100644 --- a/src/calibre/devices/android/driver.py +++ b/src/calibre/devices/android/driver.py @@ -26,151 +26,153 @@ class ANDROID(USBMS): VENDOR_ID = { # HTC - 0x0bb4 : {0xc02 : HTC_BCDS, - 0xc01 : HTC_BCDS, - 0xff9 : HTC_BCDS, - 0xc86 : HTC_BCDS, - 0xc87 : HTC_BCDS, - 0xc8d : HTC_BCDS, - 0xc91 : HTC_BCDS, - 0xc92 : HTC_BCDS, - 0xc97 : HTC_BCDS, - 0xc99 : HTC_BCDS, - 0xca2 : HTC_BCDS, - 0xca3 : HTC_BCDS, - 0xca4 : HTC_BCDS, - 0xca9 : HTC_BCDS, - 0xcac : HTC_BCDS, - 0xcba : HTC_BCDS, - 0xccf : HTC_BCDS, - 0xcd6 : HTC_BCDS, - 0xce5 : HTC_BCDS, - 0xcec : HTC_BCDS, - 0x0cf5 : HTC_BCDS, - 0x2910 : HTC_BCDS, - 0xe77 : HTC_BCDS, - 0x0001 : [0x255], + 0x0bb4: { + 0xc02 : HTC_BCDS, + 0xc01 : HTC_BCDS, + 0xff9 : HTC_BCDS, + 0xc86 : HTC_BCDS, + 0xc87 : HTC_BCDS, + 0xc8d : HTC_BCDS, + 0xc91 : HTC_BCDS, + 0xc92 : HTC_BCDS, + 0xc97 : HTC_BCDS, + 0xc99 : HTC_BCDS, + 0xca2 : HTC_BCDS, + 0xca3 : HTC_BCDS, + 0xca4 : HTC_BCDS, + 0xca9 : HTC_BCDS, + 0xcac : HTC_BCDS, + 0xcba : HTC_BCDS, + 0xccf : HTC_BCDS, + 0xcd6 : HTC_BCDS, + 0xce5 : HTC_BCDS, + 0xcec : HTC_BCDS, + 0x0cf5: HTC_BCDS, + 0x2910: HTC_BCDS, + 0xe77 : HTC_BCDS, + 0x0001: [0x255], }, # Eken - 0x040d : {0x8510 : [0x0001], 0x0851 : [0x1]}, + 0x040d: {0x8510: [0x0001], 0x0851: [0x1]}, # Trekstor - 0x1e68 : { - 0x006a : [0x0231], - 0x0062 : [0x222], # Surftab ventos https://bugs.launchpad.net/bugs/1204885 + 0x1e68: { + 0x006a: [0x0231], + 0x0062: [0x222], # Surftab ventos https://bugs.launchpad.net/bugs/1204885 }, # Motorola - 0x22b8 : { - 0x41d9 : [0x216], 0x2d61 : [0x100], 0x2d67 : [0x100], - 0x2de8 : [0x229], - 0x41db : [0x216], 0x4285 : [0x216], 0x42a3 : [0x216], - 0x4286 : [0x216], 0x42b3 : [0x216], 0x42b4 : [0x216], - 0x7086 : [0x0226], 0x70a8: [0x9999], 0x42c4 : [0x216], - 0x70c6 : [0x226], 0x70c7: [0x226], - 0x4316 : [0x216], - 0x4317 : [0x216], - 0x42d6 : [0x216], - 0x42d7 : [0x216], - 0x42f7 : [0x216], - 0x4365 : [0x216], - 0x4366 : [0x216], - 0x4371 : [0x216], + 0x22b8: { + 0x41d9: [0x216], 0x2d61: [0x100], 0x2d67: [0x100], + 0x2de8: [0x229], + 0x41db: [0x216], 0x4285: [0x216], 0x42a3: [0x216], + 0x4286: [0x216], 0x42b3: [0x216], 0x42b4: [0x216], + 0x7086: [0x0226], 0x70a8: [0x9999], 0x42c4: [0x216], + 0x70c6: [0x226], 0x70c7: [0x226], + 0x4316: [0x216], + 0x4317: [0x216], + 0x42d6: [0x216], + 0x42d7: [0x216], + 0x42f7: [0x216], + 0x4365: [0x216], + 0x4366: [0x216], + 0x4371: [0x216], }, # Freescale - 0x15a2 : { - 0x0c01 : [0x226] + 0x15a2: { + 0x0c01: [0x226] }, # Alcatel - 0x05c6 : { - 0x9018 : [0x0226], + 0x05c6: { + 0x9018: [0x0226], }, # Sony Ericsson 0xfce : { - 0xa173 : [0x216], - 0xd12e : [0x0100], - 0xe156 : [0x226], - 0xe15d : [0x226], - 0xe14f : [0x0226], - 0x614f : [0x0226, 0x100], - 0x6156 : [0x0226, 0x100], - }, + 0xa173: [0x216], + 0xd12e: [0x0100], + 0xe156: [0x226], + 0xe15d: [0x226], + 0xe14f: [0x0226], + 0x614f: [0x0226, 0x100], + 0x6156: [0x0226, 0x100], + }, # Google - 0x18d1 : { - 0x0001 : [0x0222, 0x0223, 0x230, 0x255, 0x9999], - 0x0002 : [0x9999], - 0x0003 : [0x0230, 0x9999], - 0x4e11 : [0x0100, 0x226, 0x227], - 0x4e12 : [0x0100, 0x226, 0x227], - 0x4e21 : [0x0100, 0x226, 0x227, 0x231], - 0x4e22 : [0x0100, 0x226, 0x227, 0x231], - 0xb058 : [0x0222, 0x226, 0x227], - 0x0ff9 : [0x0226], - 0xc91 : HTC_BCDS, - 0xdddd : [0x216], - 0x0d01 : [0x9999], - 0x0d02 : [0x9999], - 0x2d01 : [0x9999], - 0xdeed : [0x231, 0x226], + 0x18d1: { + 0x0001: [0x0222, 0x0223, 0x230, 0x255, 0x9999], + 0x0002: [0x9999], + 0x0003: [0x0230, 0x9999], + 0x4e11: [0x0100, 0x226, 0x227], + 0x4e12: [0x0100, 0x226, 0x227], + 0x4e21: [0x0100, 0x226, 0x227, 0x231], + 0x4e22: [0x0100, 0x226, 0x227, 0x231], + 0xb058: [0x0222, 0x226, 0x227], + 0x0ff9: [0x0226], + 0xc91 : HTC_BCDS, + 0xdddd: [0x216], + 0x0d01: [0x9999], + 0x0d02: [0x9999], + 0x2d01: [0x9999], + 0xdeed: [0x231, 0x226], }, # Samsung - 0x04e8 : {0x681d : [0x0222, 0x0223, 0x0224, 0x0400], - 0x681c : [0x0222, 0x0223, 0x0224, 0x0400], - 0x6640 : [0x0100], - 0x685b : [0x0400, 0x0226], - 0x685e : [0x0400, 0x226], - 0x6860 : [0x0400], - 0x6863 : [0x226], - 0x6877 : [0x0400], - 0x689e : [0x0400], - 0xdeed : [0x0222], - 0x1234 : [0x0400], - }, + 0x04e8: { + 0x681d: [0x0222, 0x0223, 0x0224, 0x0400], + 0x681c: [0x0222, 0x0223, 0x0224, 0x0400], + 0x6640: [0x0100], + 0x685b: [0x0400, 0x0226], + 0x685e: [0x0400, 0x226], + 0x6860: [0x0400], + 0x6863: [0x226], + 0x6877: [0x0400], + 0x689e: [0x0400], + 0xdeed: [0x0222], + 0x1234: [0x0400], + }, # Viewsonic/Vizio - 0x0489 : { - 0xc000 : [0x0226], - 0xc001 : [0x0226], - 0xc004 : [0x0226], - 0x8801 : [0x0226, 0x0227], - 0xe115 : [0x0216], # PocketBook A10 + 0x0489: { + 0xc000: [0x0226], + 0xc001: [0x0226], + 0xc004: [0x0226], + 0x8801: [0x0226, 0x0227], + 0xe115: [0x0216], # PocketBook A10 }, # Another Viewsonic - 0x0bb0 : { - 0x2a2b : [0x0226, 0x0227], + 0x0bb0: { + 0x2a2b: [0x0226, 0x0227], }, # Acer - 0x502 : {0x3203 : [0x0100, 0x224]}, + 0x502 : {0x3203: [0x0100, 0x224]}, # Dell - 0x413c : {0xb007 : [0x0100, 0x0224, 0x0226]}, + 0x413c: {0xb007: [0x0100, 0x0224, 0x0226]}, # LG - 0x1004 : { - 0x61c5 : [0x100, 0x226, 0x227, 0x229, 0x9999], - 0x61cc : [0x226, 0x227, 0x9999, 0x100], - 0x61ce : [0x226, 0x227, 0x9999, 0x100], - 0x618e : [0x226, 0x227, 0x9999, 0x100], - 0x6205 : [0x226, 0x227, 0x9999, 0x100], - 0x6234 : [0x231], + 0x1004: { + 0x61c5: [0x100, 0x226, 0x227, 0x229, 0x9999], + 0x61cc: [0x226, 0x227, 0x9999, 0x100], + 0x61ce: [0x226, 0x227, 0x9999, 0x100], + 0x618e: [0x226, 0x227, 0x9999, 0x100], + 0x6205: [0x226, 0x227, 0x9999, 0x100], + 0x6234: [0x231], }, # Archos - 0x0e79 : { - 0x1400 : [0x0222, 0x0216], - 0x1408 : [0x0222, 0x0216], - 0x1411 : [0x216], - 0x1417 : [0x0216], - 0x1419 : [0x0216], - 0x1420 : [0x0216], - 0x1422 : [0x0216] + 0x0e79: { + 0x1400: [0x0222, 0x0216], + 0x1408: [0x0222, 0x0216], + 0x1411: [0x216], + 0x1417: [0x0216], + 0x1419: [0x0216], + 0x1420: [0x0216], + 0x1422: [0x0216] }, # Huawei @@ -178,35 +180,35 @@ class ANDROID(USBMS): # 0x45e : { 0x00e1 : [0x007], }, # T-Mobile - 0x0408 : {0x03ba : [0x0109], }, + 0x0408: {0x03ba: [0x0109]}, # Xperia - 0x13d3 : {0x3304 : [0x0001, 0x0002]}, + 0x13d3: {0x3304: [0x0001, 0x0002]}, # ZTE - 0x19d2 : {0x1353 : [0x226], 0x1351 : [0x227]}, + 0x19d2: {0x1353: [0x226], 0x1351: [0x227]}, # Advent - 0x0955 : {0x7100 : [0x9999]}, # This is the same as the Notion Ink Adam + 0x0955: {0x7100: [0x9999]}, # This is the same as the Notion Ink Adam # Kobo - 0x2237: {0x2208 : [0x0226]}, + 0x2237: {0x2208: [0x0226]}, # Lenovo - 0x17ef : { - 0x7421 : [0x0216], - 0x741b : [0x9999], - 0x7640 : [0x0255], + 0x17ef: { + 0x7421: [0x0216], + 0x741b: [0x9999], + 0x7640: [0x0255], }, # Pantech - 0x10a9 : {0x6050 : [0x227]}, + 0x10a9: {0x6050: [0x227]}, # Prestigio and Teclast - 0x2207 : {0 : [0x222], 0x10 : [0x222]}, + 0x2207: {0: [0x222], 0x10: [0x222]}, # OPPO - 0x22d9 : {0x2768: [0x228]}, + 0x22d9: {0x2768: [0x228]}, } EBOOK_DIR_MAIN = ['eBooks/import', 'wordplayer/calibretransfer', 'Books', diff --git a/src/calibre/devices/kindle/driver.py b/src/calibre/devices/kindle/driver.py index 7a22cef2d8..6c3e08f698 100644 --- a/src/calibre/devices/kindle/driver.py +++ b/src/calibre/devices/kindle/driver.py @@ -312,7 +312,7 @@ class KINDLE(USBMS): divTag.insert(dtc, annot) dtc += 1 - ka_soup.insert(0,divTag) + ka_soup.insert(0, divTag) return ka_soup def add_annotation_to_library(self, db, db_id, annotation): diff --git a/src/calibre/devices/kobo/bookmark.py b/src/calibre/devices/kobo/bookmark.py index 4986509e77..63269ef685 100644 --- a/src/calibre/devices/kobo/bookmark.py +++ b/src/calibre/devices/kobo/bookmark.py @@ -135,7 +135,7 @@ class Bookmark: # {{{ 'chapter_title': chapter_title, 'chapter_progress': chapter_progress} previous_chapter = current_chapter - # debug_print("e_type:" , e_type, '\t', 'loc: ', note_id, 'text: ', text, + # debug_print("e_type:", e_type, '\t', 'loc: ', note_id, 'text: ', text, # 'annotation: ', annotation, 'chapter_title: ', chapter_title, # 'chapter_progress: ', chapter_progress, 'date: ') diff --git a/src/calibre/devices/kobo/books.py b/src/calibre/devices/kobo/books.py index c3f6b306f7..786ae89fef 100644 --- a/src/calibre/devices/kobo/books.py +++ b/src/calibre/devices/kobo/books.py @@ -1,5 +1,5 @@ __license__ = 'GPL v3' -__copyright__ = '2010-2012, , Timothy Legge and David Forrester ' +__copyright__ = '2010-2012, Timothy Legge and David Forrester ' __docformat__ = 'restructuredtext en' import os diff --git a/src/calibre/devices/kobo/driver.py b/src/calibre/devices/kobo/driver.py index 23b93b26b9..91e0f2e2a6 100644 --- a/src/calibre/devices/kobo/driver.py +++ b/src/calibre/devices/kobo/driver.py @@ -292,7 +292,7 @@ class KOBO(USBMS): if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') - # debug_print("LPATH: ", lpath, " - Title: " , title) + # debug_print("LPATH: ", lpath, " - Title: ", title) playlist_map = {} @@ -562,7 +562,7 @@ class KOBO(USBMS): self.report_progress((i+1) / float(len(paths)), _('Removing books from device...')) path = self.normalize_path(path) # print('Delete file normalized path: ' + path) - extension = os.path.splitext(path)[1] + extension = os.path.splitext(path)[1] ContentType = self.get_content_type_from_extension(extension) if extension else self.get_content_type_from_path(path) ContentID = self.contentid_from_path(path, ContentType) @@ -651,7 +651,7 @@ class KOBO(USBMS): def contentid_from_path(self, path, ContentType): if ContentType == 6: - extension = os.path.splitext(path)[1] + extension = os.path.splitext(path)[1] if extension == '.kobo': ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either @@ -770,7 +770,7 @@ class KOBO(USBMS): def get_file(self, path, *args, **kwargs): tpath = self.munge_path(path) - extension = os.path.splitext(tpath)[1] + extension = os.path.splitext(tpath)[1] if extension == '.kobo': from calibre.devices.errors import UserFeedback raise UserFeedback(_('Not Implemented'), @@ -796,7 +796,7 @@ class KOBO(USBMS): mi = MetaInformation(os.path.splitext(os.path.basename(lpath))[0], [_('Unknown')]) size = os.stat(cls.normalize_path(os.path.join(prefix, lpath))).st_size - book = cls.book_class(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=size, other=mi) + book = cls.book_class(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=size, other=mi) return book @@ -948,7 +948,7 @@ class KOBO(USBMS): if category not in book.device_collections: book.device_collections.append(category) - extension = os.path.splitext(book.path)[1] + extension = os.path.splitext(book.path)[1] ContentType = self.get_content_type_from_extension(extension) if extension else self.get_content_type_from_path(book.path) ContentID = self.contentid_from_path(book.path, ContentType) @@ -1062,7 +1062,7 @@ class KOBO(USBMS): if os.path.exists(cover): # Get ContentID for Selected Book - extension = os.path.splitext(filepath)[1] + extension = os.path.splitext(filepath)[1] ContentType = self.get_content_type_from_extension(extension) if extension != '' else self.get_content_type_from_path(filepath) ContentID = self.contentid_from_path(filepath, ContentType) @@ -1231,17 +1231,17 @@ class KOBO(USBMS): bookmarked_books = {} with closing(self.device_database_connection(use_row_factory=True)) as connection: for book_id in path_map: - extension = os.path.splitext(path_map[book_id])[1] + extension = os.path.splitext(path_map[book_id])[1] ContentType = self.get_content_type_from_extension(extension) if extension else self.get_content_type_from_path(path_map[book_id]) ContentID = self.contentid_from_path(path_map[book_id], ContentType) - debug_print('get_annotations - ContentID: ', ContentID, 'ContentType: ', ContentType) + debug_print('get_annotations - ContentID: ', ContentID, 'ContentType: ', ContentType) bookmark_ext = extension myBookmark = Bookmark(connection, ContentID, path_map[book_id], book_id, book_ext[book_id], bookmark_ext) bookmarked_books[book_id] = self.UserAnnotation(type='kobo_bookmark', value=myBookmark) - # This returns as job.result in gui2.ui.annotations_fetched(self,job) + # This returns as job.result in gui2.ui.annotations_fetched(self, job) return bookmarked_books def generate_annotation_html(self, bookmark): @@ -1252,7 +1252,7 @@ class KOBO(USBMS): # last_read_location = bookmark.last_read_location # timestamp = bookmark.timestamp percent_read = bookmark.percent_read - debug_print('Kobo::generate_annotation_html - last_read: ', bookmark.last_read) + debug_print('Kobo::generate_annotation_html - last_read: ', bookmark.last_read) if bookmark.last_read is not None: try: last_read = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(calendar.timegm(time.strptime(bookmark.last_read, '%Y-%m-%dT%H:%M:%S')))) @@ -1348,7 +1348,7 @@ class KOBO(USBMS): divTag.insert(dtc, annot) dtc += 1 - ka_soup.insert(0,divTag) + ka_soup.insert(0, divTag) return ka_soup def add_annotation_to_library(self, db, db_id, annotation): @@ -1358,7 +1358,7 @@ class KOBO(USBMS): if bm.type == 'kobo_bookmark' and bm.value.last_read: mi = db.get_metadata(db_id, index_is_id=True) - debug_print('KOBO:add_annotation_to_library - Title: ', mi.title) + debug_print('KOBO:add_annotation_to_library - Title: ', mi.title) user_notes_soup = self.generate_annotation_html(bm.value) if mi.comments: a_offset = mi.comments.find('
') @@ -1428,9 +1428,9 @@ class KOBOTOUCH(KOBO): min_aurah2o_fwversion = (3, 7, 0) min_reviews_fwversion = (3, 12, 0) min_glohd_fwversion = (3, 14, 0) - min_auraone_fwversion = (3, 20, 7280) - min_fwversion_overdrive = (4, 0, 7523) - min_clarahd_fwversion = (4, 8, 11090) + min_auraone_fwversion = (3, 20, 7280) + min_fwversion_overdrive = (4, 0, 7523) + min_clarahd_fwversion = (4, 8, 11090) min_forma_fwversion = (4, 11, 11879) min_librah20_fwversion = (4, 16, 13337) # "Reviewers" release. min_fwversion_epub_location = (4, 17, 13651) # ePub reading location without full contentid. @@ -1749,7 +1749,7 @@ class KOBOTOUCH(KOBO): if lpath.startswith(os.sep): lpath = lpath[len(os.sep):] lpath = lpath.replace('\\', '/') - # debug_print("KoboTouch:update_booklist - LPATH: ", lpath, " - Title: " , title) + # debug_print("KoboTouch:update_booklist - LPATH: ", lpath, " - Title: ", title) playlist_map = {} @@ -1909,7 +1909,7 @@ class KOBOTOUCH(KOBO): if isdownloaded == 'true': # A recommendation or preview is OK to not have a file debug_print(' Strange: The file: ', prefix, lpath, ' does not exist!') title = 'FILE MISSING: ' + title - book = self.book_class(prefix, lpath, title, authors, MimeType, DateCreated, ContentType, ImageID, size=0) + book = self.book_class(prefix, lpath, title, authors, MimeType, DateCreated, ContentType, ImageID, size=0) if show_debug: debug_print('KoboTouch:update_booklist - book file does not exist. ContentID="%s"'%ContentID) @@ -2491,7 +2491,7 @@ class KOBOTOUCH(KOBO): debug_print("KoboTouch:contentid_from_path - path='%s'"%path, "ContentType='%s'"%ContentType) debug_print("KoboTouch:contentid_from_path - self._main_prefix='%s'"%self._main_prefix, "self._card_a_prefix='%s'"%self._card_a_prefix) if ContentType == 6: - extension = os.path.splitext(path)[1] + extension = os.path.splitext(path)[1] if extension == '.kobo': ContentID = os.path.splitext(path)[0] # Remove the prefix on the file. it could be either @@ -2507,7 +2507,7 @@ class KOBOTOUCH(KOBO): debug_print("KoboTouch:contentid_from_path - 1 ContentID='%s'"%ContentID) if self._card_a_prefix is not None: - ContentID = ContentID.replace(self._card_a_prefix, 'file:///mnt/sd/') + ContentID = ContentID.replace(self._card_a_prefix, 'file:///mnt/sd/') else: # ContentType = 16 debug_print("KoboTouch:contentid_from_path ContentType other than 6 - ContentType='%d'"%ContentType, "path='%s'"%path) ContentID = path @@ -2636,7 +2636,7 @@ class KOBOTOUCH(KOBO): if book.contentID is None: debug_print(' Do not know ContentID - Title="%s", Authors="%s", path="%s"'%(book.title, book.author, book.path)) - extension = os.path.splitext(book.path)[1] + extension = os.path.splitext(book.path)[1] ContentType = self.get_content_type_from_extension(extension) if extension else self.get_content_type_from_path(book.path) book.contentID = self.contentid_from_path(book.path, ContentType) @@ -2880,7 +2880,7 @@ class KOBOTOUCH(KOBO): return # Get ContentID for Selected Book - extension = os.path.splitext(filepath)[1] + extension = os.path.splitext(filepath)[1] ContentType = self.get_content_type_from_extension(extension) if extension else self.get_content_type_from_path(filepath) ContentID = self.contentid_from_path(filepath, ContentType) diff --git a/src/calibre/devices/mtp/filesystem_cache.py b/src/calibre/devices/mtp/filesystem_cache.py index 253bf4971c..674abeebdc 100644 --- a/src/calibre/devices/mtp/filesystem_cache.py +++ b/src/calibre/devices/mtp/filesystem_cache.py @@ -177,7 +177,7 @@ class FileOrFolder: line = '%s%s %s [id:%s %s]'%(prefix, c, self.name, self.object_id, data) prints(line, file=out) for c in (self.folders, self.files): - for e in sorted(c, key=lambda x:sort_key(x.name)): + for e in sorted(c, key=lambda x: sort_key(x.name)): e.dump(prefix=prefix+' ', out=out) def list(self, recurse=False): diff --git a/src/calibre/devices/prs505/sony_cache.py b/src/calibre/devices/prs505/sony_cache.py index 864ff6d9e9..cbfad82082 100644 --- a/src/calibre/devices/prs505/sony_cache.py +++ b/src/calibre/devices/prs505/sony_cache.py @@ -51,7 +51,7 @@ MIME_MAP = { 'lrx' : 'application/x-sony-bbeb', 'rtf' : 'application/rtf', 'pdf' : 'application/pdf', - 'txt' : 'text/plain' , + 'txt' : 'text/plain', 'epub': 'application/epub+zip', } @@ -482,7 +482,7 @@ class XMLCache: try: pubdate = strftime(book.pubdate.utctimetuple(), - zone=lambda x : x) + zone=lambda x: x) record.set('publicationDate', pubdate) except: pass diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index ab01d6d23d..c8d0e52747 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -705,8 +705,8 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): 'metadata': book_metadata, 'thisBook': this_book, 'totalBooks': total_books, 'willStreamBooks': True, - 'willStreamBinary' : True, - 'wantsSendOkToSendbook' : self.can_send_ok_to_sendbook, + 'willStreamBinary': True, + 'wantsSendOkToSendbook': self.can_send_ok_to_sendbook, 'canSupportLpathChanges': True}, print_debug_info=False, wait_for_response=self.can_send_ok_to_sendbook) @@ -744,7 +744,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): lastmod = parse_date(lastmod) if key in self.device_book_cache and self.device_book_cache[key]['book'].last_modified == lastmod: self.device_book_cache[key]['last_used'] = now() - return self.device_book_cache[key]['book'].deepcopy(lambda : SDBook('', '')) + return self.device_book_cache[key]['book'].deepcopy(lambda: SDBook('', '')) except: traceback.print_exc() return None @@ -1247,8 +1247,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): {'location_code': 'main', 'name':name}) @synchronous('sync_lock') - def reset(self, key='-1', log_packets=False, report_progress=None, - detected_device=None) : + def reset(self, key='-1', log_packets=False, report_progress=None, detected_device=None): self._debug() self.set_progress_reporter(report_progress) @@ -1573,7 +1572,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): position = 0 while not eof: opcode, result = self._call_client('GET_BOOK_FILE_SEGMENT', - {'lpath' : path, 'position': position, + {'lpath': path, 'position': position, 'thisBook': this_book, 'totalBooks': total_books, 'canStream':True, 'canStreamBinary': True}, print_debug_info=False) @@ -1614,7 +1613,7 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): other_info['id_link_rules'] = msprefs.get('id_link_rules', {}) self._call_client('SET_LIBRARY_INFO', - {'libraryName' : library_name, + {'libraryName': library_name, 'libraryUuid': library_uuid, 'fieldMetadata': field_metadata.all_metadata(), 'otherInfo': other_info}, diff --git a/src/calibre/devices/winusb.py b/src/calibre/devices/winusb.py index d8c63577ba..6a17123ac5 100644 --- a/src/calibre/devices/winusb.py +++ b/src/calibre/devices/winusb.py @@ -664,7 +664,7 @@ def get_volume_information(drive_letter): flags, serial_number, max_component_length = DWORD(0), DWORD(0), DWORD(0) GetVolumeInformation(drive_letter, vname, len(vname), byref(serial_number), byref(max_component_length), byref(flags), fsname, len(fsname)) flags = flags.value - ans = { + ans = { 'name': vname.value, 'filesystem': fsname.value, 'serial_number': serial_number.value, diff --git a/src/calibre/ebooks/chardet.py b/src/calibre/ebooks/chardet.py index bb2a83ee9d..362c764def 100644 --- a/src/calibre/ebooks/chardet.py +++ b/src/calibre/ebooks/chardet.py @@ -100,7 +100,7 @@ def find_declared_encoding(raw, limit=50*1024): return ans -_CHARSET_ALIASES = {'macintosh' : 'mac-roman', 'x-sjis' : 'shift-jis', 'mac-centraleurope': 'cp1250'} +_CHARSET_ALIASES = {'macintosh': 'mac-roman', 'x-sjis': 'shift-jis', 'mac-centraleurope': 'cp1250'} def detect(bytestring): diff --git a/src/calibre/ebooks/conversion/cli.py b/src/calibre/ebooks/conversion/cli.py index 872c26778d..54e6e86cbd 100644 --- a/src/calibre/ebooks/conversion/cli.py +++ b/src/calibre/ebooks/conversion/cli.py @@ -198,13 +198,13 @@ def add_input_output_options(parser, plumber): def add_pipeline_options(parser, plumber): groups = OrderedDict(( - ('' , ('', + ('', ('', [ 'input_profile', 'output_profile', ] )), - (_('LOOK AND FEEL') , ( + (_('LOOK AND FEEL'), ( _('Options to control the look and feel of the output'), [ 'base_font_size', 'disable_font_rescaling', @@ -223,7 +223,7 @@ def add_pipeline_options(parser, plumber): ] )), - (_('HEURISTIC PROCESSING') , ( + (_('HEURISTIC PROCESSING'), ( _('Modify the document text and structure using common' ' patterns. Disabled by default. Use %(en)s to enable. ' ' Individual actions can be disabled with the %(dis)s options.') @@ -231,7 +231,7 @@ def add_pipeline_options(parser, plumber): ['enable_heuristics'] + HEURISTIC_OPTIONS )), - (_('SEARCH AND REPLACE') , ( + (_('SEARCH AND REPLACE'), ( _('Modify the document text and structure using user defined patterns.'), [ 'sr1_search', 'sr1_replace', @@ -241,7 +241,7 @@ def add_pipeline_options(parser, plumber): ] )), - (_('STRUCTURE DETECTION') , ( + (_('STRUCTURE DETECTION'), ( _('Control auto-detection of document structure.'), [ 'chapter', 'chapter_mark', @@ -251,7 +251,7 @@ def add_pipeline_options(parser, plumber): ] )), - (_('TABLE OF CONTENTS') , ( + (_('TABLE OF CONTENTS'), ( _('Control the automatic generation of a Table of Contents. By ' 'default, if the source file has a Table of Contents, it will ' 'be used in preference to the automatically generated one.'), @@ -262,7 +262,7 @@ def add_pipeline_options(parser, plumber): ] )), - (_('METADATA') , (_('Options to set metadata in the output'), + (_('METADATA'), (_('Options to set metadata in the output'), plumber.metadata_option_names + ['read_metadata_from_opf'], )), (_('DEBUG'), (_('Options to help with debugging the conversion'), diff --git a/src/calibre/ebooks/conversion/plugins/comic_input.py b/src/calibre/ebooks/conversion/plugins/comic_input.py index aaa6df1cbf..c07bac599e 100644 --- a/src/calibre/ebooks/conversion/plugins/comic_input.py +++ b/src/calibre/ebooks/conversion/plugins/comic_input.py @@ -77,11 +77,11 @@ class ComicInput(InputFormatPlugin): recommendations = { ('margin_left', 0, OptionRecommendation.HIGH), - ('margin_top', 0, OptionRecommendation.HIGH), + ('margin_top', 0, OptionRecommendation.HIGH), ('margin_right', 0, OptionRecommendation.HIGH), ('margin_bottom', 0, OptionRecommendation.HIGH), ('insert_blank_line', False, OptionRecommendation.HIGH), - ('remove_paragraph_spacing', False, OptionRecommendation.HIGH), + ('remove_paragraph_spacing', False, OptionRecommendation.HIGH), ('change_justification', 'left', OptionRecommendation.HIGH), ('dont_split_on_pagebreaks', True, OptionRecommendation.HIGH), ('chapter', None, OptionRecommendation.HIGH), diff --git a/src/calibre/ebooks/conversion/plugins/epub_input.py b/src/calibre/ebooks/conversion/plugins/epub_input.py index a3222e685f..f60e6230d0 100644 --- a/src/calibre/ebooks/conversion/plugins/epub_input.py +++ b/src/calibre/ebooks/conversion/plugins/epub_input.py @@ -9,7 +9,7 @@ from itertools import cycle from calibre.customize.conversion import InputFormatPlugin, OptionRecommendation -ADOBE_OBFUSCATION = 'http://ns.adobe.com/pdf/enc#RC' +ADOBE_OBFUSCATION = 'http://ns.adobe.com/pdf/enc#RC' IDPF_OBFUSCATION = 'http://www.idpf.org/2008/embedding' diff --git a/src/calibre/ebooks/conversion/plugins/pdf_output.py b/src/calibre/ebooks/conversion/plugins/pdf_output.py index 4bdbf3c00b..79f9ee0293 100644 --- a/src/calibre/ebooks/conversion/plugins/pdf_output.py +++ b/src/calibre/ebooks/conversion/plugins/pdf_output.py @@ -13,7 +13,7 @@ from calibre.customize.conversion import OptionRecommendation, OutputFormatPlugi from calibre.ptempfile import TemporaryDirectory from polyglot.builtins import iteritems -UNITS = ('millimeter', 'centimeter', 'point', 'inch' , 'pica' , 'didot', +UNITS = ('millimeter', 'centimeter', 'point', 'inch', 'pica', 'didot', 'cicero', 'devicepixel') PAPER_SIZES = ('a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'b0', 'b1', diff --git a/src/calibre/ebooks/conversion/plugins/rtf_input.py b/src/calibre/ebooks/conversion/plugins/rtf_input.py index adc3048cbc..982d5fb0e3 100644 --- a/src/calibre/ebooks/conversion/plugins/rtf_input.py +++ b/src/calibre/ebooks/conversion/plugins/rtf_input.py @@ -11,8 +11,8 @@ from calibre.utils.resources import get_path as P from polyglot.builtins import as_bytes, iteritems border_style_map = { - 'single' : 'solid', - 'double-thickness-border' : 'double', + 'single': 'solid', + 'double-thickness-border': 'double', 'shadowed-border': 'outset', 'double-border': 'double', 'dotted-border': 'dotted', @@ -288,7 +288,7 @@ class RTFInput(InputFormatPlugin): self.log('Converting XML to HTML...') inline_class = InlineClass(self.log) styledoc = safe_xml_fromstring(P('templates/rtf.xsl', data=True), recover=False) - extensions = {('calibre', 'inline-class') : inline_class} + extensions = {('calibre', 'inline-class'): inline_class} transform = etree.XSLT(styledoc, extensions=extensions) result = transform(doc) html = 'index.xhtml' diff --git a/src/calibre/ebooks/conversion/plugins/snb_input.py b/src/calibre/ebooks/conversion/plugins/snb_input.py index 19da8ae2f9..95f08d9b20 100644 --- a/src/calibre/ebooks/conversion/plugins/snb_input.py +++ b/src/calibre/ebooks/conversion/plugins/snb_input.py @@ -49,12 +49,14 @@ class SNBInput(InputFormatPlugin): meta = snbFile.GetFileStream('snbf/book.snbf') if meta is not None: meta = safe_xml_fromstring(meta) - l = {'title' : './/head/name', + l = { + 'title' : './/head/name', 'creator' : './/head/author', 'language' : './/head/language', 'generator': './/head/generator', 'publisher': './/head/publisher', - 'cover' : './/head/cover', } + 'cover' : './/head/cover', + } d = {} for item in l: node = meta.find(l[item]) diff --git a/src/calibre/ebooks/conversion/preprocess.py b/src/calibre/ebooks/conversion/preprocess.py index 79d3daedb2..6815967380 100644 --- a/src/calibre/ebooks/conversion/preprocess.py +++ b/src/calibre/ebooks/conversion/preprocess.py @@ -480,7 +480,7 @@ class HTMLPreProcessor: start_rules = [] if not getattr(self.extra_opts, 'keep_ligatures', False): - html = _ligpat.sub(lambda m:LIGATURES[m.group()], html) + html = _ligpat.sub(lambda m: LIGATURES[m.group()], html) user_sr_rules = {} # Function for processing search and replace diff --git a/src/calibre/ebooks/conversion/utils.py b/src/calibre/ebooks/conversion/utils.py index e8101532fc..6e40d32a31 100644 --- a/src/calibre/ebooks/conversion/utils.py +++ b/src/calibre/ebooks/conversion/utils.py @@ -449,7 +449,7 @@ class HeuristicProcessor: for i in range(2): html = re.sub(r'\s*]*>\s*(]*>\s*){0,2}\s*\s*', ' ', html) html = re.sub( - r'\s*{open}\s*({open}\s*{close}\s*){{0,2}}\s*{close}'.format(open=open_fmt_pat, close=close_fmt_pat) , ' ', html) + r'\s*{open}\s*({open}\s*{close}\s*){{0,2}}\s*{close}'.format(open=open_fmt_pat, close=close_fmt_pat), ' ', html) # delete surrounding divs from empty paragraphs html = re.sub(r']*>\s*]*>\s*

\s*
', '

', html) # Empty heading tags diff --git a/src/calibre/ebooks/djvu/djvu.py b/src/calibre/ebooks/djvu/djvu.py index 9ce34f9514..f7124d7349 100644 --- a/src/calibre/ebooks/djvu/djvu.py +++ b/src/calibre/ebooks/djvu/djvu.py @@ -109,7 +109,7 @@ class DJVUFile: def __init__(self, instream, verbose=0): self.instream = instream buf = self.instream.read(4) - assert (buf == b'AT&T') + assert buf == b'AT&T' buf = self.instream.read() self.dc = DjvuChunk(buf, 0, len(buf), verbose=verbose) diff --git a/src/calibre/ebooks/djvu/djvubzzdec.py b/src/calibre/ebooks/djvu/djvubzzdec.py index 6056e9dd72..d518cdee63 100644 --- a/src/calibre/ebooks/djvu/djvubzzdec.py +++ b/src/calibre/ebooks/djvu/djvubzzdec.py @@ -416,7 +416,7 @@ class BZZDecoder: # Create machine independent ffz table for i in range(256): j = i - while (j & 0x80): + while j & 0x80: self.ffzt[i] += 1 j <<= 1 # Initialize table diff --git a/src/calibre/ebooks/docx/block_styles.py b/src/calibre/ebooks/docx/block_styles.py index 747a7ad535..258a244581 100644 --- a/src/calibre/ebooks/docx/block_styles.py +++ b/src/calibre/ebooks/docx/block_styles.py @@ -88,7 +88,7 @@ LINE_STYLES = { # {{{ 'thick': 'solid', 'thickThinLargeGap': 'double', 'thickThinMediumGap': 'double', - 'thickThinSmallGap' : 'double', + 'thickThinSmallGap': 'double', 'thinThickLargeGap': 'double', 'thinThickMediumGap': 'double', 'thinThickSmallGap': 'double', diff --git a/src/calibre/ebooks/docx/index.py b/src/calibre/ebooks/docx/index.py index 16800f3197..39d9913989 100644 --- a/src/calibre/ebooks/docx/index.py +++ b/src/calibre/ebooks/docx/index.py @@ -106,7 +106,7 @@ def process_index(field, index, xe_fields, log, XPath, expand): if styles: heading_style = styles[0] else: - items = sorted(xe_fields, key=lambda x:sort_key(x['text'])) + items = sorted(xe_fields, key=lambda x: sort_key(x['text'])) hyperlinks = [] blocks = [] diff --git a/src/calibre/ebooks/docx/names.py b/src/calibre/ebooks/docx/names.py index 702177f2b4..34c1d9951d 100644 --- a/src/calibre/ebooks/docx/names.py +++ b/src/calibre/ebooks/docx/names.py @@ -13,24 +13,24 @@ from polyglot.builtins import iteritems # Names {{{ TRANSITIONAL_NAMES = { - 'DOCUMENT' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', - 'DOCPROPS' : 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', - 'APPPROPS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', - 'STYLES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', - 'NUMBERING' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', - 'FONTS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', - 'EMBEDDED_FONT' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font', - 'IMAGES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', - 'LINKS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', - 'FOOTNOTES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes', - 'ENDNOTES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes', - 'THEMES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', - 'SETTINGS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', + 'DOCUMENT' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument', + 'DOCPROPS' : 'http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties', + 'APPPROPS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties', + 'STYLES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles', + 'NUMBERING' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering', + 'FONTS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable', + 'EMBEDDED_FONT': 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/font', + 'IMAGES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/image', + 'LINKS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink', + 'FOOTNOTES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/footnotes', + 'ENDNOTES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/endnotes', + 'THEMES' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme', + 'SETTINGS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings', 'WEB_SETTINGS' : 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings', } STRICT_NAMES = { - k:v.replace('http://schemas.openxmlformats.org/officeDocument/2006', 'http://purl.oclc.org/ooxml/officeDocument') + k:v.replace('http://schemas.openxmlformats.org/officeDocument/2006', 'http://purl.oclc.org/ooxml/officeDocument') for k, v in iteritems(TRANSITIONAL_NAMES) } diff --git a/src/calibre/ebooks/docx/numbering.py b/src/calibre/ebooks/docx/numbering.py index a7cf7451bf..37138e3a96 100644 --- a/src/calibre/ebooks/docx/numbering.py +++ b/src/calibre/ebooks/docx/numbering.py @@ -39,7 +39,7 @@ def alphabet(val, lower=True): alphabet_map = { 'lower-alpha':alphabet, 'upper-alpha':partial(alphabet, lower=False), - 'lower-roman':lambda x:roman(x).lower(), 'upper-roman':roman, + 'lower-roman':lambda x: roman(x).lower(), 'upper-roman':roman, 'decimal-leading-zero': lambda x: '0%d' % x } @@ -361,7 +361,7 @@ class Numbering: if child.tag == 'li': if current_run: last = current_run[-1] - if (last.get('list-id') , last.get('list-lvl')) != (child.get('list-id'), child.get('list-lvl')): + if (last.get('list-id'), last.get('list-lvl')) != (child.get('list-id'), child.get('list-lvl')): commit(current_run) current_run.append(child) else: diff --git a/src/calibre/ebooks/docx/tables.py b/src/calibre/ebooks/docx/tables.py index 11e657e2a9..1a00af4456 100644 --- a/src/calibre/ebooks/docx/tables.py +++ b/src/calibre/ebooks/docx/tables.py @@ -280,7 +280,7 @@ class CellStyle(Style): for x in edges: val = getattr(self, 'cell_padding_%s' % x) if val not in (inherit, 'auto'): - c['padding-%s' % x] = val + c['padding-%s' % x] = val elif val is inherit and x in {'left', 'right'}: c['padding-%s' % x] = '%.3gpt' % (115/20) # In Word, tables are apparently rendered with some default top and diff --git a/src/calibre/ebooks/docx/writer/styles.py b/src/calibre/ebooks/docx/writer/styles.py index cfea03317f..5b299c4076 100644 --- a/src/calibre/ebooks/docx/writer/styles.py +++ b/src/calibre/ebooks/docx/writer/styles.py @@ -479,9 +479,9 @@ def read_css_block_borders(self, css, store_css_style=False): setattr(self, 'css_margin_' + edge, '') setattr(self, 'border_%s_width' % edge, 2) setattr(self, 'border_%s_color' % edge, None) - setattr(self, 'border_%s_style' % edge, 'none') + setattr(self, 'border_%s_style' % edge, 'none') if store_css_style: - setattr(self, 'border_%s_css_style' % edge, 'none') + setattr(self, 'border_%s_css_style' % edge, 'none') else: # In DOCX padding can only be a positive integer try: @@ -500,9 +500,9 @@ def read_css_block_borders(self, css, store_css_style=False): val = min(96, max(2, int(val * 8))) setattr(self, 'border_%s_width' % edge, val) setattr(self, 'border_%s_color' % edge, convert_color(css['border-%s-color' % edge]) or 'auto') - setattr(self, 'border_%s_style' % edge, LINE_STYLES.get(css['border-%s-style' % edge].lower(), 'none')) + setattr(self, 'border_%s_style' % edge, LINE_STYLES.get(css['border-%s-style' % edge].lower(), 'none')) if store_css_style: - setattr(self, 'border_%s_css_style' % edge, css['border-%s-style' % edge].lower()) + setattr(self, 'border_%s_css_style' % edge, css['border-%s-style' % edge].lower()) class BlockStyle(DOCXStyle): diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py index 0e9b9496bb..54f8b6e019 100644 --- a/src/calibre/ebooks/html/input.py +++ b/src/calibre/ebooks/html/input.py @@ -254,7 +254,7 @@ def traverse(path_to_html_file, max_levels=sys.maxsize, verbose=0, encoding=None ''' assert max_levels >= 0 level = 0 - flat = [HTMLFile(path_to_html_file, level, encoding, verbose, correct_case_mismatches=correct_case_mismatches)] + flat = [HTMLFile(path_to_html_file, level, encoding, verbose, correct_case_mismatches=correct_case_mismatches)] seen = {flat[0].path} next_level = list(flat) while level < max_levels and len(next_level) > 0: diff --git a/src/calibre/ebooks/htmlz/oeb2html.py b/src/calibre/ebooks/htmlz/oeb2html.py index 52611d82b0..d3798a8aec 100644 --- a/src/calibre/ebooks/htmlz/oeb2html.py +++ b/src/calibre/ebooks/htmlz/oeb2html.py @@ -338,7 +338,7 @@ class OEB2HTMLClassCSSizer(OEB2HTML): if self.opts.htmlz_class_style == 'external': css = '' else: - css = '' + css = '' title = '%s' % prepare_string_for_xml(self.book_title) output = [''] + \ [css] + [title, ''] + output + [''] diff --git a/src/calibre/ebooks/lrf/__init__.py b/src/calibre/ebooks/lrf/__init__.py index 73dad92c06..865b6a31fc 100644 --- a/src/calibre/ebooks/lrf/__init__.py +++ b/src/calibre/ebooks/lrf/__init__.py @@ -36,7 +36,7 @@ class PRS500_PROFILE: def find_custom_fonts(options, logger): from calibre.utils.fonts.scanner import font_scanner - fonts = {'serif' : None, 'sans' : None, 'mono' : None} + fonts = {'serif': None, 'sans': None, 'mono': None} def family(cmd): return cmd.split(',')[-1].strip() @@ -106,7 +106,7 @@ def Book(options, logger, font_delta=0, header=None, for family in ['serif', 'sans', 'mono']: if not fonts[family]: - fonts[family] = {'normal' : (None, profile.default_fonts[family])} + fonts[family] = {'normal': (None, profile.default_fonts[family])} elif 'normal' not in fonts[family]: raise ConversionError('Could not find the normal version of the ' + family + ' font') return book, fonts diff --git a/src/calibre/ebooks/lrf/fonts.py b/src/calibre/ebooks/lrf/fonts.py index eafc65b95f..9cdda9b282 100644 --- a/src/calibre/ebooks/lrf/fonts.py +++ b/src/calibre/ebooks/lrf/fonts.py @@ -9,9 +9,9 @@ Default fonts used in the PRS500 LIBERATION_FONT_MAP = { - 'Swis721 BT Roman' : 'LiberationSans-Regular', - 'Dutch801 Rm BT Roman' : 'LiberationSerif-Regular', - 'Courier10 BT Roman' : 'LiberationMono-Regular', + 'Swis721 BT Roman' : 'LiberationSans-Regular', + 'Dutch801 Rm BT Roman': 'LiberationSerif-Regular', + 'Courier10 BT Roman' : 'LiberationMono-Regular', } FONT_FILE_MAP = {} diff --git a/src/calibre/ebooks/lrf/html/convert_from.py b/src/calibre/ebooks/lrf/html/convert_from.py index 96e1c8c7ce..a1e7b8731c 100644 --- a/src/calibre/ebooks/lrf/html/convert_from.py +++ b/src/calibre/ebooks/lrf/html/convert_from.py @@ -644,7 +644,7 @@ class HTMLConverter: ans = ntb if found: - targets[fragment] = ans + targets[fragment] = ans page.contents.remove(bs) return ans @@ -1706,7 +1706,7 @@ class HTMLConverter: self.process_children(tag, tag_css, tag_pseudo_css) - if self.current_para.contents : + if self.current_para.contents: self.current_block.append(self.current_para) self.current_para = Paragraph() if tagname.startswith('h') or self.blank_after_para: diff --git a/src/calibre/ebooks/lrf/lrs/convert_from.py b/src/calibre/ebooks/lrf/lrs/convert_from.py index ba8724da65..821a60f32a 100644 --- a/src/calibre/ebooks/lrf/lrs/convert_from.py +++ b/src/calibre/ebooks/lrf/lrs/convert_from.py @@ -327,7 +327,7 @@ def main(args=sys.argv, logger=None): warnings.defaultaction = 'error' logger.info('Parsing LRS file...') - converter = LrsParser(open(args[1], 'rb'), logger) + converter = LrsParser(open(args[1], 'rb'), logger) logger.info('Writing to output file...') converter.render(opts.output, to_lrs=opts.lrs) logger.info('Output written to '+opts.output) diff --git a/src/calibre/ebooks/lrf/meta.py b/src/calibre/ebooks/lrf/meta.py index 367e06a964..1290e11e58 100644 --- a/src/calibre/ebooks/lrf/meta.py +++ b/src/calibre/ebooks/lrf/meta.py @@ -397,7 +397,7 @@ class LRFMetaFile: size = self.compressed_info_size - 4 self._file.seek(self.info_start) try: - src = zlib.decompress(self._file.read(size)) + src = zlib.decompress(self._file.read(size)) if len(src) != self.uncompressed_info_size: raise LRFException('Decompression of document meta info\ yielded unexpected results') @@ -511,7 +511,7 @@ class LRFMetaFile: ''' end = start + struct.calcsize(fmt) self._file.seek(start) - ret = struct.unpack(fmt, self._file.read(end-start)) + ret = struct.unpack(fmt, self._file.read(end-start)) return ret @safe diff --git a/src/calibre/ebooks/lrf/objects.py b/src/calibre/ebooks/lrf/objects.py index 9e8e55108a..b21b407a04 100644 --- a/src/calibre/ebooks/lrf/objects.py +++ b/src/calibre/ebooks/lrf/objects.py @@ -338,11 +338,11 @@ class Page(LRFStream): } tag_map.update(PageAttr.tag_map) tag_map.update(LRFStream.tag_map) - style = property(fget=lambda self : self._document.objects[self.style_id]) - evenheader = property(fget=lambda self : self._document.objects[self.style.evenheaderid]) - evenfooter = property(fget=lambda self : self._document.objects[self.style.evenfooterid]) - oddheader = property(fget=lambda self : self._document.objects[self.style.oddheaderid]) - oddfooter = property(fget=lambda self : self._document.objects[self.style.oddfooterid]) + style = property(fget=lambda self: self._document.objects[self.style_id]) + evenheader = property(fget=lambda self: self._document.objects[self.style.evenheaderid]) + evenfooter = property(fget=lambda self: self._document.objects[self.style.evenfooterid]) + oddheader = property(fget=lambda self: self._document.objects[self.style.oddheaderid]) + oddfooter = property(fget=lambda self: self._document.objects[self.style.oddfooterid]) class Content(LRFContentObject): tag_map = { @@ -531,7 +531,7 @@ class TextCSS: class TextAttr(StyleObject, LRFObject, TextCSS): - FONT_MAP = collections.defaultdict(lambda : 'serif') + FONT_MAP = collections.defaultdict(lambda: 'serif') for key, value in PRS500_PROFILE.default_fonts.items(): FONT_MAP[value] = key @@ -571,8 +571,8 @@ class Block(LRFStream, TextCSS): extra_attrs = [i[0] for i in BlockAttr.tag_map.values()] extra_attrs.extend([i[0] for i in TextAttr.tag_map.values()]) - style = property(fget=lambda self : self._document.objects[self.style_id]) - textstyle = property(fget=lambda self : self._document.objects[self.textstyle_id]) + style = property(fget=lambda self: self._document.objects[self.style_id]) + textstyle = property(fget=lambda self: self._document.objects[self.textstyle_id]) def initialize(self): self.attrs = {} @@ -638,7 +638,7 @@ class Text(LRFStream): tag_map.update(TextAttr.tag_map) tag_map.update(LRFStream.tag_map) - style = property(fget=lambda self : self._document.objects[self.style_id]) + style = property(fget=lambda self: self._document.objects[self.style_id]) text_map = {0x22: '"', 0x26: '&', 0x27: "'", 0x3c: '<', 0x3e: '>'} entity_pattern = re.compile(r'&(\S+?);') @@ -931,8 +931,8 @@ class Image(LRFObject): def parse_image_size(self, tag, f): self.xsize, self.ysize = struct.unpack('\n'%\ @@ -1021,7 +1021,7 @@ class ImageStream(LRFStream): tag_map.update(LRFStream.tag_map) - encoding = property(fget=lambda self : self.imgext[self.stream_flags & 0xFF].upper()) + encoding = property(fget=lambda self: self.imgext[self.stream_flags & 0xFF].upper()) def end_stream(self, *args): LRFStream.end_stream(self, *args) @@ -1122,8 +1122,8 @@ class Button(LRFObject): s += '\n' return s - refpage = property(fget=lambda self : self.jump_action(2)[0]) - refobj = property(fget=lambda self : self.jump_action(2)[1]) + refpage = property(fget=lambda self: self.jump_action(2)[0]) + refobj = property(fget=lambda self: self.jump_action(2)[1]) class Window(LRFObject): @@ -1173,7 +1173,7 @@ class BookAttr(StyleObject, LRFObject): } tag_map.update(ruby_tags) tag_map.update(LRFObject.tag_map) - binding_map = {1: 'Lr', 16 : 'Rl'} + binding_map = {1: 'Lr', 16: 'Rl'} def __init__(self, document, stream, id, scramble_key, boundary): self.font_link_list = [] diff --git a/src/calibre/ebooks/lrf/pylrs/pylrf.py b/src/calibre/ebooks/lrf/pylrs/pylrf.py index d499f62c29..073b893430 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrf.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrf.py @@ -217,7 +217,7 @@ OBJECT_TYPE_ENCODING = dict( TOC=0x1E ) -LINE_TYPE_ENCODING = { +LINE_TYPE_ENCODING = { 'none':0, 'solid':0x10, 'dashed':0x20, 'double':0x30, 'dotted':0x40 } diff --git a/src/calibre/ebooks/lrf/pylrs/pylrs.py b/src/calibre/ebooks/lrf/pylrs/pylrs.py index acce6e17b5..39bbd5ebba 100644 --- a/src/calibre/ebooks/lrf/pylrs/pylrs.py +++ b/src/calibre/ebooks/lrf/pylrs/pylrs.py @@ -1587,7 +1587,7 @@ class DropCaps(LrsTextTag): return self.text is None or not self.text.strip() def toElement(self, se): - elem = Element('DrawChar', line=str(self.line)) + elem = Element('DrawChar', line=str(self.line)) appendTextElements(elem, self.contents, se) return elem @@ -1695,7 +1695,7 @@ class Plot(LrsSimpleChar1, LrsContainer): parent.append(self.obj) def toElement(self, se): - elem = Element('Plot', xsize=str(self.xsize), ysize=str(self.ysize), + elem = Element('Plot', xsize=str(self.xsize), ysize=str(self.ysize), refobj=str(self.obj.objId)) if self.adjustment: elem.set('adjustment', self.adjustment) @@ -2364,7 +2364,7 @@ class ImageBlock(LrsObject, LrsContainer, LrsAttributes): parent.append(self.blockStyle) def getReferencedObjIds(self): - objects = [self.objId, self.extraId, self.refstream.objId] + objects = [self.objId, self.extraId, self.refstream.objId] if self.blockStyle is not None: objects.append(self.blockStyle.objId) diff --git a/src/calibre/ebooks/lrf/tags.py b/src/calibre/ebooks/lrf/tags.py index cef0ba6dd0..7e166f11e3 100644 --- a/src/calibre/ebooks/lrf/tags.py +++ b/src/calibre/ebooks/lrf/tags.py @@ -177,7 +177,7 @@ class Tag: 0xF7 : (4, None), 0xF8 : (4, None), 0xF9 : (6, None), - } + } name_map = {} for key in tags.keys(): temp = tags[key][1] diff --git a/src/calibre/ebooks/metadata/archive.py b/src/calibre/ebooks/metadata/archive.py index af64b240d7..c86f1c5dcb 100644 --- a/src/calibre/ebooks/metadata/archive.py +++ b/src/calibre/ebooks/metadata/archive.py @@ -243,7 +243,7 @@ def get_comic_images(path, tdir, first=1, last=0): # first and last use 1 based if fmt == 'rar': from calibre.utils.unrar import headers for h in headers(path): - items[h['filename']] = lambda : partial(h.get, 'file_time', 0) + items[h['filename']] = lambda: partial(h.get, 'file_time', 0) else: from zipfile import ZipFile with ZipFile(path) as zf: diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py index 1788559fd7..5640e432db 100644 --- a/src/calibre/ebooks/metadata/book/base.py +++ b/src/calibre/ebooks/metadata/book/base.py @@ -213,7 +213,7 @@ class Metadata: if f['datatype'] == 'composite' and f['#value#'] is None: self.get(field) - def deepcopy(self, class_generator=lambda : Metadata(None)): + def deepcopy(self, class_generator=lambda: Metadata(None)): ''' Do not use this method unless you know what you are doing, if you want to create a simple clone of this object, use :meth:`deepcopy_metadata` instead. Class_generator must be a function that returns an instance @@ -772,7 +772,7 @@ class Metadata: if self.title_sort: fmt('Title sort', self.title_sort) if self.authors: - fmt('Author(s)', authors_to_string(self.authors) + + fmt('Author(s)', authors_to_string(self.authors) + ((' [' + self.author_sort + ']') if self.author_sort and self.author_sort != _('Unknown') else '')) if self.publisher: diff --git a/src/calibre/ebooks/metadata/book/json_codec.py b/src/calibre/ebooks/metadata/book/json_codec.py index 99c89dc3ac..9495bac505 100644 --- a/src/calibre/ebooks/metadata/book/json_codec.py +++ b/src/calibre/ebooks/metadata/book/json_codec.py @@ -96,20 +96,20 @@ def encode_is_multiple(fm): if dt == 'composite': fm['is_multiple'] = ',' else: - fm['is_multiple'] = '|' + fm['is_multiple'] = '|' else: fm['is_multiple'] = None fm['is_multiple2'] = {} def decode_is_multiple(fm): - im = fm.get('is_multiple2', None) + im = fm.get('is_multiple2', None) if im: fm['is_multiple'] = im del fm['is_multiple2'] else: # Must migrate the is_multiple from char to dict - im = fm.get('is_multiple', {}) + im = fm.get('is_multiple', {}) if im: dt = fm.get('datatype', None) if dt == 'composite': diff --git a/src/calibre/ebooks/metadata/book/render.py b/src/calibre/ebooks/metadata/book/render.py index 6781ab3f94..d29490685e 100644 --- a/src/calibre/ebooks/metadata/book/render.py +++ b/src/calibre/ebooks/metadata/book/render.py @@ -111,7 +111,7 @@ def mi_to_html( link_note_icon_size=16 ): - link_markup = '↗️' + link_markup = '↗️' if for_qt: s = link_note_icon_size link_markup = f'' diff --git a/src/calibre/ebooks/metadata/html.py b/src/calibre/ebooks/metadata/html.py index 00a4f40e42..11e2d9e3a9 100644 --- a/src/calibre/ebooks/metadata/html.py +++ b/src/calibre/ebooks/metadata/html.py @@ -43,7 +43,7 @@ COMMENT_NAMES = { } META_NAMES = { - 'title' : ('dc.title', 'dcterms.title', 'title'), + 'title': ('dc.title', 'dcterms.title', 'title'), 'authors': ('author', 'dc.creator.aut', 'dcterms.creator.aut', 'dc.creator'), 'publisher': ('publisher', 'dc.publisher', 'dcterms.publisher'), 'isbn': ('isbn',), diff --git a/src/calibre/ebooks/metadata/mobi.py b/src/calibre/ebooks/metadata/mobi.py index 3eba193b34..ce569af3b3 100644 --- a/src/calibre/ebooks/metadata/mobi.py +++ b/src/calibre/ebooks/metadata/mobi.py @@ -181,7 +181,7 @@ class MetadataUpdater: def patch(self, off, new_record0): # Save the current size of each record record_sizes = [len(new_record0)] - for i in range(1,self.nrecs-1): + for i in range(1, self.nrecs-1): record_sizes.append(self.pdbrecords[i+1][0]-self.pdbrecords[i][0]) # And the last one record_sizes.append(self.data.stop - self.pdbrecords[self.nrecs-1][0]) @@ -192,7 +192,7 @@ class MetadataUpdater: record0_offset = self.pdbrecords[0][0] updated_offset = record0_offset + len(new_record0) - for i in range(1,self.nrecs-1): + for i in range(1, self.nrecs-1): updated_pdbrecords.append(updated_offset) updated_offset += record_sizes[i] # Update the last pdbrecord @@ -200,7 +200,7 @@ class MetadataUpdater: # Read in current records 1 to last data_blocks = [new_record0] - for i in range(1,self.nrecs): + for i in range(1, self.nrecs): data_blocks.append(self.data[self.pdbrecords[i][0]:self.pdbrecords[i][0] + record_sizes[i]]) # Rewrite the stream @@ -272,7 +272,7 @@ class MetadataUpdater: new_record0.write(b'\0'*(1024*8)) # Rebuild the stream, update the pdbrecords pointers - self.patchSection(0,new_record0.getvalue()) + self.patchSection(0, new_record0.getvalue()) # Update record0 self.record0 = self.record(0) @@ -283,7 +283,7 @@ class MetadataUpdater: N=0 result='' while src: - s,src = src[:length],src[length:] + s, src = src[:length],src[length:] hexa = ' '.join(['%02X'%ord(x) for x in s]) s = s.translate(FILTER) result += '%04X %-*s %s\n' % (N, length*3, hexa, s) @@ -448,7 +448,7 @@ class MetadataUpdater: if mi.cover_data[1] or mi.cover: try: - data = mi.cover_data[1] + data = mi.cover_data[1] if not data: with open(mi.cover, 'rb') as f: data = f.read() diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py index b29662a57d..e4be124993 100644 --- a/src/calibre/ebooks/metadata/opf2.py +++ b/src/calibre/ebooks/metadata/opf2.py @@ -568,7 +568,7 @@ def dump_dict(cats): XPATH_NS = { - 'dc': 'http://purl.org/dc/elements/1.1/', + 'dc' : 'http://purl.org/dc/elements/1.1/', 'opf': 'http://www.idpf.org/2007/opf', 're' : 'http://exslt.org/regular-expressions' } @@ -843,7 +843,7 @@ class OPF: # {{{ def create_guide_element(self): e = etree.SubElement(self.root, '{%s}guide'%self.NAMESPACES['opf']) e.text = '\n ' - e.tail = '\n' + e.tail = '\n' return e def remove_guide(self): diff --git a/src/calibre/ebooks/metadata/pdb.py b/src/calibre/ebooks/metadata/pdb.py index 46673b577a..931c8707ce 100644 --- a/src/calibre/ebooks/metadata/pdb.py +++ b/src/calibre/ebooks/metadata/pdb.py @@ -15,18 +15,18 @@ from calibre.ebooks.metadata.plucker import get_metadata as get_plucker from calibre.ebooks.pdb.header import PdbHeaderReader MREADER = { - 'PNPdPPrs' : get_eReader, - 'PNRdPPrs' : get_eReader, - 'DataPlkr' : get_plucker, - 'BOOKMTIT' : get_Haodoo, - 'BOOKMTIU' : get_Haodoo, + 'PNPdPPrs': get_eReader, + 'PNRdPPrs': get_eReader, + 'DataPlkr': get_plucker, + 'BOOKMTIT': get_Haodoo, + 'BOOKMTIU': get_Haodoo, } from calibre.ebooks.metadata.ereader import set_metadata as set_eReader MWRITER = { - 'PNPdPPrs' : set_eReader, - 'PNRdPPrs' : set_eReader, + 'PNPdPPrs': set_eReader, + 'PNRdPPrs': set_eReader, } diff --git a/src/calibre/ebooks/metadata/sources/amazon.py b/src/calibre/ebooks/metadata/sources/amazon.py index c2308ef88b..4a623d00dc 100644 --- a/src/calibre/ebooks/metadata/sources/amazon.py +++ b/src/calibre/ebooks/metadata/sources/amazon.py @@ -333,7 +333,7 @@ class Worker(Thread): # Get details {{{ self.publisher_names = {'Publisher', 'Uitgever', 'Verlag', 'Utgivare', 'Herausgeber', 'Editore', 'Editeur', 'Éditeur', 'Editor', 'Editora', '出版社'} - self.language_xpath = ''' + self.language_xpath = ''' descendant::*[ starts-with(text(), "Language:") \ or text() = "Language" \ diff --git a/src/calibre/ebooks/metadata/sources/search_engines.py b/src/calibre/ebooks/metadata/sources/search_engines.py index 7e831f2311..91c08b2a4f 100644 --- a/src/calibre/ebooks/metadata/sources/search_engines.py +++ b/src/calibre/ebooks/metadata/sources/search_engines.py @@ -224,7 +224,7 @@ def resolve_bing_wrapper_page(url, br, log): raw = br.open_novisit(url).read().decode('utf-8', 'replace') m = re.search(r'var u = "(.+)"', raw) if m is None: - log('Failed to resolve bing wrapper page for url: ' + url) + log('Failed to resolve bing wrapper page for url: ' + url) return url log('Resolved bing wrapped URL: ' + url + ' to ' + m.group(1)) return m.group(1) diff --git a/src/calibre/ebooks/metadata/topaz.py b/src/calibre/ebooks/metadata/topaz.py index 9829326e2b..847010cb06 100644 --- a/src/calibre/ebooks/metadata/topaz.py +++ b/src/calibre/ebooks/metadata/topaz.py @@ -158,7 +158,7 @@ class MetadataUpdater: N=0 result='' while src: - s,src = src[:length],src[length:] + s, src = src[:length],src[length:] hexa = ' '.join(['%02X'%ord(x) for x in s]) s = s.translate(FILTER) result += '%04X %-*s %s\n' % (N, length*3, hexa, s) @@ -170,7 +170,7 @@ class MetadataUpdater: for tag in self.metadata: print(f'{tag}: {self.metadata[tag]!r}') - def encode_vwi(self,value): + def encode_vwi(self, value): ans = [] multi_byte = (value > 0x7f) while value: @@ -333,7 +333,7 @@ class MetadataUpdater: self.original_md_len = original_md_len return ths.getvalue().encode('iso-8859-1') - def update(self,mi): + def update(self, mi): # Collect the original metadata self.get_original_metadata() diff --git a/src/calibre/ebooks/mobi/debug/headers.py b/src/calibre/ebooks/mobi/debug/headers.py index 701fc389ee..56d801b805 100644 --- a/src/calibre/ebooks/mobi/debug/headers.py +++ b/src/calibre/ebooks/mobi/debug/headers.py @@ -298,18 +298,18 @@ class MOBIHeader: # {{{ self.length, = struct.unpack(b'>I', self.raw[20:24]) self.type_raw, = struct.unpack(b'>I', self.raw[24:28]) self.type = { - 2 : 'Mobipocket book', - 3 : 'PalmDOC book', - 4 : 'Audio', - 257 : 'News', - 258 : 'News Feed', - 259 : 'News magazine', - 513 : 'PICS', - 514 : 'Word', - 515 : 'XLS', - 516 : 'PPT', - 517 : 'TEXT', - 518 : 'HTML', + 2 : 'Mobipocket book', + 3 : 'PalmDOC book', + 4 : 'Audio', + 257: 'News', + 258: 'News Feed', + 259: 'News magazine', + 513: 'PICS', + 514: 'Word', + 515: 'XLS', + 516: 'PPT', + 517: 'TEXT', + 518: 'HTML', }.get(self.type_raw, repr(self.type_raw)) self.encoding_raw, = struct.unpack(b'>I', self.raw[28:32]) diff --git a/src/calibre/ebooks/mobi/debug/mobi6.py b/src/calibre/ebooks/mobi/debug/mobi6.py index 5db395e366..50ecbddb44 100644 --- a/src/calibre/ebooks/mobi/debug/mobi6.py +++ b/src/calibre/ebooks/mobi/debug/mobi6.py @@ -242,12 +242,12 @@ class Tag: # {{{ ''' TAG_MAP = { - 1: ('offset', 'Offset in HTML'), - 2: ('size', 'Size in HTML'), - 3: ('label_offset', 'Label offset in CNCX'), - 4: ('depth', 'Depth of this entry in TOC'), - 5: ('class_offset', 'Class offset in CNCX'), - 6: ('pos_fid', 'File Index'), + 1 : ('offset', 'Offset in HTML'), + 2 : ('size', 'Size in HTML'), + 3 : ('label_offset', 'Label offset in CNCX'), + 4 : ('depth', 'Depth of this entry in TOC'), + 5 : ('class_offset', 'Class offset in CNCX'), + 6 : ('pos_fid', 'File Index'), 11: ('secondary', '[unknown, unknown, ' 'tag type from TAGX in primary index header]'), @@ -256,14 +256,14 @@ class Tag: # {{{ 22: ('first_child_index', 'First child'), 23: ('last_child_index', 'Last child'), - 69 : ('image_index', 'Offset from first image record to the' + 69: ('image_index', 'Offset from first image record to the' ' image record associated with this entry' ' (masthead for periodical or thumbnail for' ' article entry).'), - 70 : ('desc_offset', 'Description offset in cncx'), - 71 : ('author_offset', 'Author offset in cncx'), - 72 : ('image_caption_offset', 'Image caption offset in cncx'), - 73 : ('image_attr_offset', 'Image attribution offset in cncx'), + 70: ('desc_offset', 'Description offset in cncx'), + 71: ('author_offset', 'Author offset in cncx'), + 72: ('image_caption_offset', 'Image caption offset in cncx'), + 73: ('image_attr_offset', 'Image attribution offset in cncx'), } diff --git a/src/calibre/ebooks/mobi/mobiml.py b/src/calibre/ebooks/mobi/mobiml.py index 81983b2522..e60d7dc59e 100644 --- a/src/calibre/ebooks/mobi/mobiml.py +++ b/src/calibre/ebooks/mobi/mobiml.py @@ -305,7 +305,7 @@ class MobiMLizer: inline = etree.SubElement(inline, XHTML('i')) if istate.bold: inline = etree.SubElement(inline, XHTML('b')) - if istate.bgcolor is not None and istate.bgcolor != 'transparent' : + if istate.bgcolor is not None and istate.bgcolor != 'transparent': inline = etree.SubElement(inline, XHTML('span'), bgcolor=convert_color_for_font_tag(istate.bgcolor)) if istate.fgcolor != 'black': diff --git a/src/calibre/ebooks/mobi/reader/headers.py b/src/calibre/ebooks/mobi/reader/headers.py index 561998fba1..68f77b80bb 100644 --- a/src/calibre/ebooks/mobi/reader/headers.py +++ b/src/calibre/ebooks/mobi/reader/headers.py @@ -45,7 +45,7 @@ class EXTHHeader: # {{{ self.page_progression_direction = None self.primary_writing_mode = None - self.decode = lambda x : clean_ascii_chars(x.decode(codec, 'replace')) + self.decode = lambda x: clean_ascii_chars(x.decode(codec, 'replace')) while left > 0: left -= 1 diff --git a/src/calibre/ebooks/mobi/reader/ncx.py b/src/calibre/ebooks/mobi/reader/ncx.py index 756b955ad5..c4de800492 100644 --- a/src/calibre/ebooks/mobi/reader/ncx.py +++ b/src/calibre/ebooks/mobi/reader/ncx.py @@ -24,10 +24,10 @@ tag_fieldname_map = { 22: ['child1',0], 23: ['childn',0], 69: ['image_index',0], - 70 : ['desc_offset', 0], # 'Description offset in cncx' - 71 : ['author_offset', 0], # 'Author offset in cncx' - 72 : ['image_caption_offset', 0], # 'Image caption offset in cncx', - 73 : ['image_attr_offset', 0], # 'Image attribution offset in cncx', + 70: ['desc_offset', 0], # 'Description offset in cncx' + 71: ['author_offset', 0], # 'Author offset in cncx' + 72: ['image_caption_offset', 0], # 'Image caption offset in cncx', + 73: ['image_attr_offset', 0], # 'Image attribution offset in cncx', } @@ -35,13 +35,13 @@ default_entry = { 'pos': -1, 'len': 0, 'noffs': -1, - 'text' : 'Unknown Text', - 'hlvl' : -1, - 'kind' : 'Unknown Class', - 'pos_fid' : None, - 'parent' : -1, - 'child1' : -1, - 'childn' : -1, + 'text': 'Unknown Text', + 'hlvl': -1, + 'kind': 'Unknown Class', + 'pos_fid': None, + 'parent': -1, + 'child1': -1, + 'childn': -1, 'description': None, 'author': None, 'image_caption': None, diff --git a/src/calibre/ebooks/mobi/writer2/indexer.py b/src/calibre/ebooks/mobi/writer2/indexer.py index 2cc7bc99df..0aeb1bbf75 100644 --- a/src/calibre/ebooks/mobi/writer2/indexer.py +++ b/src/calibre/ebooks/mobi/writer2/indexer.py @@ -37,7 +37,7 @@ class TAGX: # {{{ BITMASKS.update({x:(1 << i) for i, x in enumerate([1, 2, 3, 4, 5, 21, 22, 23])}) BITMASKS.update({x:(1 << i) for i, x in enumerate([69, 70, 71, 72, 73])}) - NUM_VALUES = defaultdict(lambda :1) + NUM_VALUES = defaultdict(lambda:1) NUM_VALUES[11] = 3 NUM_VALUES[0] = 0 @@ -64,7 +64,7 @@ class TAGX: # {{{ ''' TAGX block for the Primary index header of a periodical ''' - for i in (1, 2, 3, 4, 5, 21, 22, 23, 0, 69, 70, 71, 72,73, 0): + for i in (1, 2, 3, 4, 5, 21, 22, 23, 0, 69, 70, 71, 72, 73, 0): self.add_tag(i) return self.header(2) + bytes(self.byts) diff --git a/src/calibre/ebooks/mobi/writer2/serializer.py b/src/calibre/ebooks/mobi/writer2/serializer.py index 37554eb45a..d26660b25d 100644 --- a/src/calibre/ebooks/mobi/writer2/serializer.py +++ b/src/calibre/ebooks/mobi/writer2/serializer.py @@ -163,7 +163,7 @@ class Serializer: continue buf.write(b'\n'%encoding + ans - return re.sub(r'&#x([0-9A-Fa-f]+);', lambda m:my_unichr(int(m.group(1), 16)), + return re.sub(r'&#x([0-9A-Fa-f]+);', lambda m: my_unichr(int(m.group(1), 16)), ans).encode(encoding) @@ -432,9 +432,9 @@ class Chunker: 'wb') as f: f.write(chunk.raw) oraw, rraw = orig_dumps[i], skeleton.rebuild() - with open(os.path.join(orig, '%04d.html'%i), 'wb') as f: + with open(os.path.join(orig, '%04d.html'%i), 'wb') as f: f.write(oraw) - with open(os.path.join(rebuilt, '%04d.html'%i), 'wb') as f: + with open(os.path.join(rebuilt, '%04d.html'%i), 'wb') as f: f.write(rraw) if oraw != rraw: error = True diff --git a/src/calibre/ebooks/oeb/normalize_css.py b/src/calibre/ebooks/oeb/normalize_css.py index aed56f5691..80d28d3011 100644 --- a/src/calibre/ebooks/oeb/normalize_css.py +++ b/src/calibre/ebooks/oeb/normalize_css.py @@ -343,7 +343,7 @@ def test_normalization(return_tests=False): # {{{ def test_edge_normalization(self): def edge_dict(prefix, expected): - return {f'{prefix}-{edge}' : x for edge, x in zip(EDGES, expected)} + return {f'{prefix}-{edge}': x for edge, x in zip(EDGES, expected)} for raw, expected in iteritems({ '2px': ('2px', '2px', '2px', '2px'), '1em 2em': ('1em', '2em', '1em', '2em'), @@ -356,7 +356,7 @@ def test_normalization(return_tests=False): # {{{ def test_list_style_normalization(self): def ls_dict(expected): - ans = {'list-style-%s' % x : DEFAULTS['list-style-%s' % x] for x in ('type', 'image', 'position')} + ans = {'list-style-%s' % x: DEFAULTS['list-style-%s' % x] for x in ('type', 'image', 'position')} for k, v in iteritems(expected): ans['list-style-%s' % k] = v return ans @@ -385,17 +385,17 @@ def test_normalization(return_tests=False): # {{{ def test_edge_condensation(self): for s, v in iteritems({ - (1, 1, 3) : None, - (1, 2, 3, 4) : '2pt 3pt 4pt 1pt', - (1, 2, 3, 2) : '2pt 3pt 2pt 1pt', - (1, 2, 1, 3) : '2pt 1pt 3pt', - (1, 2, 1, 2) : '2pt 1pt', - (1, 1, 1, 1) : '1pt', - ('2%', '2%', '2%', '2%') : '2%', - tuple('0 0 0 0'.split()) : '0', + (1, 1, 3): None, + (1, 2, 3, 4): '2pt 3pt 4pt 1pt', + (1, 2, 3, 2): '2pt 3pt 2pt 1pt', + (1, 2, 1, 3): '2pt 1pt 3pt', + (1, 2, 1, 2): '2pt 1pt', + (1, 1, 1, 1): '1pt', + ('2%', '2%', '2%', '2%'): '2%', + tuple('0 0 0 0'.split()): '0', }): for prefix in ('margin', 'padding'): - css = {f'{prefix}-{x}' : str(y)+'pt' if isinstance(y, numbers.Number) else y + css = {f'{prefix}-{x}': str(y)+'pt' if isinstance(y, numbers.Number) else y for x, y in zip(('left', 'top', 'right', 'bottom'), s)} css = '; '.join((f'{k}:{v}' for k, v in iteritems(css))) style = parseStyle(css) diff --git a/src/calibre/ebooks/oeb/parse_utils.py b/src/calibre/ebooks/oeb/parse_utils.py index 9b18af37e8..cc60faf286 100644 --- a/src/calibre/ebooks/oeb/parse_utils.py +++ b/src/calibre/ebooks/oeb/parse_utils.py @@ -198,7 +198,7 @@ def parse_html(data, log=None, decoder=None, preprocessor=None, user_entities[match.group(1)] = val if user_entities: pat = re.compile(r'&(%s);'%('|'.join(list(user_entities.keys())))) - data = pat.sub(lambda m:user_entities[m.group(1)], data) + data = pat.sub(lambda m: user_entities[m.group(1)], data) if preprocessor is not None: data = preprocessor(data) diff --git a/src/calibre/ebooks/oeb/polish/check/parsing.py b/src/calibre/ebooks/oeb/polish/check/parsing.py index 0961fb2253..b25e2e7f17 100644 --- a/src/calibre/ebooks/oeb/polish/check/parsing.py +++ b/src/calibre/ebooks/oeb/polish/check/parsing.py @@ -105,7 +105,7 @@ class NamedEntities(BaseError): for name, mt in iteritems(container.mime_map): if mt in check_types: raw = container.raw_data(name) - nraw = replace_pat.sub(lambda m:html5_entities[m.group(1)], raw) + nraw = replace_pat.sub(lambda m: html5_entities[m.group(1)], raw) if raw != nraw: changed = True with container.open(name, 'wb') as f: diff --git a/src/calibre/ebooks/oeb/polish/parsing.py b/src/calibre/ebooks/oeb/polish/parsing.py index f0abc42e78..1f20b6a9a2 100644 --- a/src/calibre/ebooks/oeb/polish/parsing.py +++ b/src/calibre/ebooks/oeb/polish/parsing.py @@ -57,7 +57,7 @@ def handle_private_entities(data): if user_entities: data = ('\n' * num_of_nl_in_pre) + data[idx:] pat = re.compile(r'&(%s);'%('|'.join(user_entities.keys()))) - data = pat.sub(lambda m:user_entities[m.group(1)], data) + data = pat.sub(lambda m: user_entities[m.group(1)], data) return data diff --git a/src/calibre/ebooks/oeb/polish/report.py b/src/calibre/ebooks/oeb/polish/report.py index 00dc9f5ccf..9c3f95b0ab 100644 --- a/src/calibre/ebooks/oeb/polish/report.py +++ b/src/calibre/ebooks/oeb/polish/report.py @@ -270,7 +270,7 @@ def css_data(container, book_locale, result_data, *args): html_sheets[name].append( css_rules(name, parser.parse_stylesheet(force_unicode(style.text, 'utf-8')).rules, style.sourceline - 1)) - rule_map = defaultdict(lambda : defaultdict(list)) + rule_map = defaultdict(lambda: defaultdict(list)) def rules_in_sheet(sheet): for rule in sheet: @@ -323,11 +323,11 @@ def css_data(container, book_locale, result_data, *args): return (MatchLocation(tag_text(elem), elem.sourceline) for elem in matches) - class_map = defaultdict(lambda : defaultdict(list)) + class_map = defaultdict(lambda: defaultdict(list)) for name, inline_sheets in iteritems(html_sheets): root = container.parsed(name) - cmap = defaultdict(lambda : defaultdict(list)) + cmap = defaultdict(lambda: defaultdict(list)) for elem in root.xpath('//*[@class]'): for cls in elem.get('class', '').split(): cmap[cls][elem] = [] diff --git a/src/calibre/ebooks/oeb/polish/tests/structure.py b/src/calibre/ebooks/oeb/polish/tests/structure.py index 4304994bdd..a5822ae83b 100644 --- a/src/calibre/ebooks/oeb/polish/tests/structure.py +++ b/src/calibre/ebooks/oeb/polish/tests/structure.py @@ -93,7 +93,7 @@ class Structure(BaseTest): self.assertTrue(len(get_toc(c))) # detect NCX toc even in epub 3 files c.add_file('nav.html', b'' b'
', - process_manifest_item=lambda item:item.set('properties', 'nav')) + process_manifest_item=lambda item: item.set('properties', 'nav')) toc = get_toc(c) self.assertTrue(len(toc)) self.assertEqual(toc.as_dict['children'][0]['title'], 'EPUB 3 nav') @@ -133,7 +133,7 @@ class Structure(BaseTest): b'', - process_manifest_item=lambda item:item.set('properties', 'nav')) + process_manifest_item=lambda item: item.set('properties', 'nav')) self.assertEqual([ {'dest':'xxx.html', 'frag':'moo', 'type':'x', 'title':'XXX'}, {'dest':'a.html', 'frag':'', 'type':'', 'title':'YYY'} ], get_landmarks(c)) diff --git a/src/calibre/ebooks/oeb/transforms/flatcss.py b/src/calibre/ebooks/oeb/transforms/flatcss.py index cc8aeb7d8c..d3df1ebe3b 100644 --- a/src/calibre/ebooks/oeb/transforms/flatcss.py +++ b/src/calibre/ebooks/oeb/transforms/flatcss.py @@ -290,7 +290,7 @@ class CSSFlattener: body = html.find(XHTML('body')) if 'style' in html.attrib: b = body.attrib.get('style', '') - body.set('style', html.get('style') + ';' + b) + body.set('style', html.get('style') + ';' + b) del html.attrib['style'] bs = body.get('style', '').split(';') bs.append('margin-top: 0pt') @@ -534,7 +534,7 @@ class CSSFlattener: indent_size = self.context.remove_paragraph_spacing_indent_size keep_indents = indent_size < 0.0 if (self.context.remove_paragraph_spacing and not keep_indents and cssdict.get('text-align', None) not in ('center', 'right')): - cssdict['text-indent'] = '%1.1fem' % indent_size + cssdict['text-indent'] = '%1.1fem' % indent_size pseudo_classes = style.pseudo_classes(self.filter_css) if cssdict or pseudo_classes: @@ -696,9 +696,9 @@ class CSSFlattener: fsize = self.context.dest.fbase self.flatten_node(html, stylizer, names, styles, pseudo_styles, fsize, item.id, recurse=False) self.flatten_node(html.find(XHTML('body')), stylizer, names, styles, pseudo_styles, fsize, item.id) - items = sorted(((key, val) for (val, key) in iteritems(styles)), key=lambda x:numeric_sort_key(x[0])) + items = sorted(((key, val) for (val, key) in iteritems(styles)), key=lambda x: numeric_sort_key(x[0])) # :hover must come after link and :active must come after :hover - psels = sorted(pseudo_styles, key=lambda x : + psels = sorted(pseudo_styles, key=lambda x: {'hover':1, 'active':2}.get(x, 0)) for psel in psels: styles = pseudo_styles[psel] diff --git a/src/calibre/ebooks/oeb/transforms/metadata.py b/src/calibre/ebooks/oeb/transforms/metadata.py index bd99f0d0bf..7893793c37 100644 --- a/src/calibre/ebooks/oeb/transforms/metadata.py +++ b/src/calibre/ebooks/oeb/transforms/metadata.py @@ -24,17 +24,17 @@ def meta_info_to_oeb_metadata(mi, m, log, override_input_metadata=False): m.clear('title_sort') m.add('title_sort', mi.title_sort) if not mi.is_null('authors'): - m.filter('creator', lambda x : x.role.lower() in ['aut', '']) + m.filter('creator', lambda x: x.role.lower() in ['aut', '']) for a in mi.authors: attrib = {'role':'aut'} if mi.author_sort: attrib[OPF('file-as')] = mi.author_sort m.add('creator', a, attrib=attrib) if not mi.is_null('book_producer'): - m.filter('contributor', lambda x : x.role.lower() == 'bkp') + m.filter('contributor', lambda x: x.role.lower() == 'bkp') m.add('contributor', mi.book_producer, role='bkp') elif override_input_metadata: - m.filter('contributor', lambda x : x.role.lower() == 'bkp') + m.filter('contributor', lambda x: x.role.lower() == 'bkp') if not mi.is_null('comments'): m.clear('description') m.add('description', mi.comments) diff --git a/src/calibre/ebooks/oeb/transforms/split.py b/src/calibre/ebooks/oeb/transforms/split.py index 93b5da866c..324e47e2bb 100644 --- a/src/calibre/ebooks/oeb/transforms/split.py +++ b/src/calibre/ebooks/oeb/transforms/split.py @@ -131,7 +131,7 @@ class Split: continue page_breaks = list(page_breaks) - page_breaks.sort(key=lambda x:int(x.get('pb_order'))) + page_breaks.sort(key=lambda x: int(x.get('pb_order'))) page_break_ids, page_breaks_ = [], [] for i, x in enumerate(page_breaks): x.set('id', x.get('id', 'calibre_pb_%d'%i)) @@ -426,7 +426,7 @@ class FlowSplitter: ''' if not self.was_split: return - self.anchor_map = collections.defaultdict(lambda :self.base%0) + self.anchor_map = collections.defaultdict(lambda: self.base%0) self.files = [] for i, tree in enumerate(self.trees): diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py index 342a2a0957..92100692a5 100644 --- a/src/calibre/ebooks/pdf/reflow.py +++ b/src/calibre/ebooks/pdf/reflow.py @@ -170,7 +170,7 @@ class Text(Element): ('top', 'left', 'width', 'height')))) # This does nothing, as expected, # but somewhere left (at least) is changed sometimes to not .0 - if self.left != round(self.left) : + if self.left != round(self.left): self.left = round(self.left) self.bottom = self.top + self.height self.right = self.left + self.width @@ -264,8 +264,8 @@ class Text(Element): self.left = min(self.left, other.left) self.right = max(self.right, other.right) - self.width += other.width - self.final_width = other.left + other.width + self.width += other.width + self.final_width = other.left + other.width self.height = self.bottom - self.top # Need to check for (.+)$', other.raw) @@ -282,12 +282,12 @@ class Text(Element): self.raw = m_self.group(1) other.raw = m_other.group(1) elif self.font_size_em != other.font_size_em \ - and self.font_size_em != 1.00 : - if re.match(r'= other.font_size_em * 2.0 : + and self.font_size_em >= other.font_size_em * 2.0: # Insert 'float: left' etc. into current font info # Unfortunately, processing to generate the .epub file changes things. # The line height gets set to the same as other parts of the file @@ -351,10 +351,10 @@ class Text(Element): # Are there problems if self.raw does not end ? # Note that the 2 parts could have different font sizes matchObj = re.match(r'^([^<]*)(]*>)*(]+>)(.*)()*(\s*)$', self.raw) - if matchObj is not None : + if matchObj is not None: otherObj = re.match(r'^([^<]*)(]*>)*(]+>)(.*)()()*(.*)$', other.raw) # There is another href, but is it for the same place? - if otherObj is not None and matchObj.group(3) == otherObj.group(3) : + if otherObj is not None and matchObj.group(3) == otherObj.group(3): m2 = matchObj.group(2) if m2 is None: m2 = '' @@ -523,7 +523,7 @@ class Column: left_margin = elem.left - self.left elem.indent_fraction = left_margin/self.width elem.width_fraction = elem.width/self.width - if i == 0 or self.average_line_separation == 0: + if i == 0 or self.average_line_separation == 0: elem.top_gap_ratio = None else: elem.top_gap_ratio = (self.elements[i-1].bottom - @@ -740,15 +740,15 @@ class Page: if (frst.top <= secnd.top and frst.bottom >= secnd.bottom-BOTTOM_FACTOR) \ or (secnd.top <= frst.top and secnd.bottom >= frst.bottom-BOTTOM_FACTOR): # Overlap = same line - if frst.left < secnd.left : + if frst.left < secnd.left: return -1 - elif frst.left == secnd.left : + elif frst.left == secnd.left: return 0 return 1 # Different line so sort into line number - if frst.bottom < secnd.bottom : + if frst.bottom < secnd.bottom: return -1 - elif frst.bottom == secnd.bottom : + elif frst.bottom == secnd.bottom: return 0 return 1 @@ -862,7 +862,7 @@ class Page: # Approximate the line spacing for checking overlapped lines line_height = frag.bottom - frag.top for t in self.texts: - if t is not frag : + if t is not frag: # Do the parts of a line overlap? # Some files can have separate lines overlapping slightly # BOTTOM_FACTOR allows for this @@ -1100,7 +1100,7 @@ class Page: for i in range(LINE_SCAN_COUNT): if len(self.texts) < 1: break - if re.match(opts.pdf_header_regex, self.texts[0].text_as_string) is not None : + if re.match(opts.pdf_header_regex, self.texts[0].text_as_string) is not None: # There could be fragments which are spread out, so join_fragments has not coalesced them # Not sure that this would work as it relies on the first fragment matching regex t = self.texts[0] @@ -1116,7 +1116,7 @@ class Page: for i in range(LINE_SCAN_COUNT): if len(self.texts) < 1: break - if re.match(opts.pdf_footer_regex, self.texts[-1].text_as_string) is not None : + if re.match(opts.pdf_footer_regex, self.texts[-1].text_as_string) is not None: # There could be fragments which are spread out, so join_fragments has not coalesced them t = self.texts[-1] # match = self.find_match(t) @@ -1154,10 +1154,10 @@ class Page: for text in self.texts: top = text.top left = text.left - if round(left) != left : + if round(left) != left: text.left = left = round(left) right = text.right - if round(right) != right : + if round(right) != right: text.right = right = round(right) if first: tops[top] = tops.get(top, 0) + 1 @@ -1969,7 +1969,7 @@ class PDFDocument: merged_len = 0 # No merge # Allow where the last line ends with or next line starts with lower case. if re.match(r'.*[a-z,-]\s*$', last_line.text_as_string) is not None \ - or re.match(r'^\s*[a-z,-]', merged_text.text_as_string) is not None : + or re.match(r'^\s*[a-z,-]', merged_text.text_as_string) is not None: merged_len = merged_text.right # To use merged_len etc. @@ -1984,7 +1984,7 @@ class PDFDocument: merge_done = True # We don't want to merge partial pages # i.e. if this is the last line, preserve its top/bottom till after merge - if len(page.texts) == 1 : + if len(page.texts) == 1: save_bottom = merged_text.bottom else: save_bottom = 0.0 @@ -2014,7 +2014,7 @@ class PDFDocument: or self.pages[pind+1].texts[0].top > self.pages[pind+1].imgs[0].top)): page.page_break_after = True elif (re.match(r'.*[a-z, ]$', last_line.text_as_string) is not None \ - or last_line.final_width > page.width*self.opts.unwrap_factor): + or last_line.final_width > page.width*self.opts.unwrap_factor): candidate = page else: candidate = None diff --git a/src/calibre/ebooks/pdf/render/fonts.py b/src/calibre/ebooks/pdf/render/fonts.py index 2f0e5235da..2b804e3c98 100644 --- a/src/calibre/ebooks/pdf/render/fonts.py +++ b/src/calibre/ebooks/pdf/render/fonts.py @@ -205,7 +205,7 @@ class Font: widths = {g:w for g, w in iteritems(widths) if w != most_common} groups = Array() - for k, g in groupby(enumerate(widths), lambda i_x:i_x[0]-i_x[1]): + for k, g in groupby(enumerate(widths), lambda i_x: i_x[0]-i_x[1]): group = list(map(itemgetter(1), g)) gwidths = [widths[g] for g in group] if len(set(gwidths)) == 1 and len(group) > 1: diff --git a/src/calibre/ebooks/pdf/render/serialize.py b/src/calibre/ebooks/pdf/render/serialize.py index 0efe50e4ea..c363da5f33 100644 --- a/src/calibre/ebooks/pdf/render/serialize.py +++ b/src/calibre/ebooks/pdf/render/serialize.py @@ -228,7 +228,7 @@ class Image(Stream): def add_extra_keys(self, d): d['Type'] = Name('XObject') - d['Subtype']= Name('Image') + d['Subtype']= Name('Image') d['Width'] = self.width d['Height'] = self.height if self.depth == 1: @@ -260,14 +260,14 @@ class PDFStream: PATH_OPS = { # stroke fill fill-rule - (False, False, 'winding') : 'n', - (False, False, 'evenodd') : 'n', - (False, True, 'winding') : 'f', - (False, True, 'evenodd') : 'f*', - (True, False, 'winding') : 'S', - (True, False, 'evenodd') : 'S', - (True, True, 'winding') : 'B', - (True, True, 'evenodd') : 'B*', + (False, False, 'winding'): 'n', + (False, False, 'evenodd'): 'n', + (False, True, 'winding'): 'f', + (False, True, 'evenodd'): 'f*', + (True, False, 'winding'): 'S', + (True, False, 'evenodd'): 'S', + (True, True, 'winding'): 'B', + (True, True, 'evenodd'): 'B*', } def __init__(self, stream, page_size, compress=False, mark_links=False, diff --git a/src/calibre/ebooks/pml/pmlml.py b/src/calibre/ebooks/pml/pmlml.py index 7e18a64fe7..9232cf0150 100644 --- a/src/calibre/ebooks/pml/pmlml.py +++ b/src/calibre/ebooks/pml/pmlml.py @@ -34,10 +34,10 @@ TAG_MAP = { } STYLES = [ - ('font-weight', {'bold' : 'B', 'bolder' : 'B'}), - ('font-style', {'italic' : 'i'}), - ('text-decoration', {'underline' : 'u'}), - ('text-align', {'right' : 'r', 'center' : 'c'}), + ('font-weight', {'bold': 'B', 'bolder': 'B'}), + ('font-style', {'italic': 'i'}), + ('text-decoration', {'underline': 'u'}), + ('text-align', {'right': 'r', 'center': 'c'}), ] BLOCK_TAGS = [ diff --git a/src/calibre/ebooks/rb/rbml.py b/src/calibre/ebooks/rb/rbml.py index 47994fc395..da0f8361fd 100644 --- a/src/calibre/ebooks/rb/rbml.py +++ b/src/calibre/ebooks/rb/rbml.py @@ -47,7 +47,7 @@ IMAGE_TAGS = [ ] STYLES = [ - ('font-weight', {'bold' : 'b', 'bolder' : 'b'}), + ('font-weight', {'bold' : 'b', 'bolder' : 'b'}), ('font-style', {'italic' : 'i'}), ('text-align', {'center' : 'center'}), ] diff --git a/src/calibre/ebooks/readability/readability.py b/src/calibre/ebooks/readability/readability.py index 9fd448bf5c..29b2a53c90 100644 --- a/src/calibre/ebooks/readability/readability.py +++ b/src/calibre/ebooks/readability/readability.py @@ -455,7 +455,7 @@ class Document: if j == x: break # self.debug(str(siblings)) - if siblings and sum(siblings) > 1000 : + if siblings and sum(siblings) > 1000: to_remove = False self.debug('Allowing %s' % describe(el)) for desnode in self.tags(el, 'table', 'ul', 'div'): diff --git a/src/calibre/ebooks/rtf/preprocess.py b/src/calibre/ebooks/rtf/preprocess.py index e199c12b0f..66e90106c6 100644 --- a/src/calibre/ebooks/rtf/preprocess.py +++ b/src/calibre/ebooks/rtf/preprocess.py @@ -127,7 +127,7 @@ class tokenUnicode: ucn = self.current_ucn if len(self.eqList) < ucn: ucn = len(self.eqList) - result = tokenControlWordWithNumericArgument('\\uc', ucn).toRTF() + result + result = tokenControlWordWithNumericArgument('\\uc', ucn).toRTF() + result i = 0 for eq in self.eqList: if i >= ucn: @@ -321,7 +321,7 @@ class RtfTokenizer: break l = l + 1 i = i + 1 - if l > 10 : + if l > 10: raise Exception('Error (at:%d): Too many digits in control word numeric argument.'%[tokenStart]) if not consumed: diff --git a/src/calibre/ebooks/rtf/rtfml.py b/src/calibre/ebooks/rtf/rtfml.py index 10359a01f1..40f897879b 100644 --- a/src/calibre/ebooks/rtf/rtfml.py +++ b/src/calibre/ebooks/rtf/rtfml.py @@ -279,7 +279,7 @@ class RTFMLizer: text += self.dump_text(item, stylizer, tag_stack) for i in range(tag_count): - end_tag = tag_stack.pop() + end_tag = tag_stack.pop() if end_tag != 'block': if tag in BLOCK_TAGS: text += r'\par\pard\plain\hyphpar}' diff --git a/src/calibre/ebooks/rtf2xml/ParseRtf.py b/src/calibre/ebooks/rtf2xml/ParseRtf.py index 8abfbe9c1e..83f1d668f1 100644 --- a/src/calibre/ebooks/rtf2xml/ParseRtf.py +++ b/src/calibre/ebooks/rtf2xml/ParseRtf.py @@ -63,7 +63,7 @@ Here is an example script using the ParseRTF module directly def Handle_Main(): # Handles options and creates a parse object - parse_obj =ParseRtf.ParseRtf( + parse_obj = ParseRtf.ParseRtf( in_file = 'in.rtf', # All values from here on are optional # determine the output file @@ -201,7 +201,7 @@ class ParseRtf: def __check_dir(self, the_dir): '''Check to see if directory exists''' - if not the_dir : + if not the_dir: return dir_exists = os.path.isdir(the_dir) if not dir_exists: @@ -495,7 +495,7 @@ class ParseRtf: table_info_obj.insert_info() self.__bracket_match('table__data_info') if self.__form_lists: - make_list_obj = make_lists.MakeLists( + make_list_obj = make_lists.MakeLists( in_file=self.__temp_file, bug_handler=RtfInvalidCodeException, copy=self.__copy, @@ -506,7 +506,7 @@ class ParseRtf: make_list_obj.make_lists() self.__bracket_match('form_lists_info') if self.__headings_to_sections: - headings_to_sections_obj = headings_to_sections.HeadingsToSections( + headings_to_sections_obj = headings_to_sections.HeadingsToSections( in_file=self.__temp_file, bug_handler=RtfInvalidCodeException, copy=self.__copy, @@ -576,7 +576,7 @@ class ParseRtf: def __bracket_match(self, file_name): if self.__run_level > 2: - good_br, msg = self.__check_brack_obj.check_brackets() + good_br, msg = self.__check_brack_obj.check_brackets() if good_br: pass # sys.stderr.write( msg + ' in ' + file_name + "\n") @@ -590,7 +590,7 @@ class ParseRtf: if int(num) > self.__exit_level: self.__exit_level = num - def __make_temp_file(self,file): + def __make_temp_file(self, file): '''Make a temporary file to parse''' write_file='rtf_write_file' read_obj = file if hasattr(file, 'read') else open_for_read(file) diff --git a/src/calibre/ebooks/rtf2xml/add_brackets.py b/src/calibre/ebooks/rtf2xml/add_brackets.py index 55ef9a0d7f..b4fab208e1 100644 --- a/src/calibre/ebooks/rtf2xml/add_brackets.py +++ b/src/calibre/ebooks/rtf2xml/add_brackets.py @@ -51,39 +51,39 @@ class AddBrackets: self.__write_to = better_mktemp() self.__run_level = run_level self.__state_dict = { - 'before_body' : self.__before_body_func, - 'in_body' : self.__in_body_func, - 'after_control_word' : self.__after_control_word_func, - 'in_ignore' : self.__ignore_func, + 'before_body' : self.__before_body_func, + 'in_body' : self.__in_body_func, + 'after_control_word': self.__after_control_word_func, + 'in_ignore' : self.__ignore_func, } self.__accept = [ - 'cw bt - 'bdr-li-wid' : 'line-width', - 'bdr-sp-wid' : 'padding', - 'bdr-color_' : 'color', + 'bdr-li-wid': 'line-width', + 'bdr-sp-wid': 'padding', + 'bdr-color_': 'color', } self.__border_style_dict = { - 'bdr-single' : 'single', - 'bdr-doubtb' : 'double-thickness-border', - 'bdr-shadow' : 'shadowed-border', - 'bdr-double' : 'double-border', - 'bdr-dotted' : 'dotted-border', - 'bdr-dashed' : 'dashed', - 'bdr-hair__' : 'hairline', - 'bdr-inset_' : 'inset', - 'bdr-das-sm' : 'dash-small', - 'bdr-dot-sm' : 'dot-dash', - 'bdr-dot-do' : 'dot-dot-dash', - 'bdr-outset' : 'outset', - 'bdr-trippl' : 'tripple', - 'bdr-thsm__' : 'thick-thin-small', - 'bdr-htsm__' : 'thin-thick-small', - 'bdr-hthsm_' : 'thin-thick-thin-small', - 'bdr-thm___' : 'thick-thin-medium', - 'bdr-htm___' : 'thin-thick-medium', - 'bdr-hthm__' : 'thin-thick-thin-medium', - 'bdr-thl___' : 'thick-thin-large', - 'bdr-hthl__' : 'thin-thick-thin-large', - 'bdr-wavy__' : 'wavy', - 'bdr-d-wav_' : 'double-wavy', - 'bdr-strip_' : 'striped', - 'bdr-embos_' : 'emboss', - 'bdr-engra_' : 'engrave', - 'bdr-frame_' : 'frame', + 'bdr-single': 'single', + 'bdr-doubtb': 'double-thickness-border', + 'bdr-shadow': 'shadowed-border', + 'bdr-double': 'double-border', + 'bdr-dotted': 'dotted-border', + 'bdr-dashed': 'dashed', + 'bdr-hair__': 'hairline', + 'bdr-inset_': 'inset', + 'bdr-das-sm': 'dash-small', + 'bdr-dot-sm': 'dot-dash', + 'bdr-dot-do': 'dot-dot-dash', + 'bdr-outset': 'outset', + 'bdr-trippl': 'tripple', + 'bdr-thsm__': 'thick-thin-small', + 'bdr-htsm__': 'thin-thick-small', + 'bdr-hthsm_': 'thin-thick-thin-small', + 'bdr-thm___': 'thick-thin-medium', + 'bdr-htm___': 'thin-thick-medium', + 'bdr-hthm__': 'thin-thick-thin-medium', + 'bdr-thl___': 'thick-thin-large', + 'bdr-hthl__': 'thin-thick-thin-large', + 'bdr-wavy__': 'wavy', + 'bdr-d-wav_': 'double-wavy', + 'bdr-strip_': 'striped', + 'bdr-embos_': 'emboss', + 'bdr-engra_': 'engrave', + 'bdr-frame_': 'frame', } def parse_border(self, line): diff --git a/src/calibre/ebooks/rtf2xml/check_encoding.py b/src/calibre/ebooks/rtf2xml/check_encoding.py index f06a3dddb3..d32de41ccb 100644 --- a/src/calibre/ebooks/rtf2xml/check_encoding.py +++ b/src/calibre/ebooks/rtf2xml/check_encoding.py @@ -16,7 +16,7 @@ class CheckEncoding: try: char.decode(encoding) except ValueError as msg: - sys.stderr.write('line: %s char: %s\n%s\n' % (line_num, char_position, str(msg))) + sys.stderr.write('line: %s char: %s\n%s\n' % (line_num, char_position, str(msg))) def check_encoding(self, path, encoding='us-ascii', verbose=True): line_num = 0 diff --git a/src/calibre/ebooks/rtf2xml/colors.py b/src/calibre/ebooks/rtf2xml/colors.py index b549fea4b7..03e275ae11 100644 --- a/src/calibre/ebooks/rtf2xml/colors.py +++ b/src/calibre/ebooks/rtf2xml/colors.py @@ -57,7 +57,7 @@ class Colors: self.__state_dict = { 'before_color_table': self.__before_color_func, 'in_color_table' : self.__in_color_func, - 'after_color_table' : self.__after_color_func, + 'after_color_table' : self.__after_color_func, 'cw -1: diff --git a/src/calibre/ebooks/rtf2xml/fields_large.py b/src/calibre/ebooks/rtf2xml/fields_large.py index dd61fcb727..2668382514 100644 --- a/src/calibre/ebooks/rtf2xml/fields_large.py +++ b/src/calibre/ebooks/rtf2xml/fields_large.py @@ -136,7 +136,7 @@ Examples 'cw 2: - msg = 'wrong flag' + msg = 'wrong flag' raise self.__bug_handler(msg) elif self.__token_info in self.__end_list: self.__write_obj.write('mi 2: - msg = 'wrong flag' + msg = 'wrong flag' raise self.__bug_handler(msg) elif self.__token_info in self.__end_list: self.__write_obj.write('mi ci - 'annotation' : 'annotation', - 'blue______' : 'blue', - 'bold______' : 'bold', - 'caps______' : 'caps', - 'char-style' : 'character-style', - 'dbl-strike' : 'double-strike-through', - 'emboss____' : 'emboss', - 'engrave___' : 'engrave', - 'font-color' : 'font-color', - 'font-down_' : 'subscript', - 'font-size_' : 'font-size', - 'font-style' : 'font-style', - 'font-up___' : 'superscript', - 'footnot-mk' : 'footnote-marker', - 'green_____' : 'green', - 'hidden____' : 'hidden', - 'italics___' : 'italics', - 'outline___' : 'outline', - 'red_______' : 'red', - 'shadow____' : 'shadow', - 'small-caps' : 'small-caps', - 'strike-thr' : 'strike-through', - 'subscript_' : 'subscript', - 'superscrip' : 'superscript', - 'underlined' : 'underlined', + 'annotation': 'annotation', + 'blue______': 'blue', + 'bold______': 'bold', + 'caps______': 'caps', + 'char-style': 'character-style', + 'dbl-strike': 'double-strike-through', + 'emboss____': 'emboss', + 'engrave___': 'engrave', + 'font-color': 'font-color', + 'font-down_': 'subscript', + 'font-size_': 'font-size', + 'font-style': 'font-style', + 'font-up___': 'superscript', + 'footnot-mk': 'footnote-marker', + 'green_____': 'green', + 'hidden____': 'hidden', + 'italics___': 'italics', + 'outline___': 'outline', + 'red_______': 'red', + 'shadow____': 'shadow', + 'small-caps': 'small-caps', + 'strike-thr': 'strike-through', + 'subscript_': 'subscript', + 'superscrip': 'superscript', + 'underlined': 'underlined', } self.__caps_list = ['false'] @@ -365,7 +365,7 @@ class Inline: ''' for the_dict in self.__inline_list: contains_info = the_dict.get('contains_inline') - if contains_info : + if contains_info: the_keys = the_dict.keys() if 'font-style' in the_keys: face = the_dict['font-style'] diff --git a/src/calibre/ebooks/rtf2xml/list_numbers.py b/src/calibre/ebooks/rtf2xml/list_numbers.py index 7568aeead9..1c99168a72 100644 --- a/src/calibre/ebooks/rtf2xml/list_numbers.py +++ b/src/calibre/ebooks/rtf2xml/list_numbers.py @@ -58,10 +58,10 @@ class ListNumbers: self.__previous_line = '' self.__list_text_ob_count = '' self.__state_dict={ - 'default' : self.__default_func, - 'after_ob' : self.__after_ob_func, - 'list_text' : self.__list_text_func, - 'after_list_text' : self.__after_list_text_func + 'default' : self.__default_func, + 'after_ob' : self.__after_ob_func, + 'list_text' : self.__list_text_func, + 'after_list_text' : self.__after_list_text_func } def __after_ob_func(self, line): diff --git a/src/calibre/ebooks/rtf2xml/list_table.py b/src/calibre/ebooks/rtf2xml/list_table.py index fa9260b853..b77c3fe01b 100644 --- a/src/calibre/ebooks/rtf2xml/list_table.py +++ b/src/calibre/ebooks/rtf2xml/list_table.py @@ -49,24 +49,24 @@ class ListTable: 'list_name' : self.__list_name_func, } self.__main_list_dict = { - 'cw pf - 'par-end___' : 'para', - 'par-def___' : 'paragraph-definition', - 'keep-w-nex' : 'keep-with-next', - 'widow-cntl' : 'widow-control', - 'adjust-rgt' : 'adjust-right', - 'language__' : 'language', - 'right-inde' : 'right-indent', - 'fir-ln-ind' : 'first-line-indent', - 'left-inden' : 'left-indent', - 'space-befo' : 'space-before', - 'space-afte' : 'space-after', - 'line-space' : 'line-spacing', - 'default-ta' : 'default-tab', - 'align_____' : 'align', - 'widow-cntr' : 'widow-control', + 'par-end___': 'para', + 'par-def___': 'paragraph-definition', + 'keep-w-nex': 'keep-with-next', + 'widow-cntl': 'widow-control', + 'adjust-rgt': 'adjust-right', + 'language__': 'language', + 'right-inde': 'right-indent', + 'fir-ln-ind': 'first-line-indent', + 'left-inden': 'left-indent', + 'space-befo': 'space-before', + 'space-afte': 'space-after', + 'line-space': 'line-spacing', + 'default-ta': 'default-tab', + 'align_____': 'align', + 'widow-cntr': 'widow-control', # stylesheet = > ss - 'style-shet' : 'stylesheet', - 'based-on__' : 'based-on-style', - 'next-style' : 'next-style', - 'char-style' : 'character-style', + 'style-shet': 'stylesheet', + 'based-on__': 'based-on-style', + 'next-style': 'next-style', + 'char-style': 'character-style', # this is changed to get a nice attribute - 'para-style' : 'name', + 'para-style': 'name', # graphics => gr - 'picture___' : 'pict', - 'obj-class_' : 'obj_class', - 'mac-pic___' : 'mac-pict', + 'picture___': 'pict', + 'obj-class_': 'obj_class', + 'mac-pic___': 'mac-pict', # section => sc - 'section___' : 'section-new', - 'sect-defin' : 'section-reset', - 'sect-note_' : 'endnotes-in-section', + 'section___': 'section-new', + 'sect-defin': 'section-reset', + 'sect-note_': 'endnotes-in-section', # list=> ls - 'list-text_' : 'list-text', - 'list______' : 'list', - 'list-lev-d' : 'list-level-definition', - 'list-cardi' : 'list-cardinal-numbering', - 'list-decim' : 'list-decimal-numbering', - 'list-up-al' : 'list-uppercase-alphabetic-numbering', - 'list-up-ro' : 'list-uppercae-roman-numbering', - 'list-ord__' : 'list-ordinal-numbering', - 'list-ordte' : 'list-ordinal-text-numbering', - 'list-bulli' : 'list-bullet', - 'list-simpi' : 'list-simple', - 'list-conti' : 'list-continue', - 'list-hang_' : 'list-hang', + 'list-text_': 'list-text', + 'list______': 'list', + 'list-lev-d': 'list-level-definition', + 'list-cardi': 'list-cardinal-numbering', + 'list-decim': 'list-decimal-numbering', + 'list-up-al': 'list-uppercase-alphabetic-numbering', + 'list-up-ro': 'list-uppercae-roman-numbering', + 'list-ord__': 'list-ordinal-numbering', + 'list-ordte': 'list-ordinal-text-numbering', + 'list-bulli': 'list-bullet', + 'list-simpi': 'list-simple', + 'list-conti': 'list-continue', + 'list-hang_': 'list-hang', # 'list-tebef' : 'list-text-before', # 'list-level' : 'level', - 'list-id___' : 'list-id', - 'list-start' : 'list-start', - 'nest-level' : 'nest-level', + 'list-id___': 'list-id', + 'list-start': 'list-start', + 'nest-level': 'nest-level', # duplicate - 'list-level' : 'list-level', + 'list-level': 'list-level', # notes => nt - 'footnote__' : 'footnote', - 'type______' : 'type', + 'footnote__': 'footnote', + 'type______': 'type', # anchor => an - 'toc_______' : 'anchor-toc', - 'book-mk-st' : 'bookmark-start', - 'book-mk-en' : 'bookmark-end', - 'index-mark' : 'anchor-index', - 'place_____' : 'place', + 'toc_______': 'anchor-toc', + 'book-mk-st': 'bookmark-start', + 'book-mk-en': 'bookmark-end', + 'index-mark': 'anchor-index', + 'place_____': 'place', # field => fd - 'field_____' : 'field', - 'field-inst' : 'field-instruction', - 'field-rslt' : 'field-result', - 'datafield_' : 'data-field', + 'field_____': 'field', + 'field-inst': 'field-instruction', + 'field-rslt': 'field-result', + 'datafield_': 'data-field', # info-tables => it - 'font-table' : 'font-table', - 'colr-table' : 'color-table', - 'lovr-table' : 'list-override-table', - 'listtable_' : 'list-table', - 'revi-table' : 'revision-table', + 'font-table': 'font-table', + 'colr-table': 'color-table', + 'lovr-table': 'list-override-table', + 'listtable_': 'list-table', + 'revi-table': 'revision-table', # character info => ci - 'hidden____' : 'hidden', - 'italics___' : 'italics', - 'bold______' : 'bold', - 'strike-thr' : 'strike-through', - 'shadow____' : 'shadow', - 'outline___' : 'outline', - 'small-caps' : 'small-caps', - 'caps______' : 'caps', - 'dbl-strike' : 'double-strike-through', - 'emboss____' : 'emboss', - 'engrave___' : 'engrave', - 'subscript_' : 'subscript', - 'superscrip' : 'superscipt', - 'font-style' : 'font-style', - 'font-color' : 'font-color', - 'font-size_' : 'font-size', - 'font-up___' : 'superscript', - 'font-down_' : 'subscript', - 'red_______' : 'red', - 'blue______' : 'blue', - 'green_____' : 'green', + 'hidden____': 'hidden', + 'italics___': 'italics', + 'bold______': 'bold', + 'strike-thr': 'strike-through', + 'shadow____': 'shadow', + 'outline___': 'outline', + 'small-caps': 'small-caps', + 'caps______': 'caps', + 'dbl-strike': 'double-strike-through', + 'emboss____': 'emboss', + 'engrave___': 'engrave', + 'subscript_': 'subscript', + 'superscrip': 'superscipt', + 'font-style': 'font-style', + 'font-color': 'font-color', + 'font-size_': 'font-size', + 'font-up___': 'superscript', + 'font-down_': 'subscript', + 'red_______': 'red', + 'blue______': 'blue', + 'green_____': 'green', # table => tb - 'row-def___' : 'row-definition', - 'cell______' : 'cell', - 'row_______' : 'row', - 'in-table__' : 'in-table', - 'columns___' : 'columns', - 'row-pos-le' : 'row-position-left', - 'cell-posit' : 'cell-position', + 'row-def___': 'row-definition', + 'cell______': 'cell', + 'row_______': 'row', + 'in-table__': 'in-table', + 'columns___': 'columns', + 'row-pos-le': 'row-position-left', + 'cell-posit': 'cell-position', # preamble => pr # underline - 'underlined' : 'underlined', + 'underlined': 'underlined', # border => bd - 'bor-t-r-hi' : 'border-table-row-horizontal-inside', - 'bor-t-r-vi' : 'border-table-row-vertical-inside', - 'bor-t-r-to' : 'border-table-row-top', - 'bor-t-r-le' : 'border-table-row-left', - 'bor-t-r-bo' : 'border-table-row-bottom', - 'bor-t-r-ri' : 'border-table-row-right', - 'bor-cel-bo' : 'border-cell-bottom', - 'bor-cel-to' : 'border-cell-top', - 'bor-cel-le' : 'border-cell-left', - 'bor-cel-ri' : 'border-cell-right', + 'bor-t-r-hi': 'border-table-row-horizontal-inside', + 'bor-t-r-vi': 'border-table-row-vertical-inside', + 'bor-t-r-to': 'border-table-row-top', + 'bor-t-r-le': 'border-table-row-left', + 'bor-t-r-bo': 'border-table-row-bottom', + 'bor-t-r-ri': 'border-table-row-right', + 'bor-cel-bo': 'border-cell-bottom', + 'bor-cel-to': 'border-cell-top', + 'bor-cel-le': 'border-cell-left', + 'bor-cel-ri': 'border-cell-right', # 'bor-par-bo' : 'border-paragraph-bottom', - 'bor-par-to' : 'border-paragraph-top', - 'bor-par-le' : 'border-paragraph-left', - 'bor-par-ri' : 'border-paragraph-right', - 'bor-par-bo' : 'border-paragraph-box', - 'bor-for-ev' : 'border-for-every-paragraph', - 'bor-outsid' : 'border-outisde', - 'bor-none__' : 'border', + 'bor-par-to': 'border-paragraph-top', + 'bor-par-le': 'border-paragraph-left', + 'bor-par-ri': 'border-paragraph-right', + 'bor-par-bo': 'border-paragraph-box', + 'bor-for-ev': 'border-for-every-paragraph', + 'bor-outsid': 'border-outisde', + 'bor-none__': 'border', # border type => bt - 'bdr-single' : 'single', - 'bdr-doubtb' : 'double-thickness-border', - 'bdr-shadow' : 'shadowed-border', - 'bdr-double' : 'double-border', - 'bdr-dotted' : 'dotted-border', - 'bdr-dashed' : 'dashed', - 'bdr-hair__' : 'hairline', - 'bdr-inset_' : 'inset', - 'bdr-das-sm' : 'dash-small', - 'bdr-dot-sm' : 'dot-dash', - 'bdr-dot-do' : 'dot-dot-dash', - 'bdr-outset' : 'outset', - 'bdr-trippl' : 'tripple', - 'bdr-thsm__' : 'thick-thin-small', - 'bdr-htsm__' : 'thin-thick-small', - 'bdr-hthsm_' : 'thin-thick-thin-small', - 'bdr-thm__' : 'thick-thin-medium', - 'bdr-htm__' : 'thin-thick-medium', - 'bdr-hthm_' : 'thin-thick-thin-medium', - 'bdr-thl__' : 'thick-thin-large', - 'bdr-hthl_' : 'think-thick-think-large', - 'bdr-wavy_' : 'wavy', - 'bdr-d-wav' : 'double-wavy', - 'bdr-strip' : 'striped', - 'bdr-embos' : 'emboss', - 'bdr-engra' : 'engrave', - 'bdr-frame' : 'frame', - 'bdr-li-wid' : 'line-width', + 'bdr-single': 'single', + 'bdr-doubtb': 'double-thickness-border', + 'bdr-shadow': 'shadowed-border', + 'bdr-double': 'double-border', + 'bdr-dotted': 'dotted-border', + 'bdr-dashed': 'dashed', + 'bdr-hair__': 'hairline', + 'bdr-inset_': 'inset', + 'bdr-das-sm': 'dash-small', + 'bdr-dot-sm': 'dot-dash', + 'bdr-dot-do': 'dot-dot-dash', + 'bdr-outset': 'outset', + 'bdr-trippl': 'tripple', + 'bdr-thsm__': 'thick-thin-small', + 'bdr-htsm__': 'thin-thick-small', + 'bdr-hthsm_': 'thin-thick-thin-small', + 'bdr-thm__': 'thick-thin-medium', + 'bdr-htm__': 'thin-thick-medium', + 'bdr-hthm_': 'thin-thick-thin-medium', + 'bdr-thl__': 'thick-thin-large', + 'bdr-hthl_': 'think-thick-think-large', + 'bdr-wavy_': 'wavy', + 'bdr-d-wav': 'double-wavy', + 'bdr-strip': 'striped', + 'bdr-embos': 'emboss', + 'bdr-engra': 'engrave', + 'bdr-frame': 'frame', + 'bdr-li-wid': 'line-width', } self.__tabs_dict = { - 'cw%s' % (key, self.__section[key]) + '<%s>%s' % (key, self.__section[key]) ) self.__write_obj.write('\n') diff --git a/src/calibre/ebooks/rtf2xml/preamble_rest.py b/src/calibre/ebooks/rtf2xml/preamble_rest.py index 36b299d476..2a208905d4 100644 --- a/src/calibre/ebooks/rtf2xml/preamble_rest.py +++ b/src/calibre/ebooks/rtf2xml/preamble_rest.py @@ -67,14 +67,14 @@ class Preamble: self.__state_dict = { 'default' : self.__default_func, 'revision' : self.__revision_table_func, - 'list_table' : self.__list_table_func, - 'body' : self.__body_func, + 'list_table': self.__list_table_func, + 'body' : self.__body_func, } self.__default_dict = { - 'mi%s' % str(num) ) if self.__list_of_sec_values: - keys = self.__list_of_sec_values[0].keys() + keys = self.__list_of_sec_values[0].keys() for key in keys: self.__write_obj.write( f'<{key}>{self.__list_of_sec_values[0][key]}\n') diff --git a/src/calibre/ebooks/rtf2xml/styles.py b/src/calibre/ebooks/rtf2xml/styles.py index bbda310887..a067bb56ab 100644 --- a/src/calibre/ebooks/rtf2xml/styles.py +++ b/src/calibre/ebooks/rtf2xml/styles.py @@ -51,22 +51,22 @@ class Styles: Initiate all values. ''' self.__border_obj = border_parse.BorderParse() - self.__styles_dict = {'par':{}, 'char':{}} + self.__styles_dict = {'par':{}, 'char':{}} self.__styles_num = '0' self.__type_of_style = 'par' self.__text_string = '' self.__state = 'before_styles_table' self.__state_dict = { - 'before_styles_table': self.__before_styles_func, - 'in_styles_table' : self.__in_styles_func, - 'in_individual_style' : self.__in_individual_style_func, - 'after_styles_table' : self.__after_styles_func, - 'mi pf - 'par-end___' : 'para', - 'par-def___' : 'paragraph-definition', - 'keep-w-nex' : 'keep-with-next', - 'widow-cntl' : 'widow-control', - 'adjust-rgt' : 'adjust-right', - 'language__' : 'language', - 'right-inde' : 'right-indent', - 'fir-ln-ind' : 'first-line-indent', - 'left-inden' : 'left-indent', - 'space-befo' : 'space-before', - 'space-afte' : 'space-after', - 'line-space' : 'line-spacing', - 'default-ta' : 'default-tab', - 'align_____' : 'align', - 'widow-cntr' : 'widow-control', + 'par-end___': 'para', + 'par-def___': 'paragraph-definition', + 'keep-w-nex': 'keep-with-next', + 'widow-cntl': 'widow-control', + 'adjust-rgt': 'adjust-right', + 'language__': 'language', + 'right-inde': 'right-indent', + 'fir-ln-ind': 'first-line-indent', + 'left-inden': 'left-indent', + 'space-befo': 'space-before', + 'space-afte': 'space-after', + 'line-space': 'line-spacing', + 'default-ta': 'default-tab', + 'align_____': 'align', + 'widow-cntr': 'widow-control', # page formatting mixed in! (Just in older RTF?) - 'margin-lef' : 'left-indent', - 'margin-rig' : 'right-indent', - 'margin-bot' : 'space-after', - 'margin-top' : 'space-before', + 'margin-lef': 'left-indent', + 'margin-rig': 'right-indent', + 'margin-bot': 'space-after', + 'margin-top': 'space-before', # stylesheet = > ss - 'style-shet' : 'stylesheet', - 'based-on__' : 'based-on-style', - 'next-style' : 'next-style', - 'char-style' : 'character-style', - 'para-style' : 'paragraph-style', + 'style-shet': 'stylesheet', + 'based-on__': 'based-on-style', + 'next-style': 'next-style', + 'char-style': 'character-style', + 'para-style': 'paragraph-style', # graphics => gr - 'picture___' : 'pict', - 'obj-class_' : 'obj_class', - 'mac-pic___' : 'mac-pict', + 'picture___': 'pict', + 'obj-class_': 'obj_class', + 'mac-pic___': 'mac-pict', # section => sc - 'section___' : 'section-new', - 'sect-defin' : 'section-reset', - 'sect-note_' : 'endnotes-in-section', + 'section___': 'section-new', + 'sect-defin': 'section-reset', + 'sect-note_': 'endnotes-in-section', # list=> ls - 'list-text_' : 'list-text', - 'list______' : 'list', - 'list-lev-d' : 'list-level-definition', - 'list-cardi' : 'list-cardinal-numbering', - 'list-decim' : 'list-decimal-numbering', - 'list-up-al' : 'list-uppercase-alphabetic-numbering', - 'list-up-ro' : 'list-uppercae-roman-numbering', - 'list-ord__' : 'list-ordinal-numbering', - 'list-ordte' : 'list-ordinal-text-numbering', - 'list-bulli' : 'list-bullet', - 'list-simpi' : 'list-simple', - 'list-conti' : 'list-continue', - 'list-hang_' : 'list-hang', + 'list-text_': 'list-text', + 'list______': 'list', + 'list-lev-d': 'list-level-definition', + 'list-cardi': 'list-cardinal-numbering', + 'list-decim': 'list-decimal-numbering', + 'list-up-al': 'list-uppercase-alphabetic-numbering', + 'list-up-ro': 'list-uppercae-roman-numbering', + 'list-ord__': 'list-ordinal-numbering', + 'list-ordte': 'list-ordinal-text-numbering', + 'list-bulli': 'list-bullet', + 'list-simpi': 'list-simple', + 'list-conti': 'list-continue', + 'list-hang_': 'list-hang', # 'list-tebef' : 'list-text-before', # 'list-level' : 'level', - 'list-id___' : 'list-id', - 'list-start' : 'list-start', - 'nest-level' : 'nest-level', + 'list-id___': 'list-id', + 'list-start': 'list-start', + 'nest-level': 'nest-level', # duplicate - 'list-level' : 'list-level', + 'list-level': 'list-level', # notes => nt - 'footnote__' : 'footnote', - 'type______' : 'type', + 'footnote__': 'footnote', + 'type______': 'type', # anchor => an - 'toc_______' : 'anchor-toc', - 'book-mk-st' : 'bookmark-start', - 'book-mk-en' : 'bookmark-end', - 'index-mark' : 'anchor-index', - 'place_____' : 'place', + 'toc_______': 'anchor-toc', + 'book-mk-st': 'bookmark-start', + 'book-mk-en': 'bookmark-end', + 'index-mark': 'anchor-index', + 'place_____': 'place', # field => fd - 'field_____' : 'field', - 'field-inst' : 'field-instruction', - 'field-rslt' : 'field-result', - 'datafield_' : 'data-field', + 'field_____': 'field', + 'field-inst': 'field-instruction', + 'field-rslt': 'field-result', + 'datafield_': 'data-field', # info-tables => it - 'font-table' : 'font-table', - 'colr-table' : 'color-table', - 'lovr-table' : 'list-override-table', - 'listtable_' : 'list-table', - 'revi-table' : 'revision-table', + 'font-table': 'font-table', + 'colr-table': 'color-table', + 'lovr-table': 'list-override-table', + 'listtable_': 'list-table', + 'revi-table': 'revision-table', # character info => ci - 'hidden____' : 'hidden', - 'italics___' : 'italics', - 'bold______' : 'bold', - 'strike-thr' : 'strike-through', - 'shadow____' : 'shadow', - 'outline___' : 'outline', - 'small-caps' : 'small-caps', - 'dbl-strike' : 'double-strike-through', - 'emboss____' : 'emboss', - 'engrave___' : 'engrave', - 'subscript_' : 'subscript', - 'superscrip' : 'superscript', - 'plain_____' : 'plain', - 'font-style' : 'font-style', - 'font-color' : 'font-color', - 'font-size_' : 'font-size', - 'font-up___' : 'superscript', - 'font-down_' : 'subscript', - 'red_______' : 'red', - 'blue______' : 'blue', - 'green_____' : 'green', - 'caps______' : 'caps', + 'hidden____': 'hidden', + 'italics___': 'italics', + 'bold______': 'bold', + 'strike-thr': 'strike-through', + 'shadow____': 'shadow', + 'outline___': 'outline', + 'small-caps': 'small-caps', + 'dbl-strike': 'double-strike-through', + 'emboss____': 'emboss', + 'engrave___': 'engrave', + 'subscript_': 'subscript', + 'superscrip': 'superscript', + 'plain_____': 'plain', + 'font-style': 'font-style', + 'font-color': 'font-color', + 'font-size_': 'font-size', + 'font-up___': 'superscript', + 'font-down_': 'subscript', + 'red_______': 'red', + 'blue______': 'blue', + 'green_____': 'green', + 'caps______': 'caps', # table => tb - 'row-def___' : 'row-definition', - 'cell______' : 'cell', - 'row_______' : 'row', - 'in-table__' : 'in-table', - 'columns___' : 'columns', - 'row-pos-le' : 'row-position-left', - 'cell-posit' : 'cell-position', + 'row-def___': 'row-definition', + 'cell______': 'cell', + 'row_______': 'row', + 'in-table__': 'in-table', + 'columns___': 'columns', + 'row-pos-le': 'row-position-left', + 'cell-posit': 'cell-position', # preamble => pr # underline - 'underlined' : 'underlined', + 'underlined': 'underlined', # border => bd - 'bor-t-r-hi' : 'border-table-row-horizontal-inside', - 'bor-t-r-vi' : 'border-table-row-vertical-inside', - 'bor-t-r-to' : 'border-table-row-top', - 'bor-t-r-le' : 'border-table-row-left', - 'bor-t-r-bo' : 'border-table-row-bottom', - 'bor-t-r-ri' : 'border-table-row-right', - 'bor-cel-bo' : 'border-cell-bottom', - 'bor-cel-to' : 'border-cell-top', - 'bor-cel-le' : 'border-cell-left', - 'bor-cel-ri' : 'border-cell-right', + 'bor-t-r-hi': 'border-table-row-horizontal-inside', + 'bor-t-r-vi': 'border-table-row-vertical-inside', + 'bor-t-r-to': 'border-table-row-top', + 'bor-t-r-le': 'border-table-row-left', + 'bor-t-r-bo': 'border-table-row-bottom', + 'bor-t-r-ri': 'border-table-row-right', + 'bor-cel-bo': 'border-cell-bottom', + 'bor-cel-to': 'border-cell-top', + 'bor-cel-le': 'border-cell-left', + 'bor-cel-ri': 'border-cell-right', # 'bor-par-bo' : 'border-paragraph-bottom', - 'bor-par-to' : 'border-paragraph-top', - 'bor-par-le' : 'border-paragraph-left', - 'bor-par-ri' : 'border-paragraph-right', - 'bor-par-bo' : 'border-paragraph-box', - 'bor-for-ev' : 'border-for-every-paragraph', - 'bor-outsid' : 'border-outisde', - 'bor-none__' : 'border', + 'bor-par-to': 'border-paragraph-top', + 'bor-par-le': 'border-paragraph-left', + 'bor-par-ri': 'border-paragraph-right', + 'bor-par-bo': 'border-paragraph-box', + 'bor-for-ev': 'border-for-every-paragraph', + 'bor-outsid': 'border-outisde', + 'bor-none__': 'border', # border type => bt - 'bdr-single' : 'single', - 'bdr-doubtb' : 'double-thickness-border', - 'bdr-shadow' : 'shadowed-border', - 'bdr-double' : 'double-border', - 'bdr-dotted' : 'dotted-border', - 'bdr-dashed' : 'dashed', - 'bdr-hair__' : 'hairline', - 'bdr-inset_' : 'inset', - 'bdr-das-sm' : 'dash-small', - 'bdr-dot-sm' : 'dot-dash', - 'bdr-dot-do' : 'dot-dot-dash', - 'bdr-outset' : 'outset', - 'bdr-trippl' : 'tripple', - 'bdr-thsm__' : 'thick-thin-small', - 'bdr-htsm__' : 'thin-thick-small', - 'bdr-hthsm_' : 'thin-thick-thin-small', - 'bdr-thm__' : 'thick-thin-medium', - 'bdr-htm__' : 'thin-thick-medium', - 'bdr-hthm_' : 'thin-thick-thin-medium', - 'bdr-thl__' : 'thick-thin-large', - 'bdr-hthl_' : 'think-thick-think-large', - 'bdr-wavy_' : 'wavy', - 'bdr-d-wav' : 'double-wavy', - 'bdr-strip' : 'striped', - 'bdr-embos' : 'emboss', - 'bdr-engra' : 'engrave', - 'bdr-frame' : 'frame', - 'bdr-li-wid' : 'line-width', + 'bdr-single': 'single', + 'bdr-doubtb': 'double-thickness-border', + 'bdr-shadow': 'shadowed-border', + 'bdr-double': 'double-border', + 'bdr-dotted': 'dotted-border', + 'bdr-dashed': 'dashed', + 'bdr-hair__': 'hairline', + 'bdr-inset_': 'inset', + 'bdr-das-sm': 'dash-small', + 'bdr-dot-sm': 'dot-dash', + 'bdr-dot-do': 'dot-dot-dash', + 'bdr-outset': 'outset', + 'bdr-trippl': 'tripple', + 'bdr-thsm__': 'thick-thin-small', + 'bdr-htsm__': 'thin-thick-small', + 'bdr-hthsm_': 'thin-thick-thin-small', + 'bdr-thm__': 'thick-thin-medium', + 'bdr-htm__': 'thin-thick-medium', + 'bdr-hthm_': 'thin-thick-thin-medium', + 'bdr-thl__': 'thick-thin-large', + 'bdr-hthl_': 'think-thick-think-large', + 'bdr-wavy_': 'wavy', + 'bdr-d-wav': 'double-wavy', + 'bdr-strip': 'striped', + 'bdr-embos': 'emboss', + 'bdr-engra': 'engrave', + 'bdr-frame': 'frame', + 'bdr-li-wid': 'line-width', # tabs - 'tab-center' : 'center', - 'tab-right_' : 'right', - 'tab-dec___' : 'decimal', - 'leader-dot' : 'leader-dot', - 'leader-hyp' : 'leader-hyphen', - 'leader-und' : 'leader-underline', + 'tab-center': 'center', + 'tab-right_': 'right', + 'tab-dec___': 'decimal', + 'leader-dot': 'leader-dot', + 'leader-hyp': 'leader-hyphen', + 'leader-und': 'leader-underline', } self.__tabs_dict = { 'cw 3: msg = 'no value for key %s\n' % info @@ -436,7 +436,7 @@ class Styles: Add this type dictionary to the main styles dictionary. ''' if self.__type_of_style == 'par': - type_dict =self.__styles_dict['par'] + type_dict = self.__styles_dict['par'] elif self.__type_of_style == 'char': type_dict = self.__styles_dict['char'] else: diff --git a/src/calibre/ebooks/rtf2xml/table.py b/src/calibre/ebooks/rtf2xml/table.py index fd32e20650..5dbf666d01 100644 --- a/src/calibre/ebooks/rtf2xml/table.py +++ b/src/calibre/ebooks/rtf2xml/table.py @@ -80,28 +80,28 @@ class Table: Initiate all values. ''' self.__state_dict = { - 'in_table': self.__in_table_func, - 'in_row_def': self.__in_row_def_func, - 'not_in_table': self.__not_in_table_func, - 'in_cell': self.__in_cell_func, - 'in_row': self.__in_row_func, + 'in_table' : self.__in_table_func, + 'in_row_def' : self.__in_row_def_func, + 'not_in_table' : self.__not_in_table_func, + 'in_cell' : self.__in_cell_func, + 'in_row' : self.__in_row_func, } self.__not_in_table_dict = { - 'cw