diff --git a/manual/plugin_examples/interface_demo/__init__.py b/manual/plugin_examples/interface_demo/__init__.py
index f6733549f2..1a9df67b43 100644
--- a/manual/plugin_examples/interface_demo/__init__.py
+++ b/manual/plugin_examples/interface_demo/__init__.py
@@ -76,5 +76,3 @@ class InterfacePluginDemo(InterfaceActionBase):
ac = self.actual_plugin_
if ac is not None:
ac.apply_settings()
-
-
diff --git a/manual/template_ref_generate.py b/manual/template_ref_generate.py
index ba64235d75..9fcba5e2b3 100644
--- a/manual/template_ref_generate.py
+++ b/manual/template_ref_generate.py
@@ -89,5 +89,6 @@ def generate_template_language_help(language, log):
a(POSTAMBLE)
return ''.join(output)
+
if __name__ == '__main__':
generate_template_language_help()
diff --git a/recipes/1843.recipe b/recipes/1843.recipe
index 5755461574..0a30f9631b 100644
--- a/recipes/1843.recipe
+++ b/recipes/1843.recipe
@@ -17,6 +17,7 @@ from calibre.web.feeds.news import BasicNewsRecipe
use_archive = True
+
def E(parent, name, text='', **attrs):
ans = parent.makeelement(name, **attrs)
ans.text = text
@@ -341,7 +342,6 @@ class Economist(BasicNewsRecipe):
# }}}
-
def preprocess_raw_html(self, raw, url):
# open('/t/raw.html', 'wb').write(raw.encode('utf-8'))
if use_archive:
diff --git a/recipes/afr.recipe b/recipes/afr.recipe
index ef4e31b578..cbba5b9817 100644
--- a/recipes/afr.recipe
+++ b/recipes/afr.recipe
@@ -8,6 +8,7 @@ def absurl(url):
if url.startswith('/'):
return 'https://www.afr.com' + url
+
class afr(BasicNewsRecipe):
title = 'Australian Financial Review'
__author__ = 'unkn0wn'
diff --git a/recipes/altomdata_dk.recipe b/recipes/altomdata_dk.recipe
index c0e76b1fdd..1f771e8d94 100644
--- a/recipes/altomdata_dk.recipe
+++ b/recipes/altomdata_dk.recipe
@@ -28,4 +28,3 @@ class WwwAltomdata_dk(BasicNewsRecipe):
('Kommentarer til Alt om DATA, Datatid TechLife', 'http://www.altomdata.dk/comments/feed'),
]
-
diff --git a/recipes/andhrajyothy_ap.recipe b/recipes/andhrajyothy_ap.recipe
index 0afb08b1ae..fbb43b7b56 100644
--- a/recipes/andhrajyothy_ap.recipe
+++ b/recipes/andhrajyothy_ap.recipe
@@ -18,6 +18,7 @@ today = today.replace('/', '%2F')
index = 'https://epaper.andhrajyothy.com'
+
class andhra(BasicNewsRecipe):
title = 'ఆంధ్రజ్యోతి - ఆంధ్రప్రదేశ్'
language = 'te'
diff --git a/recipes/andhrajyothy_tel.recipe b/recipes/andhrajyothy_tel.recipe
index d10c1bd87e..aba0979455 100644
--- a/recipes/andhrajyothy_tel.recipe
+++ b/recipes/andhrajyothy_tel.recipe
@@ -18,6 +18,7 @@ today = today.replace('/', '%2F')
index = 'https://epaper.andhrajyothy.com'
+
class andhra(BasicNewsRecipe):
title = 'ఆంధ్రజ్యోతి - తెలంగాణ'
language = 'te'
diff --git a/recipes/avisen_dk.recipe b/recipes/avisen_dk.recipe
index 15d8033f24..2b0aa9f8ed 100644
--- a/recipes/avisen_dk.recipe
+++ b/recipes/avisen_dk.recipe
@@ -24,4 +24,3 @@ class WwwAvisen_dk(BasicNewsRecipe):
feeds = [
('Nyheder fra Avisen.dk', 'http://www.avisen.dk/rss.aspx'),
]
-
diff --git a/recipes/boston_globe_print_edition.recipe b/recipes/boston_globe_print_edition.recipe
index 515bb42270..7a48a86b43 100644
--- a/recipes/boston_globe_print_edition.recipe
+++ b/recipes/boston_globe_print_edition.recipe
@@ -12,6 +12,7 @@ def class_as_string(x):
x = ' '.join(x)
return x
+
def class_startswith(*prefixes):
def q(x):
@@ -24,6 +25,7 @@ def class_startswith(*prefixes):
return dict(attrs={'class': q})
+
def absolutize_url(url):
if url.startswith('//'):
return 'https:' + url
diff --git a/recipes/caravan_magazine.recipe b/recipes/caravan_magazine.recipe
index 7a3630e2fd..6f276c5090 100644
--- a/recipes/caravan_magazine.recipe
+++ b/recipes/caravan_magazine.recipe
@@ -15,6 +15,7 @@ def absurl(x):
x = 'https://caravanmagazine.in' + x
return x
+
def safe_dict(data, *names):
ans = data
for x in names:
@@ -49,6 +50,7 @@ def parse_body(x):
yield from parse_body(p)
yield '
'
+
def parse_p(p):
if p.get('type', '') == 'text':
if 'marks' in p:
diff --git a/recipes/chicago_tribune.recipe b/recipes/chicago_tribune.recipe
index 70cf0958ee..66b9969af7 100644
--- a/recipes/chicago_tribune.recipe
+++ b/recipes/chicago_tribune.recipe
@@ -67,7 +67,6 @@ class ChicagoTribune(BasicNewsRecipe):
feeds.append({'title': title, 'url': url})
return [('Articles', feeds)]
-
def preprocess_html(self, soup):
for img in soup.findAll('img', attrs={'data-src': True}):
img['src'] = img['data-src']
diff --git a/recipes/computerworld_dk.recipe b/recipes/computerworld_dk.recipe
index d34ebac609..1102a09b66 100644
--- a/recipes/computerworld_dk.recipe
+++ b/recipes/computerworld_dk.recipe
@@ -51,4 +51,3 @@ class WwwComputerworld_dk(BasicNewsRecipe):
('IDG Kurser', 'http://job.idgkurser.dk/rss/'),
]
-
diff --git a/recipes/deccan_herald.recipe b/recipes/deccan_herald.recipe
index 81525ea8fa..7070db9904 100644
--- a/recipes/deccan_herald.recipe
+++ b/recipes/deccan_herald.recipe
@@ -5,6 +5,7 @@ def absurl(url):
if url.startswith('/'):
return 'https://www.deccanherald.com' + url
+
class herald(BasicNewsRecipe):
title = 'Deccan Herald'
__author__ = 'unkn0wn'
diff --git a/recipes/deutsche_welle_es.recipe b/recipes/deutsche_welle_es.recipe
index 5076f1425d..96639af75a 100644
--- a/recipes/deutsche_welle_es.recipe
+++ b/recipes/deutsche_welle_es.recipe
@@ -54,7 +54,6 @@ class DeutscheWelle_es(BasicNewsRecipe):
('Conozca Alemania', 'http://rss.dw-world.de/rdf/rss-sp-con')
]
-
def preprocess_html(self, soup):
for img in soup.findAll('img', srcset=True):
img['src'] = img['srcset'].split()[6]
diff --git a/recipes/deutsche_welle_sr.recipe b/recipes/deutsche_welle_sr.recipe
index 134ea368fc..e0a052bcd2 100644
--- a/recipes/deutsche_welle_sr.recipe
+++ b/recipes/deutsche_welle_sr.recipe
@@ -59,4 +59,3 @@ class DeutscheWelle_sr(BasicNewsRecipe):
(u'Nauka Tehnika Medicina', u'http://rss.dw-world.de/rdf/rss-ser-science'),
(u'Kultura', u'feed:http://rss.dw-world.de/rdf/rss-ser-cul')
]
-
diff --git a/recipes/deutschland_funk.recipe b/recipes/deutschland_funk.recipe
index aefe587276..a5dd30defc 100644
--- a/recipes/deutschland_funk.recipe
+++ b/recipes/deutschland_funk.recipe
@@ -14,6 +14,7 @@ Fetch Deutschlandfunk & Deutschlandfunk Kultur
## Version:1.6
## New RSS source: https://www.deutschlandfunk.de/rss-angebot-102.html
+
class AdvancedUserRecipe1432200863(BasicNewsRecipe):
title = 'Deutschlandfunk & Deutschlandfunk Kultur'
@@ -34,8 +35,6 @@ class AdvancedUserRecipe1432200863(BasicNewsRecipe):
.b-image-figure, .caption-figure.is-left, .b-image-credits {font-size: .75em; font-weight: normal;margin-bottom: .75em}
'''
-
-
feeds = [
('DLF Nachrichten', 'https://www.deutschlandfunk.de/nachrichten-100.rss'),
('DLF Politikportal', 'https://www.deutschlandfunk.de/politikportal-100.rss'),
diff --git a/recipes/dr_dk.recipe b/recipes/dr_dk.recipe
index 85510a45cd..ef6283ee2a 100644
--- a/recipes/dr_dk.recipe
+++ b/recipes/dr_dk.recipe
@@ -104,7 +104,6 @@ class DRNyheder(BasicNewsRecipe):
cover_url = cover_item['src']
return cover_url
-
keep_only_tags = [
dict(name='h1', attrs={'class': 'dre-article-title__heading'}), # Title
diff --git a/recipes/economist_espresso.recipe b/recipes/economist_espresso.recipe
index ab60ae5c2c..6766cdae82 100644
--- a/recipes/economist_espresso.recipe
+++ b/recipes/economist_espresso.recipe
@@ -242,7 +242,6 @@ class Espresso(BasicNewsRecipe):
raw = etree.tostring(root, encoding='unicode')
return raw
-
def eco_find_image_tables(self, soup):
for x in soup.findAll('table', align=['right', 'center']):
if len(x.findAll('font')) in (1, 2) and len(x.findAll('img')) == 1:
diff --git a/recipes/economist_search.recipe b/recipes/economist_search.recipe
index ae29fc5eab..c6ca84f630 100644
--- a/recipes/economist_search.recipe
+++ b/recipes/economist_search.recipe
@@ -78,6 +78,7 @@ def load_article_from_json(raw):
body += process_node(node)
return '' + body + ''
+
def cleanup_html_article(root):
main = root.xpath('//main')[0]
body = root.xpath('//body')[0]
@@ -91,17 +92,20 @@ def cleanup_html_article(root):
for x in root.xpath('//button'):
x.getparent().remove(x)
+
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
+
def new_tag(soup, name, attrs=()):
impl = getattr(soup, 'new_tag', None)
if impl is not None:
return impl(name, attrs=dict(attrs))
return Tag(soup, name, attrs=attrs or None)
+
def process_url(url):
if url.startswith('/'):
url = 'https://www.economist.com' + url
diff --git a/recipes/esenja.recipe b/recipes/esenja.recipe
index 0417b5d05f..5f88fe7604 100644
--- a/recipes/esenja.recipe
+++ b/recipes/esenja.recipe
@@ -33,7 +33,6 @@ class Esensja(BasicNewsRecipe):
dict(attrs={'class': ['tekst_koniec', 'ref', 'wykop']}),
dict(attrs={'itemprop': ['copyrightHolder', 'publisher']}),
dict(id='komentarze')
-
]
extra_css = '''
diff --git a/recipes/faz_net.recipe b/recipes/faz_net.recipe
index 093b6b320b..fa4e9c60d2 100644
--- a/recipes/faz_net.recipe
+++ b/recipes/faz_net.recipe
@@ -18,7 +18,6 @@ def format_tickaroo_liveblog(soup):
for div in soup.findAll('div', attrs={'class':'tik4-content-block tik4-content-block--rich-text tik4-content-block--position-2'}):
div.insert_before(soup.new_tag('br'))
-
#format liveblogs
for tag in soup.findAll('time'):
ntag = soup.new_tag('br')
@@ -33,6 +32,7 @@ def format_tickaroo_liveblog(soup):
if ntag and temp:
ntag.insert_after(temp)
+
# process run of images
def bilderstrecke(soup,tag):
flag = False
@@ -76,10 +76,10 @@ def bilderstrecke(soup,tag):
collect.append(fig)
soup.find(class_='header-teaser').insert_after(collect)
-
for tag in soup.findAll(class_='header-teaser__image--default'):
tag.extract()
+
def story(soup,tag):
first_image = soup.find('img',attrs={'loading':'lazy'})
first_caption = soup.find('figcaption',attrs={'class':'caption'})
@@ -136,7 +136,6 @@ class FazNet(BasicNewsRecipe):
dict(name = 'script', attrs = {'id':'__NUXT_DATA__'}),
]
-
remove_tags = [
dict(name='div', attrs={'class':[
'related-articles','consent-placeholder',
@@ -153,7 +152,6 @@ class FazNet(BasicNewsRecipe):
remove_attributes = ['onclick']
-
test_article = False
if not test_article:
feeds = [
diff --git a/recipes/globaltimes.recipe b/recipes/globaltimes.recipe
index e7d808c1ad..0bcf1aa43d 100644
--- a/recipes/globaltimes.recipe
+++ b/recipes/globaltimes.recipe
@@ -7,6 +7,7 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
index = 'https://www.globaltimes.cn/'
+
class GlobalTimes(BasicNewsRecipe):
title = 'Global Times'
__author__ = 'unkn0wn'
diff --git a/recipes/hamilton_spectator.recipe b/recipes/hamilton_spectator.recipe
index 92180b75ea..57aed48530 100644
--- a/recipes/hamilton_spectator.recipe
+++ b/recipes/hamilton_spectator.recipe
@@ -5,10 +5,12 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
Hamilton Spectator Calibre Recipe
'''
+
def absurl(url):
if url.startswith('/'):
return 'https://www.thespec.com' + url
+
class HamiltonSpectator(BasicNewsRecipe):
title = u'Hamilton Spectator'
max_articles_per_feed = 50
diff --git a/recipes/himal_southasian.recipe b/recipes/himal_southasian.recipe
index f384bd40b6..13621ac383 100644
--- a/recipes/himal_southasian.recipe
+++ b/recipes/himal_southasian.recipe
@@ -17,6 +17,7 @@ def get_story(story):
for x in story['story-elements']:
yield from get_story(x)
+
def img(img):
yield ''
if 'image-s3-key' in img:
@@ -25,6 +26,7 @@ def img(img):
yield '
' + img['title'] + '
'
yield ''
+
class himal(BasicNewsRecipe):
title = 'Himal Southasian'
__author__ = 'unkn0wn'
diff --git a/recipes/hindufeeds.recipe b/recipes/hindufeeds.recipe
index 143cdcdd6a..8d6aba19b2 100644
--- a/recipes/hindufeeds.recipe
+++ b/recipes/hindufeeds.recipe
@@ -74,7 +74,6 @@ class TheHindufeeds(BasicNewsRecipe):
src.extract()
return soup
-
def get_cover_url(self):
soup = self.index_to_soup('https://www.thehindu.com/todays-paper/')
if cover := soup.find(attrs={'class':'hindu-ad'}):
diff --git a/recipes/hindustan_times_print.recipe b/recipes/hindustan_times_print.recipe
index dae7044289..4fd78d0363 100644
--- a/recipes/hindustan_times_print.recipe
+++ b/recipes/hindustan_times_print.recipe
@@ -8,6 +8,7 @@ from calibre.web.feeds.news import BasicNewsRecipe
index = 'https://epaper.hindustantimes.com'
+
class ht(BasicNewsRecipe):
title = 'Hindustan Times Print Edition'
language = 'en_IN'
@@ -100,7 +101,6 @@ class ht(BasicNewsRecipe):
feeds_dict[section].append({'title': title, 'description': desc, 'url': url})
return list(feeds_dict.items())
-
def preprocess_raw_html(self, raw, *a):
data = json.loads(raw)
body = ''
diff --git a/recipes/hurriyet.recipe b/recipes/hurriyet.recipe
index 697fc037dd..11dead19b0 100644
--- a/recipes/hurriyet.recipe
+++ b/recipes/hurriyet.recipe
@@ -64,4 +64,3 @@ class Hurriyet(BasicNewsRecipe):
(u'Ankara', 'https://www.hurriyet.com.tr/rss/ankara'),
(u'Ege', 'https://www.hurriyet.com.tr/rss/ege')
]
-
diff --git a/recipes/ifzm.recipe b/recipes/ifzm.recipe
index b9c962eab5..0ceacd4dc0 100644
--- a/recipes/ifzm.recipe
+++ b/recipes/ifzm.recipe
@@ -8,6 +8,7 @@ def absurl(url):
if url.startswith('/'):
return 'https://www.infzm.com' + url
+
def json_to_html(raw, link):
data = json.loads(raw)
data = data['data']['content']
@@ -51,7 +52,6 @@ class infzm(BasicNewsRecipe):
.cm_pic_caption, .cm_pic_author { font-size:small; text-align:center; }
'''
-
def parse_index(self):
index = 'https://www.infzm.com/'
sections = [
diff --git a/recipes/inc42.recipe b/recipes/inc42.recipe
index ec43ebdfbe..b5b10066e0 100644
--- a/recipes/inc42.recipe
+++ b/recipes/inc42.recipe
@@ -47,7 +47,6 @@ class inc42(BasicNewsRecipe):
feeds.append((section, articles))
return feeds
-
def preprocess_html(self, soup):
for img in soup.findAll('img', attrs={'data-src':True}):
img['src'] = img['data-src']
diff --git a/recipes/india_speaks_reddit.recipe b/recipes/india_speaks_reddit.recipe
index 5866dc379f..c9b9c67bef 100644
--- a/recipes/india_speaks_reddit.recipe
+++ b/recipes/india_speaks_reddit.recipe
@@ -20,4 +20,3 @@ class IndiaSpeaksReddit(BasicNewsRecipe):
feeds = [
('India Speaks Reddit main feed', 'https://www.reddit.com/r/IndiaSpeaks.rss'),
]
-
diff --git a/recipes/kosmonauta_pl.recipe b/recipes/kosmonauta_pl.recipe
index 8cc7258c1b..2e7c23ac8f 100644
--- a/recipes/kosmonauta_pl.recipe
+++ b/recipes/kosmonauta_pl.recipe
@@ -17,4 +17,3 @@ class Kosmonauta(BasicNewsRecipe):
remove_attributes = ['style']
max_articles_per_feed = 100
feeds = [(u'Kosmonauta.net', u'http://www.kosmonauta.net/feed')]
-
diff --git a/recipes/liberation.recipe b/recipes/liberation.recipe
index 18b936ac6a..d94dc4c0ec 100644
--- a/recipes/liberation.recipe
+++ b/recipes/liberation.recipe
@@ -21,12 +21,14 @@ def resize(x):
if '_750' in k:
return v
+
m_fr = {
1: 'Janvier', 2: 'Février', 3: 'Mars', 4: 'Avril',
5: 'Mai', 6: 'Juin', 7: 'Juillet', 8: 'Août',
9: 'Septembre', 10: 'Octobre', 11: 'Novembre', 12: 'Décembre'
}
+
def json_to_html(raw):
data = json.loads(raw)
diff --git a/recipes/live_law.recipe b/recipes/live_law.recipe
index 4d6a1e3c5a..c05ebaebec 100644
--- a/recipes/live_law.recipe
+++ b/recipes/live_law.recipe
@@ -6,6 +6,7 @@ def absurl(url):
if url.startswith('/'):
return 'https://www.livelaw.in' + url
+
class livelaw(BasicNewsRecipe):
title = 'Live Law'
__author__ = 'unkn0wn'
diff --git a/recipes/new_yorker.recipe b/recipes/new_yorker.recipe
index b190c6a33c..4b4ee666a0 100644
--- a/recipes/new_yorker.recipe
+++ b/recipes/new_yorker.recipe
@@ -14,6 +14,7 @@ def absurl(x):
x = 'https://www.newyorker.com' + x
return x
+
class NewYorker(BasicNewsRecipe):
title = 'The New Yorker Magazine'
@@ -129,7 +130,6 @@ class NewYorker(BasicNewsRecipe):
feeds_dict[section].append({'title': title, 'url': url, 'description': desc})
return feeds_dict.items()
-
# The New Yorker changes the content it delivers based on cookies, so the
# following ensures that we send no cookies
def get_browser(self, *args, **kwargs):
diff --git a/recipes/nhk_news.recipe b/recipes/nhk_news.recipe
index b9dcc0ebd3..6582cbc28f 100644
--- a/recipes/nhk_news.recipe
+++ b/recipes/nhk_news.recipe
@@ -36,4 +36,3 @@ class ReutersJa(BasicNewsRecipe):
for img in soup.findAll('img', attrs={'data-src':True}):
img['src'] = img['data-src']
return soup
-
diff --git a/recipes/nordjyske_dk.recipe b/recipes/nordjyske_dk.recipe
index 76a71e9454..8d9132941e 100644
--- a/recipes/nordjyske_dk.recipe
+++ b/recipes/nordjyske_dk.recipe
@@ -38,4 +38,3 @@ class Nordjyske_dk(BasicNewsRecipe):
('Aalborg', 'http://nordjyske.dk/rss/aalborg'),
]
-
diff --git a/recipes/nzz_ger.recipe b/recipes/nzz_ger.recipe
index 3c7a1c15fd..9f6e4ea0c7 100644
--- a/recipes/nzz_ger.recipe
+++ b/recipes/nzz_ger.recipe
@@ -97,7 +97,6 @@ class Nzz(BasicNewsRecipe):
return url
-
def get_browser(self, *args, **kwargs):
kwargs['user_agent'] = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
br = BasicNewsRecipe.get_browser(self, *args, **kwargs)
diff --git a/recipes/pajama.recipe b/recipes/pajama.recipe
index 93bd3dab7e..4b556d2db4 100644
--- a/recipes/pajama.recipe
+++ b/recipes/pajama.recipe
@@ -18,4 +18,3 @@ class PajamasMedia(BasicNewsRecipe):
'http://feeds.feedburner.com/PajamasMedia'),
]
-
diff --git a/recipes/radio_canada.recipe b/recipes/radio_canada.recipe
index 765c40920b..39eb26d7d9 100644
--- a/recipes/radio_canada.recipe
+++ b/recipes/radio_canada.recipe
@@ -24,6 +24,7 @@ def classes(classes):
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
+
class RadioCanada(BasicNewsRecipe):
title = 'Radio Canada'
__author__ = 'quatorze, pticrix'
diff --git a/recipes/rnd.recipe b/recipes/rnd.recipe
index 62edb2a6f6..9140078970 100644
--- a/recipes/rnd.recipe
+++ b/recipes/rnd.recipe
@@ -79,7 +79,6 @@ class RND(BasicNewsRecipe):
#('E-Mobility', 'https://www.rnd.de/arc/outboundfeeds/rss/category/e-mobility/')
]
-
def parse_feeds(self):
# Call parent's method.
feeds = BasicNewsRecipe.parse_feeds(self)
diff --git a/recipes/saechsische.recipe b/recipes/saechsische.recipe
index 6d0fe90f4a..577800b500 100644
--- a/recipes/saechsische.recipe
+++ b/recipes/saechsische.recipe
@@ -193,7 +193,6 @@ class Saechsische(BasicNewsRecipe):
#('Beruf & Bildung', 'https://www.saechsische.de/arc/outboundfeeds/rss/category/beruf-und-bildung')
]
-
def parse_feeds(self):
# Call parent's method.
feeds = BasicNewsRecipe.parse_feeds(self)
diff --git a/recipes/salon.recipe b/recipes/salon.recipe
index e719e9b170..93a41fa9ef 100644
--- a/recipes/salon.recipe
+++ b/recipes/salon.recipe
@@ -10,6 +10,7 @@ def classes(classes):
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
+
class Salon_com(BasicNewsRecipe):
title = 'Salon.com'
diff --git a/recipes/scmp.recipe b/recipes/scmp.recipe
index 8856c1543f..f536972676 100644
--- a/recipes/scmp.recipe
+++ b/recipes/scmp.recipe
@@ -20,6 +20,7 @@ def E(parent, name, text='', **attrs):
parent.append(ans)
return ans
+
def process_node(node, html_parent):
ntype = node.get('type')
@@ -45,6 +46,7 @@ def ts_date(x):
dt = datetime.fromtimestamp(x/1000 + time.timezone)
return dt.strftime('%b %d, %Y at %I:%M %p')
+
def load_article_from_json(raw, root):
# open('/t/raw.json', 'w').write(raw)
data = json.loads(raw)['props']['pageProps']['payload']['data']['article']
diff --git a/recipes/sputnik.recipe b/recipes/sputnik.recipe
index 43f0b5f7b0..4ef83a7a2b 100644
--- a/recipes/sputnik.recipe
+++ b/recipes/sputnik.recipe
@@ -25,5 +25,4 @@ class Ria_eng(BasicNewsRecipe):
'comment': description, 'tags': category, 'language': language
}
-
feeds = [(u'News', u'https://sputnikglobe.com/export/rss2/archive/index.xml')]
diff --git a/recipes/tagesspiegel.recipe b/recipes/tagesspiegel.recipe
index 36b6600bb1..7a36a1059c 100644
--- a/recipes/tagesspiegel.recipe
+++ b/recipes/tagesspiegel.recipe
@@ -70,4 +70,3 @@ class TagesspiegelRss(BasicNewsRecipe):
(u'Medien', u'http://www.tagesspiegel.de/contentexport/feed/medien'),
(u'Wissen', u'http://www.tagesspiegel.de/contentexport/feed/wissen')
]
-
diff --git a/recipes/tehelka.recipe b/recipes/tehelka.recipe
index e90249d2c8..18edfcfc70 100644
--- a/recipes/tehelka.recipe
+++ b/recipes/tehelka.recipe
@@ -27,7 +27,6 @@ class Tehelka(BasicNewsRecipe):
use_embedded_content = False
ignore_duplicate_articles = {'title', 'url'}
-
feeds = [
('Tehelka', 'http://tehelka.com/rss'),
]
diff --git a/recipes/the_saturday_paper.recipe b/recipes/the_saturday_paper.recipe
index d71e09446f..25eb07d203 100644
--- a/recipes/the_saturday_paper.recipe
+++ b/recipes/the_saturday_paper.recipe
@@ -35,7 +35,6 @@ class SaturdayPaper(BasicNewsRecipe):
{'name': 'div', 'class': 'end-matter'},
]
-
def get_cover_url(self):
soup = self.index_to_soup('https://www.thesaturdaypaper.com.au/editions/')
div = soup.find('div', attrs={'class':'article__image'})
diff --git a/recipes/theoldie.recipe b/recipes/theoldie.recipe
index 6c20d77310..009f04297c 100644
--- a/recipes/theoldie.recipe
+++ b/recipes/theoldie.recipe
@@ -196,7 +196,6 @@ class PrivateEyeRecipe(BasicNewsRecipe):
return soup
-
# Remove features not wanted and tweak HTML
preprocess_regexps = [
# Remove big blank spaces
diff --git a/recipes/times_online.recipe b/recipes/times_online.recipe
index 8f00a45f74..23c28ab071 100644
--- a/recipes/times_online.recipe
+++ b/recipes/times_online.recipe
@@ -11,11 +11,13 @@ def resize(x):
elif '?crop=' in x:
return x + '&resize=600'
+
def absurl(url):
if url.startswith('/'):
url = 'https://www.thetimes.com' + url
return url
+
class times(BasicNewsRecipe):
title = 'The Times and Sunday Times'
__author__ = 'unkn0wn'
diff --git a/recipes/tls_mag.recipe b/recipes/tls_mag.recipe
index 8aa0b13e0a..1be3472516 100644
--- a/recipes/tls_mag.recipe
+++ b/recipes/tls_mag.recipe
@@ -14,6 +14,7 @@ def re_html(y):
return soup.text
return ''
+
def get_id(url):
rq = browser().open(url)
return re.search(r'\?p=(\S+)>', str(rq.info())).group(1)
diff --git a/recipes/toiprint.recipe b/recipes/toiprint.recipe
index 8fa9627f67..e610205a95 100644
--- a/recipes/toiprint.recipe
+++ b/recipes/toiprint.recipe
@@ -23,6 +23,7 @@ date_ = dt.strftime('%d_%m_%Y')
index = 'https://asset.harnscloud.com/PublicationData/TOI/' + le + '/' + date0
img_index = 'https://cmsimages.timesgroup.com/image-resizer?epaper_s3_path=PublicationData/TOI/' + le + '/' + date0
+
def handle_images(x, soup):
img = soup.find('img')
if img:
@@ -36,6 +37,7 @@ def handle_images(x, soup):
for lead in reversed(soup.findAll('div', attrs={'class':'lead'})):
x.insert_after(lead)
+
class toiprint(BasicNewsRecipe):
title = 'TOI Print Edition'
language = 'en_IN'
diff --git a/recipes/usatoday.recipe b/recipes/usatoday.recipe
index d5518aaf1d..59d9d7ffb5 100644
--- a/recipes/usatoday.recipe
+++ b/recipes/usatoday.recipe
@@ -14,10 +14,12 @@ def classes(classes):
return dict(attrs={
'class': lambda x: x and frozenset(x.split()).intersection(q)})
+
def absurl(url):
if url.startswith('/'):
return 'https://www.usatoday.com' + url
+
class USAToday(BasicNewsRecipe):
title = 'USA Today'
diff --git a/recipes/wsj_free.recipe b/recipes/wsj_free.recipe
index 7ba539a6d9..32c6703d95 100644
--- a/recipes/wsj_free.recipe
+++ b/recipes/wsj_free.recipe
@@ -28,6 +28,7 @@ except ImportError:
needs_subscription = False
+
class WSJ(BasicNewsRecipe):
if needs_subscription:
diff --git a/ruff-strict-pep8.toml b/ruff-strict-pep8.toml
index 895e02d6ac..922e8b586b 100644
--- a/ruff-strict-pep8.toml
+++ b/ruff-strict-pep8.toml
@@ -36,6 +36,7 @@ select = [
'RUF055', # unnecessary regex
'RUF039', # always use raw-string for regex
'RUF047', # needless else
+ 'E302', 'E303', 'E304', 'E305', 'W391', # blank-line standard
]
[lint.per-file-ignores]
@@ -49,7 +50,7 @@ select = [
"src/calibre/gui2/tts/manager.py" = ['UP037']
"src/calibre/utils/copy_files.py" = ['UP037']
"src/calibre/utils/smartypants.py" = ['RUF039', 'RUF055']
-"src/qt/*.py" = ['I']
+"src/qt/*.py" = ['I', 'E302']
"src/qt/*.pyi" = ['I']
[lint.isort]
diff --git a/setup.py b/setup.py
index e67d61b93a..c7e27c9133 100755
--- a/setup.py
+++ b/setup.py
@@ -29,7 +29,6 @@ def check_version_info():
exit(f'calibre requires Python {minver}. Current Python version: {".".join(map(str, sys.version_info[:3]))}')
-
check_version_info()
sys.path.insert(0, src_base)
diff --git a/setup/build.py b/setup/build.py
index 1d968c012a..685f166126 100644
--- a/setup/build.py
+++ b/setup/build.py
@@ -23,6 +23,7 @@ isunix = islinux or ismacos or isbsd or ishaiku
py_lib = os.path.join(sys.prefix, 'libs', 'python{}{}.lib'.format(*sys.version_info[:2]))
+
class CompileCommand(NamedTuple):
cmd: list[str]
src: str
@@ -145,7 +146,6 @@ def parse_extension(ext, compiling_for='native'):
if compiling_for == 'windows':
get_key = 'windows_'
-
def get(k, default=''):
ans = ext.pop(k, default)
ans = ext.pop(get_key + k, ans)
@@ -242,7 +242,6 @@ class Environment(NamedTuple):
return list(map(map_name, libs))
-
def init_env(debug=False, sanitize=False, compiling_for='native'):
from setup.build_environment import NMAKE, win_cc, win_inc, win_ld, win_lib
linker = None
diff --git a/setup/file-hosting-bw.py b/setup/file-hosting-bw.py
index c179e6fb4a..b1e8e7ddfa 100644
--- a/setup/file-hosting-bw.py
+++ b/setup/file-hosting-bw.py
@@ -10,6 +10,7 @@ import subprocess
BASE = '/srv/download/bw'
+
def main():
if not os.path.exists(BASE):
os.makedirs(BASE)
@@ -52,5 +53,6 @@ def main():
with open('index.html', 'wb') as f:
f.write(html.encode('utf-8'))
+
if __name__ == '__main__':
main()
diff --git a/setup/hosting.py b/setup/hosting.py
index fb1e528c3d..8dc1a73144 100644
--- a/setup/hosting.py
+++ b/setup/hosting.py
@@ -69,7 +69,6 @@ class ReadFileWithProgressReporting: # {{{
)
sys.stdout.flush()
-
# }}}
@@ -93,7 +92,6 @@ class Base: # {{{
print('_' * 50)
sys.stdout.flush()
-
# }}}
@@ -127,7 +125,6 @@ class SourceForge(Base): # {{{
break
print('Uploaded in', int(time.time() - start), 'seconds\n\n')
-
# }}}
@@ -259,7 +256,6 @@ class GitHub(Base): # {{{
self.fail(r, f'Failed to create release for version: {self.version}')
return r.json()
-
# }}}
@@ -388,10 +384,9 @@ def generate_index(): # {{{
f.write(index.encode('utf-8'))
finally:
os.chdir('..')
-
-
# }}}
+
SERVER_BASE = '/srv/download/'
@@ -432,9 +427,6 @@ def upload_to_servers(files, version): # {{{
# else:
# break
# print('Uploaded in', int(time.time() - start), 'seconds\n\n')
- #
-
-
# }}}
diff --git a/setup/lc_data.py b/setup/lc_data.py
index 8756a9930c..307a4d74da 100644
--- a/setup/lc_data.py
+++ b/setup/lc_data.py
@@ -25,6 +25,7 @@ def generate_data():
ans.append((x, nl(getattr(locale, x.upper()))))
return ans
+
def main():
if sys.version_info[0] < 3: # noqa: UP036
raise RuntimeError('Must be run using python 3.x')
diff --git a/setup/plugins_mirror.py b/setup/plugins_mirror.py
index 80bca84c19..d33e4b5893 100644
--- a/setup/plugins_mirror.py
+++ b/setup/plugins_mirror.py
@@ -1,7 +1,6 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2013, Kovid Goyal
-
# Imports {{{
import argparse
import ast
@@ -151,8 +150,8 @@ def load_plugins_index():
raise
return json.loads(bz2.decompress(raw))
-# Get metadata from plugin zip file {{{
+# Get metadata from plugin zip file {{{
def convert_node(fields, x, names={}, import_data=None):
name = x.__class__.__name__
@@ -357,9 +356,9 @@ def get_plugin_info(raw_zip):
return json.loads(res.stdout)
raise
-
# }}}
+
def update_plugin_from_entry(plugin, entry):
plugin['index_name'] = entry.name
plugin['thread_url'] = entry.url
@@ -706,7 +705,6 @@ def test_parse(): # {{{
if new_url != full_url:
print(f'new url ({aname}): {new_url} != {full_url} for plugin at: {url}')
raise SystemExit(1)
-
# }}}
@@ -740,7 +738,6 @@ class HelloWorld(FileTypePlugin):
zf.writestr('very/ver.py', b'MV = (0, 7, 53)')
zf.writestr('__init__.py', b'from xxx import yyy\nfrom very.lovely import HelloWorld')
assert get_plugin_info(buf.getvalue()) == vals
-
# }}}
diff --git a/setup/test.py b/setup/test.py
index 8be2acac81..32f26cc879 100644
--- a/setup/test.py
+++ b/setup/test.py
@@ -65,7 +65,6 @@ class Test(BaseTest):
ffmpeg_dll_dir = os.path.join(SW, 'ffmpeg', 'bin')
os.add_dll_directory(ffmpeg_dll_dir)
-
from calibre.utils.run_tests import filter_tests_by_name, find_tests, remove_tests_by_name, run_cli
tests = find_tests(which_tests=frozenset(opts.test_module), exclude_tests=frozenset(opts.exclude_test_module))
if opts.test_name:
diff --git a/setup/translations.py b/setup/translations.py
index 1e46bfe156..e205da504d 100644
--- a/setup/translations.py
+++ b/setup/translations.py
@@ -607,7 +607,6 @@ class Translations(POT): # {{{
if os.path.exists(destbase):
shutil.rmtree(destbase)
shutil.rmtree(self.cache_dir)
-
# }}}
@@ -756,7 +755,6 @@ class GetTranslations(Translations): # {{{
cc('git add */*.po'.split())
cc('git commit -am'.split() + [msg or 'Updated translations'])
cc('git push'.split())
-
# }}}
@@ -817,7 +815,6 @@ class ISO639(Command): # {{{
def clean(self):
if os.path.exists(self.DEST):
os.remove(self.DEST)
-
# }}}
diff --git a/setup/upload.py b/setup/upload.py
index c4a8217d3e..487461104e 100644
--- a/setup/upload.py
+++ b/setup/upload.py
@@ -98,7 +98,6 @@ class ReUpload(Command): # {{{
if os.path.exists(x):
os.remove(x)
-
# }}}
@@ -159,7 +158,6 @@ def run_remote_upload(args):
'python', 'hosting.py'
] + args)
-
# }}}
@@ -313,7 +311,6 @@ class UploadInstallers(Command): # {{{
def upload_to_calibre(self):
run_remote_upload(calibre_cmdline(__version__))
-
# }}}
@@ -355,7 +352,6 @@ class UploadUserManual(Command): # {{{
)
check_call('ssh main chown -R http:http /srv/manual'.split())
-
# }}}
@@ -382,7 +378,6 @@ class UploadDemo(Command): # {{{
check_call(f'scp /tmp/html-demo.zip main:{DOWNLOADS}/', shell=True)
-
# }}}
@@ -410,5 +405,4 @@ class UploadToServer(Command): # {{{
f'ssh main /usr/local/bin/update-calibre-version.py {__version__} && /usr/local/bin/update-calibre-code.py && /apps/static/generate.py'
).split())
-
# }}}
diff --git a/setup/vcvars.py b/setup/vcvars.py
index 99cfb16d41..ee88f444a6 100644
--- a/setup/vcvars.py
+++ b/setup/vcvars.py
@@ -128,7 +128,6 @@ def query_vcvarsall(is64bit=True):
comn_tools[k] = int(m.group(1))
comntools = sorted(comn_tools, key=comn_tools.__getitem__)[-1]
-
def g(k):
try:
return env[k]
diff --git a/setup/wincross.py b/setup/wincross.py
index 31e688362c..00d0ae224d 100644
--- a/setup/wincross.py
+++ b/setup/wincross.py
@@ -176,6 +176,7 @@ def download_item(dest_dir: str, file: File):
raise SystemExit(f'The hash for {file.filename} does not match.'
f' {m.hexdigest()} != {file.sha256}')
+
def cabinets_in_msi(path):
raw = subprocess.check_output(['msiinfo', 'export', path, 'Media']).decode('utf-8')
return re.findall(r'\S+\.cab', raw)
diff --git a/src/calibre/__init__.py b/src/calibre/__init__.py
index c5697bce13..6513b9de1f 100644
--- a/src/calibre/__init__.py
+++ b/src/calibre/__init__.py
@@ -450,6 +450,7 @@ def my_unichr(num):
except (ValueError, OverflowError):
return '?'
+
XML_ENTITIES = {
'"' : '"',
"'" : ''',
@@ -458,6 +459,7 @@ XML_ENTITIES = {
'&' : '&'
}
+
def entity_to_unicode(match, exceptions=(), encoding=None, result_exceptions={}):
'''
:param match: A match object such that '&'+match.group(1)';' is the entity.
diff --git a/src/calibre/constants.py b/src/calibre/constants.py
index dd11ae7d3c..e94c6ff7ea 100644
--- a/src/calibre/constants.py
+++ b/src/calibre/constants.py
@@ -410,7 +410,6 @@ else:
atexit.register(cleanup_cdir)
# }}}
-
is_running_from_develop = False
if getattr(sys, 'frozen', False):
try:
diff --git a/src/calibre/customize/__init__.py b/src/calibre/customize/__init__.py
index afdf4cceaa..df0b6a6759 100644
--- a/src/calibre/customize/__init__.py
+++ b/src/calibre/customize/__init__.py
@@ -475,6 +475,7 @@ class MetadataReaderPlugin(Plugin): # {{{
:return: A :class:`calibre.ebooks.metadata.book.Metadata` object
'''
return None
+
# }}}
diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py
index 7374ed3cec..2a5cce0df6 100644
--- a/src/calibre/customize/builtins.py
+++ b/src/calibre/customize/builtins.py
@@ -11,8 +11,8 @@ from calibre.ebooks.metadata.archive import ArchiveExtract, KPFExtract, get_comi
plugins = []
-# To archive plugins {{{
+# To archive plugins {{{
class PML2PMLZ(FileTypePlugin):
name = 'PML to PMLZ'
@@ -96,8 +96,8 @@ class TXT2TXTZ(FileTypePlugin):
plugins += [HTML2ZIP, PML2PMLZ, TXT2TXTZ, ArchiveExtract, KPFExtract]
# }}}
-# Metadata reader plugins {{{
+# Metadata reader plugins {{{
class ComicMetadataReader(MetadataReaderPlugin):
@@ -434,8 +434,8 @@ plugins += [x for x in list(locals().values()) if isinstance(x, type) and
# }}}
-# Metadata writer plugins {{{
+# Metadata writer plugins {{{
class EPUBMetadataWriter(MetadataWriterPlugin):
@@ -835,7 +835,6 @@ plugins += [
USER_DEFINED,
]
-
# }}}
# New metadata download plugins {{{
@@ -850,8 +849,8 @@ plugins += [GoogleBooks, GoogleImages, Amazon, Edelweiss, OpenLibrary, BigBookSe
# }}}
-# Interface Actions {{{
+# Interface Actions {{{
class ActionAdd(InterfaceActionBase):
name = 'Add Books'
@@ -1137,6 +1136,7 @@ class ActionAllActions(InterfaceActionBase):
actual_plugin = 'calibre.gui2.actions.all_actions:AllGUIActions'
description = _('Open a menu showing all installed GUI actions')
+
class ActionVirtualLibrary(InterfaceActionBase):
name = 'Virtual Library'
actual_plugin = 'calibre.gui2.actions.virtual_library:VirtualLibraryAction'
@@ -1183,8 +1183,8 @@ plugins += [ActionAdd, ActionAllActions, ActionFetchAnnotations, ActionGenerateC
# }}}
-# Preferences Plugins {{{
+# Preferences Plugins {{{
class LookAndFeel(PreferencesPlugin):
name = 'Look & Feel'
@@ -1460,8 +1460,8 @@ plugins += [LookAndFeel, Behavior, Columns, Toolbar, Search, InputOptions,
# }}}
-# Store plugins {{{
+# Store plugins {{{
class StoreAmazonKindleStore(StoreBase):
name = 'Amazon Kindle'
diff --git a/src/calibre/customize/conversion.py b/src/calibre/customize/conversion.py
index 59a641bad6..54e61dc24a 100644
--- a/src/calibre/customize/conversion.py
+++ b/src/calibre/customize/conversion.py
@@ -11,7 +11,6 @@ from calibre.customize import Plugin
class ConversionOption:
-
'''
Class representing conversion options
'''
@@ -127,7 +126,6 @@ def gui_configuration_widget(name, parent, get_option_by_name,
class InputFormatPlugin(Plugin):
-
'''
InputFormatPlugins are responsible for converting a document into
HTML+OPF+CSS+etc.
@@ -275,7 +273,6 @@ class InputFormatPlugin(Plugin):
class OutputFormatPlugin(Plugin):
-
'''
OutputFormatPlugins are responsible for converting an OEB document
(OPF+HTML) into an output e-book.
diff --git a/src/calibre/customize/profiles.py b/src/calibre/customize/profiles.py
index 91e6a3fcca..ba285fbf27 100644
--- a/src/calibre/customize/profiles.py
+++ b/src/calibre/customize/profiles.py
@@ -34,8 +34,8 @@ class Plugin(_Plugin):
self.width_pts = self.width * 72./self.dpi
self.height_pts = self.height * 72./self.dpi
-# Input profiles {{{
+# Input profiles {{{
class InputProfile(Plugin):
diff --git a/src/calibre/customize/ui.py b/src/calibre/customize/ui.py
index 6c75784aa6..3911c738e1 100644
--- a/src/calibre/customize/ui.py
+++ b/src/calibre/customize/ui.py
@@ -74,11 +74,10 @@ def load_plugin(path_to_zip_file): # {{{
:return: A :class:`Plugin` instance.
'''
return loader.load(path_to_zip_file)
-
# }}}
-# Enable/disable plugins {{{
+# Enable/disable plugins {{{
def disable_plugin(plugin_or_name):
x = getattr(plugin_or_name, 'name', plugin_or_name)
@@ -131,8 +130,8 @@ def is_disabled(plugin):
plugin.name in default_disabled_plugins
# }}}
-# File type plugins {{{
+# File type plugins {{{
_on_import = {}
_on_postimport = {}
@@ -270,8 +269,8 @@ def run_plugins_on_postadd(db, book_id, fmt_map):
# }}}
-# Plugin customization {{{
+# Plugin customization {{{
def customize_plugin(plugin, custom):
d = config['plugin_customization']
@@ -284,8 +283,8 @@ def plugin_customization(plugin):
# }}}
-# Input/Output profiles {{{
+# Input/Output profiles {{{
def input_profiles():
for plugin in _initialized_plugins:
@@ -299,8 +298,8 @@ def output_profiles():
yield plugin
# }}}
-# Interface Actions # {{{
+# Interface Actions # {{{
def interface_actions():
customization = config['plugin_customization']
@@ -311,8 +310,8 @@ def interface_actions():
yield plugin
# }}}
-# Preferences Plugins # {{{
+# Preferences Plugins # {{{
def preferences_plugins():
customization = config['plugin_customization']
@@ -323,8 +322,8 @@ def preferences_plugins():
yield plugin
# }}}
-# Library Closed Plugins # {{{
+# Library Closed Plugins # {{{
def available_library_closed_plugins():
customization = config['plugin_customization']
@@ -343,8 +342,8 @@ def has_library_closed_plugins():
return False
# }}}
-# Store Plugins # {{{
+# Store Plugins # {{{
def store_plugins():
customization = config['plugin_customization']
@@ -375,8 +374,8 @@ def available_stores():
# }}}
-# Metadata read/write {{{
+# Metadata read/write {{{
_metadata_readers = {}
_metadata_writers = {}
@@ -519,8 +518,8 @@ def can_set_metadata(ftype):
# }}}
-# Add/remove plugins {{{
+# Add/remove plugins {{{
def add_plugin(path_to_zip_file):
make_config_dir()
@@ -565,8 +564,8 @@ def remove_plugin(plugin_or_name):
# }}}
-# Input/Output format plugins {{{
+# Input/Output format plugins {{{
def input_format_plugins():
for plugin in _initialized_plugins:
@@ -623,8 +622,8 @@ def available_output_formats():
# }}}
-# Catalog plugins {{{
+# Catalog plugins {{{
def catalog_plugins():
for plugin in _initialized_plugins:
@@ -648,8 +647,8 @@ def plugin_for_catalog_format(fmt):
# }}}
-# Device plugins {{{
+# Device plugins {{{
def device_plugins(include_disabled=False):
for plugin in _initialized_plugins:
@@ -670,8 +669,8 @@ def disabled_device_plugins():
yield plugin
# }}}
-# Metadata sources2 {{{
+# Metadata sources2 {{{
def metadata_plugins(capabilities):
capabilities = frozenset(capabilities)
@@ -702,8 +701,8 @@ def patch_metadata_plugins(possibly_updated_plugins):
_initialized_plugins[i] = pup
# }}}
-# Editor plugins {{{
+# Editor plugins {{{
def all_edit_book_tool_plugins():
for plugin in _initialized_plugins:
@@ -711,8 +710,8 @@ def all_edit_book_tool_plugins():
yield plugin
# }}}
-# Initialize plugins {{{
+# Initialize plugins {{{
_initialized_plugins = []
@@ -823,8 +822,8 @@ def initialized_plugins():
# }}}
-# CLI {{{
+# CLI {{{
def build_plugin(path):
from calibre import prints
diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py
index f17e3cbc7c..734845599a 100644
--- a/src/calibre/db/backend.py
+++ b/src/calibre/db/backend.py
@@ -197,8 +197,8 @@ class DBPrefs(dict): # {{{
return json.load(f, object_hook=from_json)
# }}}
-# Extra collators {{{
+# Extra collators {{{
def pynocase(one, two, encoding='utf-8'):
if isbytestring(one):
@@ -226,8 +226,8 @@ def icu_collator(s1, s2):
# }}}
-# Unused aggregators {{{
+# Unused aggregators {{{
def Concatenate(sep=','):
'''String concatenation aggregator for sqlite'''
diff --git a/src/calibre/db/cache.py b/src/calibre/db/cache.py
index a0aaa293cf..f90f30e937 100644
--- a/src/calibre/db/cache.py
+++ b/src/calibre/db/cache.py
@@ -135,7 +135,6 @@ dynamic_category_preferences = frozenset({'grouped_search_make_user_categories',
class Cache:
-
'''
An in-memory cache of the metadata.db file from a calibre library.
This class also serves as a threadsafe API for accessing the database.
diff --git a/src/calibre/db/categories.py b/src/calibre/db/categories.py
index 1480805e94..df5829347e 100644
--- a/src/calibre/db/categories.py
+++ b/src/calibre/db/categories.py
@@ -189,6 +189,7 @@ def sort_key_for_name_and_first_letter(x, hierarchical_categories=()):
return (c if numeric_collation and c.isdigit() else '9999999999',
collation_order(v2), sort_key(v1))
+
def sort_key_for_name(x, hierarchical_categories=()):
v = x.sort or x.name
if x.category not in hierarchical_categories:
diff --git a/src/calibre/db/cli/cmd_catalog.py b/src/calibre/db/cli/cmd_catalog.py
index 5c6fa69568..0f01c23719 100644
--- a/src/calibre/db/cli/cmd_catalog.py
+++ b/src/calibre/db/cli/cmd_catalog.py
@@ -96,8 +96,6 @@ see the different options, specify the name of the output file and then the
add_plugin_parser_options(fmt, parser)
return parser
-
-
# }}}
diff --git a/src/calibre/db/constants.py b/src/calibre/db/constants.py
index a7d3f7beb8..2c5fccb3b0 100644
--- a/src/calibre/db/constants.py
+++ b/src/calibre/db/constants.py
@@ -16,6 +16,7 @@ BOOK_ID_PATH_TEMPLATE = ' ({})'
RESOURCE_URL_SCHEME = 'calres'
TEMPLATE_ICON_INDICATOR = ' template ' # Item values cannot start or end with space
+
@dataclass
class TrashEntry:
book_id: int
diff --git a/src/calibre/db/legacy.py b/src/calibre/db/legacy.py
index 5bf057b372..4a7161cdf5 100644
--- a/src/calibre/db/legacy.py
+++ b/src/calibre/db/legacy.py
@@ -164,7 +164,6 @@ class ThreadSafePrefs(MutableMapping):
class LibraryDatabase:
-
''' Emulate the old LibraryDatabase2 interface '''
PATH_LIMIT = DB.PATH_LIMIT
diff --git a/src/calibre/db/notes/connect.py b/src/calibre/db/notes/connect.py
index 2355d7c457..e5df66f2ef 100644
--- a/src/calibre/db/notes/connect.py
+++ b/src/calibre/db/notes/connect.py
@@ -25,6 +25,7 @@ from calibre.utils.icu import lower as icu_lower
if iswindows:
from calibre_extensions import winutil
+
class cmt(str):
pass
diff --git a/src/calibre/db/search.py b/src/calibre/db/search.py
index 35de3e02c8..fea68f7cac 100644
--- a/src/calibre/db/search.py
+++ b/src/calibre/db/search.py
@@ -28,8 +28,8 @@ EQUALS_MATCH = 1
REGEXP_MATCH = 2
ACCENT_MATCH = 3
-# Utils {{{
+# Utils {{{
def _matchkind(query, case_sensitive=False):
matchkind = CONTAINS_MATCH
diff --git a/src/calibre/db/tables.py b/src/calibre/db/tables.py
index eba46dd614..2cc83cb08a 100644
--- a/src/calibre/db/tables.py
+++ b/src/calibre/db/tables.py
@@ -20,6 +20,7 @@ from polyglot.builtins import iteritems, itervalues
def identity(x):
return x
+
def c_parse(val):
try:
year, month, day, hour, minutes, seconds, tzsecs = _c_speedup(val)
@@ -90,7 +91,6 @@ class Table:
class VirtualTable(Table):
-
'''
A dummy table used for fields that only exist in memory like ondevice
'''
@@ -102,7 +102,6 @@ class VirtualTable(Table):
class OneToOneTable(Table):
-
'''
Represents data that is unique per book (it may not actually be unique) but
each item is assigned to a book in a one-to-one mapping. For example: uuid,
@@ -197,7 +196,6 @@ class CompositeTable(OneToOneTable):
class ManyToOneTable(Table):
-
'''
Represents data where one data item can map to many books, for example:
series or publisher.
@@ -409,7 +407,6 @@ class RatingTable(ManyToOneTable):
class ManyToManyTable(ManyToOneTable):
-
'''
Represents data that has a many-to-many mapping with books. i.e. each book
can have more than one value and each value can be mapped to more than one
diff --git a/src/calibre/db/tests/__init__.py b/src/calibre/db/tests/__init__.py
index ad82601065..1f6b29ebfa 100644
--- a/src/calibre/db/tests/__init__.py
+++ b/src/calibre/db/tests/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/db/tests/filesystem.py b/src/calibre/db/tests/filesystem.py
index 3dc5bd5607..86e1178ec8 100644
--- a/src/calibre/db/tests/filesystem.py
+++ b/src/calibre/db/tests/filesystem.py
@@ -160,7 +160,6 @@ class FilesystemTest(BaseTest):
self.assertEqual(cache.rename_extra_files(1, {'B': 'data/c'}), set())
self.assertEqual(cache.rename_extra_files(1, {'B': 'data/c'}, replace=True), {'B'})
-
@unittest.skipUnless(iswindows, 'Windows only')
def test_windows_atomic_move(self):
'Test book file open in another process when changing metadata'
diff --git a/src/calibre/db/tests/legacy.py b/src/calibre/db/tests/legacy.py
index 9cb4ba13c0..c2e0ded3e0 100644
--- a/src/calibre/db/tests/legacy.py
+++ b/src/calibre/db/tests/legacy.py
@@ -78,7 +78,6 @@ def run_funcs(self, db, ndb, funcs):
class LegacyTest(BaseTest):
-
''' Test the emulation of the legacy interface. '''
def test_library_wide_properties(self): # {{{
diff --git a/src/calibre/db/tests/notes.py b/src/calibre/db/tests/notes.py
index 65bd5c0ae9..822a235505 100644
--- a/src/calibre/db/tests/notes.py
+++ b/src/calibre/db/tests/notes.py
@@ -22,6 +22,7 @@ def test_notes_restore(self: 'NotesTest'):
doc2 = 'simple notes for an author2'
cache.set_notes_for('authors', authors[1], doc2, resource_hashes=(h2,))
+
def test_notes_api(self: 'NotesTest'):
cache, notes = self.create_notes_db()
authors = sorted(cache.all_field_ids('authors'))
@@ -81,6 +82,7 @@ def test_notes_api(self: 'NotesTest'):
cache.set_notes_for('authors', authors[0], '', resource_hashes=())
self.ae(len(os.listdir(notes.retired_dir)), 1)
+
def test_cache_api(self: 'NotesTest'):
cache, notes = self.create_notes_db()
authors = cache.field_for('authors', 1)
diff --git a/src/calibre/db/tests/reading.py b/src/calibre/db/tests/reading.py
index cbdb53eb2b..b9c099be42 100644
--- a/src/calibre/db/tests/reading.py
+++ b/src/calibre/db/tests/reading.py
@@ -712,7 +712,6 @@ class ReadingTest(BaseTest):
self.assertRaises(NotImplementedError, pmi.template_to_attribute, {}, {})
self.assertRaises(NotImplementedError, pmi.smart_update, {})
-
# }}}
def test_marked_field(self): # {{{
diff --git a/src/calibre/db/tests/writing.py b/src/calibre/db/tests/writing.py
index cdb33cbb39..801dc67377 100644
--- a/src/calibre/db/tests/writing.py
+++ b/src/calibre/db/tests/writing.py
@@ -920,7 +920,6 @@ class WritingTest(BaseTest):
cache.restore_annotations(1, list(opf.read_annotations()))
amap = cache.annotations_map_for_book(1, 'moo')
self.assertEqual([x[0] for x in annot_list], map_as_list(amap))
-
# }}}
def test_changed_events(self): # {{{
@@ -1043,7 +1042,6 @@ class WritingTest(BaseTest):
self.assertDictEqual({'publisher': {'random': 'url2'}, 'tags': {'foobar': 'url'}},
mi.link_maps, "ProxyMetadata didn't return the right link map")
-
# Now test deleting the links.
links = cache.get_link_map('tags')
to_del = {l:'' for l in links.keys()}
@@ -1054,6 +1052,4 @@ class WritingTest(BaseTest):
cache.set_link_map('publisher', to_del)
self.assertEqual({}, cache.get_link_map('publisher'), 'links on publisher were not deleted')
self.assertEqual({}, cache.get_all_link_maps_for_book(1), 'Not all links for book were deleted')
-
-
# }}}
diff --git a/src/calibre/db/utils.py b/src/calibre/db/utils.py
index 1442253ebf..16fbcc45c1 100644
--- a/src/calibre/db/utils.py
+++ b/src/calibre/db/utils.py
@@ -107,7 +107,6 @@ class CacheError(Exception):
class ThumbnailCache:
-
' This is a persistent disk cache to speed up loading and resizing of covers '
def __init__(self,
diff --git a/src/calibre/db/view.py b/src/calibre/db/view.py
index a97cf93e6e..ade2131ecf 100644
--- a/src/calibre/db/view.py
+++ b/src/calibre/db/view.py
@@ -99,7 +99,6 @@ def format_identifiers(x):
class View:
-
''' A table view of the database, with rows and columns. Also supports
filtering and sorting. '''
diff --git a/src/calibre/db/write.py b/src/calibre/db/write.py
index e8cdf88142..236500cd82 100644
--- a/src/calibre/db/write.py
+++ b/src/calibre/db/write.py
@@ -19,8 +19,8 @@ from polyglot.builtins import iteritems, itervalues
missing = object()
-# Convert data into values suitable for the db {{{
+# Convert data into values suitable for the db {{{
def sqlite_datetime(x):
return isoformat(x, sep=' ') if isinstance(x, datetime) else x
@@ -190,8 +190,8 @@ def get_adapter(name, metadata):
return ans
# }}}
-# One-One fields {{{
+# One-One fields {{{
def one_one_in_books(book_id_val_map, db, field, *args):
'Set a one-one field in the books table'
@@ -265,8 +265,8 @@ def custom_series_index(book_id_val_map, db, field, *args):
return {s[1] for s in sequence}
# }}}
-# Many-One fields {{{
+# Many-One fields {{{
def safe_lower(x):
try:
@@ -392,8 +392,8 @@ def many_one(book_id_val_map, db, field, allow_case_change, *args):
return dirtied
# }}}
-# Many-Many fields {{{
+# Many-Many fields {{{
def uniq(vals, kmap=lambda x:x):
''' Remove all duplicates from vals, while preserving order. kmap must be a
diff --git a/src/calibre/devices/jetbook/driver.py b/src/calibre/devices/jetbook/driver.py
index 837a5ab419..499ce3ed50 100644
--- a/src/calibre/devices/jetbook/driver.py
+++ b/src/calibre/devices/jetbook/driver.py
@@ -99,7 +99,6 @@ class MIBUK(USBMS):
class JETBOOK_MINI(USBMS):
-
'''
['0x4b8',
'0x507',
@@ -126,7 +125,6 @@ class JETBOOK_MINI(USBMS):
class JETBOOK_COLOR(USBMS):
-
'''
set([('0x951',
'0x160b',
diff --git a/src/calibre/devices/kindle/apnx_page_generator/pages.py b/src/calibre/devices/kindle/apnx_page_generator/pages.py
index aa8e1ea51b..bd74568dce 100644
--- a/src/calibre/devices/kindle/apnx_page_generator/pages.py
+++ b/src/calibre/devices/kindle/apnx_page_generator/pages.py
@@ -39,5 +39,3 @@ class Pages:
@property
def number_of_pages(self) -> int:
return sum(len(pg.page_locations) for pg in self.__pages_groups)
-
-
diff --git a/src/calibre/devices/kobo/bookmark.py b/src/calibre/devices/kobo/bookmark.py
index 554740627b..bf0e569416 100644
--- a/src/calibre/devices/kobo/bookmark.py
+++ b/src/calibre/devices/kobo/bookmark.py
@@ -185,5 +185,4 @@ class Bookmark: # {{{
return ans
-
# }}}
diff --git a/src/calibre/devices/mtp/__init__.py b/src/calibre/devices/mtp/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/devices/mtp/__init__.py
+++ b/src/calibre/devices/mtp/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/devices/mtp/filesystem_cache.py b/src/calibre/devices/mtp/filesystem_cache.py
index 22d9331983..253bf4971c 100644
--- a/src/calibre/devices/mtp/filesystem_cache.py
+++ b/src/calibre/devices/mtp/filesystem_cache.py
@@ -22,6 +22,7 @@ from calibre.utils.icu import lower, sort_key
bexts = frozenset(BOOK_EXTENSIONS) - {'mbp', 'tan', 'rar', 'zip', 'xml'}
+
def convert_timestamp(md):
try:
if isinstance(md, tuple):
diff --git a/src/calibre/devices/mtp/unix/__init__.py b/src/calibre/devices/mtp/unix/__init__.py
index a2ec8c43b0..ad672c4ee0 100644
--- a/src/calibre/devices/mtp/unix/__init__.py
+++ b/src/calibre/devices/mtp/unix/__init__.py
@@ -9,4 +9,3 @@ __docformat__ = 'restructuredtext en'
'''
libmtp based drivers for MTP devices on Unix like platforms.
'''
-
diff --git a/src/calibre/devices/mtp/windows/__init__.py b/src/calibre/devices/mtp/windows/__init__.py
index fba7748a38..c555cf1377 100644
--- a/src/calibre/devices/mtp/windows/__init__.py
+++ b/src/calibre/devices/mtp/windows/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/devices/usbms/device.py b/src/calibre/devices/usbms/device.py
index 685dd6a2a3..fc98ab20e1 100644
--- a/src/calibre/devices/usbms/device.py
+++ b/src/calibre/devices/usbms/device.py
@@ -73,7 +73,6 @@ class USBDevice:
class Device(DeviceConfig, DevicePlugin):
-
'''
This class provides logic common to all drivers for devices that export themselves
as USB Mass Storage devices. Provides implementations for mounting/ejecting
diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py
index 1dba28aa3b..88562bd864 100644
--- a/src/calibre/devices/usbms/driver.py
+++ b/src/calibre/devices/usbms/driver.py
@@ -67,7 +67,6 @@ def safe_walk(top, topdown=True, onerror=None, followlinks=False, maxdepth=128):
# CLI must come before Device as it implements the CLI functions that
# are inherited from the device interface in Device.
class USBMS(CLI, Device):
-
'''
The base class for all USBMS devices. Implements the logic for
sending/getting/updating metadata/caching metadata/etc.
diff --git a/src/calibre/devices/winusb.py b/src/calibre/devices/winusb.py
index 406548878c..d8c63577ba 100644
--- a/src/calibre/devices/winusb.py
+++ b/src/calibre/devices/winusb.py
@@ -44,7 +44,6 @@ except ImportError:
# Data and function type definitions {{{
-
class GUID(Structure):
_fields_ = [
('data1', DWORD),
@@ -701,8 +700,8 @@ def get_volume_pathnames(volume_id, buf=None):
# }}}
-# def scan_usb_devices(): {{{
+# def scan_usb_devices(): {{{
_USBDevice = namedtuple('USBDevice', 'vendor_id product_id bcd devid devinst')
diff --git a/src/calibre/ebooks/conversion/plugins/__init__.py b/src/calibre/ebooks/conversion/plugins/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/ebooks/conversion/plugins/__init__.py
+++ b/src/calibre/ebooks/conversion/plugins/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/conversion/plumber.py b/src/calibre/ebooks/conversion/plumber.py
index 9f9699724c..b7c562509c 100644
--- a/src/calibre/ebooks/conversion/plumber.py
+++ b/src/calibre/ebooks/conversion/plumber.py
@@ -78,7 +78,6 @@ ARCHIVE_FMTS = ('zip', 'rar', 'oebzip')
class Plumber:
-
'''
The `Plumber` manages the conversion pipeline. An UI should call the methods
:method:`merge_ui_recommendations` and then :method:`run`. The plumber will
diff --git a/src/calibre/ebooks/covers.py b/src/calibre/ebooks/covers.py
index b9ef909a83..6b8bbc9240 100644
--- a/src/calibre/ebooks/covers.py
+++ b/src/calibre/ebooks/covers.py
@@ -246,8 +246,8 @@ def layout_text(prefs, img, title, subtitle, footer, max_height, style):
# }}}
-# Format text using templates {{{
+# Format text using templates {{{
def sanitize(s):
return unicodedata.normalize('NFC', clean_xml_chars(clean_ascii_chars(force_unicode(s or ''))))
@@ -355,8 +355,8 @@ def color(color_theme, name):
# }}}
-# Styles {{{
+# Styles {{{
class Style:
diff --git a/src/calibre/ebooks/djvu/__init__.py b/src/calibre/ebooks/djvu/__init__.py
index 1d58fcfdd7..9280f81b7d 100644
--- a/src/calibre/ebooks/djvu/__init__.py
+++ b/src/calibre/ebooks/djvu/__init__.py
@@ -8,4 +8,3 @@ __docformat__ = 'restructuredtext en'
'''
Used for DJVU input
'''
-
diff --git a/src/calibre/ebooks/djvu/djvubzzdec.py b/src/calibre/ebooks/djvu/djvubzzdec.py
index b1c8ede695..f850094fe4 100644
--- a/src/calibre/ebooks/djvu/djvubzzdec.py
+++ b/src/calibre/ebooks/djvu/djvubzzdec.py
@@ -78,7 +78,6 @@ MAXLEN = 1024 ** 2
class BZZDecoderError(Exception):
-
'''This exception is raised when BZZDecode runs into trouble
'''
diff --git a/src/calibre/ebooks/docx/__init__.py b/src/calibre/ebooks/docx/__init__.py
index fd10297f12..fc5e470722 100644
--- a/src/calibre/ebooks/docx/__init__.py
+++ b/src/calibre/ebooks/docx/__init__.py
@@ -7,4 +7,3 @@ __copyright__ = '2013, Kovid Goyal '
class InvalidDOCX(ValueError):
pass
-
diff --git a/src/calibre/ebooks/docx/container.py b/src/calibre/ebooks/docx/container.py
index bdea8cdb25..b7157d9749 100644
--- a/src/calibre/ebooks/docx/container.py
+++ b/src/calibre/ebooks/docx/container.py
@@ -25,8 +25,8 @@ from calibre.utils.zipfile import ZipFile
def fromstring(raw, parser=None):
return safe_xml_fromstring(raw)
-# Read metadata {{{
+# Read metadata {{{
def read_doc_props(raw, mi, XPath):
root = fromstring(raw)
diff --git a/src/calibre/ebooks/docx/settings.py b/src/calibre/ebooks/docx/settings.py
index d0a6823947..5276e7b517 100644
--- a/src/calibre/ebooks/docx/settings.py
+++ b/src/calibre/ebooks/docx/settings.py
@@ -17,4 +17,3 @@ class Settings:
self.default_tab_stop = int(self.namespace.get(dts, 'w:val')) / 20
except (ValueError, TypeError, AttributeError):
pass
-
diff --git a/src/calibre/ebooks/docx/styles.py b/src/calibre/ebooks/docx/styles.py
index fe48b380a7..35a14052af 100644
--- a/src/calibre/ebooks/docx/styles.py
+++ b/src/calibre/ebooks/docx/styles.py
@@ -14,7 +14,6 @@ from polyglot.builtins import iteritems, itervalues
class PageProperties:
-
'''
Class representing page level properties (page size/margins) read from
sectPr elements.
@@ -104,7 +103,6 @@ class Style:
class Styles:
-
'''
Collection of all styles defined in the document. Used to get the final styles applicable to elements in the document markup.
'''
diff --git a/src/calibre/ebooks/docx/writer/__init__.py b/src/calibre/ebooks/docx/writer/__init__.py
index 0cbf055ec8..fb2e4b74e1 100644
--- a/src/calibre/ebooks/docx/writer/__init__.py
+++ b/src/calibre/ebooks/docx/writer/__init__.py
@@ -3,6 +3,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-
-
-
diff --git a/src/calibre/ebooks/docx/writer/styles.py b/src/calibre/ebooks/docx/writer/styles.py
index 73f85d49eb..cfea03317f 100644
--- a/src/calibre/ebooks/docx/writer/styles.py
+++ b/src/calibre/ebooks/docx/writer/styles.py
@@ -199,6 +199,7 @@ LINE_STYLES = {
'outset': 'outset',
}
+
def convert_underline(items):
style = 'solid'
has_underline = False
diff --git a/src/calibre/ebooks/docx/writer/utils.py b/src/calibre/ebooks/docx/writer/utils.py
index e0ff6d9f66..1f7d5f6817 100644
--- a/src/calibre/ebooks/docx/writer/utils.py
+++ b/src/calibre/ebooks/docx/writer/utils.py
@@ -13,8 +13,8 @@ def int_or_zero(raw):
except (ValueError, TypeError, AttributeError):
return 0
-# convert_color() {{{
+# convert_color() {{{
def convert_color(value):
if not value:
diff --git a/src/calibre/ebooks/epub/cfi/parse.py b/src/calibre/ebooks/epub/cfi/parse.py
index a3fd308e1e..c43bb3775b 100644
--- a/src/calibre/ebooks/epub/cfi/parse.py
+++ b/src/calibre/ebooks/epub/cfi/parse.py
@@ -8,7 +8,6 @@ import regex
class Parser:
-
''' See epubcfi.ebnf for the specification that this parser tries to
follow. I have implemented it manually, since I dont want to depend on
grako, and the grammar is pretty simple. This parser is thread-safe, i.e.
diff --git a/src/calibre/ebooks/html/input.py b/src/calibre/ebooks/html/input.py
index c739fac934..0e9b9496bb 100644
--- a/src/calibre/ebooks/html/input.py
+++ b/src/calibre/ebooks/html/input.py
@@ -24,7 +24,6 @@ from polyglot.urllib import urlparse, urlunparse
class Link:
-
'''
Represents a link in a HTML file.
'''
@@ -79,7 +78,6 @@ class IgnoreFile(Exception):
class HTMLFile:
-
'''
Contains basic information about an HTML file. This
includes a list of links to other files as well as
diff --git a/src/calibre/ebooks/metadata/__init__.py b/src/calibre/ebooks/metadata/__init__.py
index 5631f8e978..93e022cb22 100644
--- a/src/calibre/ebooks/metadata/__init__.py
+++ b/src/calibre/ebooks/metadata/__init__.py
@@ -259,7 +259,6 @@ def fmt_sidx(i, fmt='%.2f', use_roman=False):
class Resource:
-
'''
Represents a resource (usually a file on the filesystem or a URL pointing
to the web. Such resources are commonly referred to in OPF files.
diff --git a/src/calibre/ebooks/metadata/archive.py b/src/calibre/ebooks/metadata/archive.py
index 301d611894..af64b240d7 100644
--- a/src/calibre/ebooks/metadata/archive.py
+++ b/src/calibre/ebooks/metadata/archive.py
@@ -60,6 +60,7 @@ class KPFExtract(FileTypePlugin):
of.write(zf.read(candidates[0]))
return of.name
+
class RAR:
def __init__(self, archive):
diff --git a/src/calibre/ebooks/metadata/book/base.py b/src/calibre/ebooks/metadata/book/base.py
index b3f67c535e..1788559fd7 100644
--- a/src/calibre/ebooks/metadata/book/base.py
+++ b/src/calibre/ebooks/metadata/book/base.py
@@ -65,7 +65,6 @@ def cv(val):
class Metadata:
-
'''
A class representing all the metadata for a book. The various standard metadata
fields are available as attributes of this object. You can also stick
diff --git a/src/calibre/ebooks/metadata/epub.py b/src/calibre/ebooks/metadata/epub.py
index 872f72bcd2..5f0a89f153 100644
--- a/src/calibre/ebooks/metadata/epub.py
+++ b/src/calibre/ebooks/metadata/epub.py
@@ -140,7 +140,6 @@ class OCFReader(OCF):
return False
-
class OCFZipReader(OCFReader):
def __init__(self, stream, mode='r', root=None):
diff --git a/src/calibre/ebooks/metadata/kfx.py b/src/calibre/ebooks/metadata/kfx.py
index d9f900cead..654d70f3b9 100644
--- a/src/calibre/ebooks/metadata/kfx.py
+++ b/src/calibre/ebooks/metadata/kfx.py
@@ -69,7 +69,6 @@ def hexs(string, sep=' '):
class PackedData:
-
'''
Simplify unpacking of packed binary data structures
'''
@@ -101,7 +100,6 @@ class PackedData:
class PackedBlock(PackedData):
-
'''
Common header structure of container and entity blocks
'''
@@ -119,7 +117,6 @@ class PackedBlock(PackedData):
class Container(PackedBlock):
-
'''
Container file containing data entities
'''
@@ -143,7 +140,6 @@ class Container(PackedBlock):
class Entity(PackedBlock):
-
'''
Data entity inside a container
'''
@@ -164,7 +160,6 @@ class Entity(PackedBlock):
class PackedIon(PackedData):
-
'''
Packed structured binary data format used by KFX
'''
diff --git a/src/calibre/ebooks/metadata/opf2.py b/src/calibre/ebooks/metadata/opf2.py
index 4516fbcae8..7ffe52b44d 100644
--- a/src/calibre/ebooks/metadata/opf2.py
+++ b/src/calibre/ebooks/metadata/opf2.py
@@ -566,6 +566,7 @@ def dump_dict(cats):
return json.dumps(object_to_unicode(cats), ensure_ascii=False,
skipkeys=True)
+
XPATH_NS = {
'dc': 'http://purl.org/dc/elements/1.1/',
'opf': 'http://www.idpf.org/2007/opf',
diff --git a/src/calibre/ebooks/metadata/opf3.py b/src/calibre/ebooks/metadata/opf3.py
index d095981b3e..1669932fbe 100644
--- a/src/calibre/ebooks/metadata/opf3.py
+++ b/src/calibre/ebooks/metadata/opf3.py
@@ -191,8 +191,8 @@ def ensure_prefix(root, prefixes, prefix, value=None):
# }}}
-# Refines {{{
+# Refines {{{
def read_refines(root):
ans = defaultdict(list)
@@ -221,8 +221,8 @@ def set_refines(elem, existing_refines, *new_refines):
p.insert(p.index(elem)+1, r)
# }}}
-# Identifiers {{{
+# Identifiers {{{
def parse_identifier(ident, val, refines):
idid = ident.get('id')
@@ -330,8 +330,8 @@ set_uuid = identifier_writer('uuid')
# }}}
-# Title {{{
+# Title {{{
def find_main_title(root, refines, remove_blanks=False):
first_title = main_title = None
@@ -404,8 +404,8 @@ def set_title(root, prefixes, refines, title, title_sort=None):
# }}}
-# Languages {{{
+# Languages {{{
def read_languages(root, prefixes, refines):
ans = []
@@ -434,8 +434,8 @@ def set_languages(root, prefixes, refines, languages):
metadata.append(l)
# }}}
-# Creator/Contributor {{{
+# Creator/Contributor {{{
Author = namedtuple('Author', 'name sort seq', defaults=(0,))
@@ -558,8 +558,8 @@ def set_book_producers(root, prefixes, refines, producers):
metadata.append(m)
# }}}
-# Dates {{{
+# Dates {{{
def parse_date(raw, is_w3cdtf=False):
raw = raw.strip()
@@ -668,8 +668,8 @@ def set_last_modified(root, prefixes, refines, val=None):
meta.text = val
# }}}
-# Comments {{{
+# Comments {{{
def read_comments(root, prefixes, refines):
ans = ''
@@ -691,8 +691,8 @@ def set_comments(root, prefixes, refines, val):
m.append(c)
# }}}
-# Publisher {{{
+# Publisher {{{
@simple_text
def read_publisher(root, prefixes, refines):
@@ -713,8 +713,8 @@ def set_publisher(root, prefixes, refines, val):
m.append(c)
# }}}
-# Tags {{{
+# Tags {{{
def read_tags(root, prefixes, refines):
ans = []
@@ -737,8 +737,8 @@ def set_tags(root, prefixes, refines, val):
m.append(c)
# }}}
-# Rating {{{
+# Rating {{{
def read_rating(root, prefixes, refines):
pq = '%s:rating' % CALIBRE_PREFIX
@@ -780,8 +780,8 @@ def set_rating(root, prefixes, refines, val):
create_rating(root, prefixes, '%.2g' % float(val))
# }}}
-# Series {{{
+# Series {{{
def read_series(root, prefixes, refines):
series_index = 1.0
@@ -825,8 +825,8 @@ def set_series(root, prefixes, refines, series, series_index):
create_series(root, refines, series, fmt_sidx(series_index))
# }}}
-# User metadata {{{
+# User metadata {{{
def dict_reader(name, load=json.loads, try2=True):
pq = f'{CALIBRE_PREFIX}:{name}'
@@ -960,8 +960,8 @@ def set_user_metadata(root, prefixes, refines, val):
# }}}
-# Covers {{{
+# Covers {{{
def read_raster_cover(root, prefixes, refines):
@@ -1008,8 +1008,8 @@ def ensure_is_only_raster_cover(root, prefixes, refines, raster_cover_item_href)
# }}}
-# Reading/setting Metadata objects {{{
+# Reading/setting Metadata objects {{{
def first_spine_item(root, prefixes, refines):
for i in XPath('./opf:spine/opf:itemref/@idref')(root):
diff --git a/src/calibre/ebooks/metadata/opf3_test.py b/src/calibre/ebooks/metadata/opf3_test.py
index ba7f97f419..0dc9e84c79 100644
--- a/src/calibre/ebooks/metadata/opf3_test.py
+++ b/src/calibre/ebooks/metadata/opf3_test.py
@@ -587,8 +587,8 @@ class TestOPF3(unittest.TestCase):
self.ae('xxx/cover.jpg', apply_metadata(root, mi3, cover_data=b'x', cover_prefix='xxx'))
# }}}
-# Run tests {{{
+# Run tests {{{
def suite():
return unittest.TestLoader().loadTestsFromTestCase(TestOPF3)
diff --git a/src/calibre/ebooks/metadata/sources/base.py b/src/calibre/ebooks/metadata/sources/base.py
index 84d6ca522a..cc9b16f789 100644
--- a/src/calibre/ebooks/metadata/sources/base.py
+++ b/src/calibre/ebooks/metadata/sources/base.py
@@ -44,7 +44,6 @@ def cleanup_title(s):
@total_ordering
class InternalMetadataCompareKeyGen:
-
'''
Generate a sort key for comparison of the relevance of Metadata objects,
given a search query. This is used only to compare results from the same
diff --git a/src/calibre/ebooks/metadata/sources/google.py b/src/calibre/ebooks/metadata/sources/google.py
index 5dee08e26b..99238ca487 100644
--- a/src/calibre/ebooks/metadata/sources/google.py
+++ b/src/calibre/ebooks/metadata/sources/google.py
@@ -60,10 +60,9 @@ def get_details(browser, url, timeout): # {{{
raw = browser.open_novisit(url, timeout=timeout).read()
return raw
-
-
# }}}
+
xpath_cache = {}
@@ -197,7 +196,6 @@ def to_metadata(browser, log, entry_, timeout, running_a_test=False): # {{{
return mi
-
# }}}
diff --git a/src/calibre/ebooks/metadata/sources/google_images.py b/src/calibre/ebooks/metadata/sources/google_images.py
index ef3c2397ff..6532fbfa02 100644
--- a/src/calibre/ebooks/metadata/sources/google_images.py
+++ b/src/calibre/ebooks/metadata/sources/google_images.py
@@ -58,7 +58,6 @@ def parse_google_markup(raw):
return list(ans)
-
class GoogleImages(Source):
name = 'Google Images'
diff --git a/src/calibre/ebooks/metadata/sources/identify.py b/src/calibre/ebooks/metadata/sources/identify.py
index f69eaa4454..4d0fceb43f 100644
--- a/src/calibre/ebooks/metadata/sources/identify.py
+++ b/src/calibre/ebooks/metadata/sources/identify.py
@@ -62,8 +62,8 @@ def is_worker_alive(workers):
# }}}
-# Merge results from different sources {{{
+# Merge results from different sources {{{
class xISBN(Thread):
diff --git a/src/calibre/ebooks/metadata/sources/search_engines.py b/src/calibre/ebooks/metadata/sources/search_engines.py
index 567eca4453..7e831f2311 100644
--- a/src/calibre/ebooks/metadata/sources/search_engines.py
+++ b/src/calibre/ebooks/metadata/sources/search_engines.py
@@ -118,7 +118,6 @@ def quote_term(x):
# DDG + Wayback machine {{{
-
def ddg_url_processor(url):
return url
@@ -207,8 +206,8 @@ def ddg_develop():
print()
# }}}
-# Bing {{{
+# Bing {{{
def bing_term(t):
t = t.replace('"', '')
@@ -278,8 +277,8 @@ def bing_develop(terms='heroes abercrombie'):
print()
# }}}
-# Google {{{
+# Google {{{
def google_term(t):
t = t.replace('"', '')
diff --git a/src/calibre/ebooks/metadata/sources/test.py b/src/calibre/ebooks/metadata/sources/test.py
index b6cea338a5..775d637de3 100644
--- a/src/calibre/ebooks/metadata/sources/test.py
+++ b/src/calibre/ebooks/metadata/sources/test.py
@@ -204,7 +204,6 @@ def test_identify(tests): # {{{
log('\n\n')
prints('Average time per query', sum(times)/len(times))
-
# }}}
diff --git a/src/calibre/ebooks/metadata/xisbn.py b/src/calibre/ebooks/metadata/xisbn.py
index 571e318fa0..732efdc47c 100644
--- a/src/calibre/ebooks/metadata/xisbn.py
+++ b/src/calibre/ebooks/metadata/xisbn.py
@@ -13,7 +13,6 @@ from calibre import browser
class xISBN:
-
'''
This class is used to find the ISBN numbers of "related" editions of a
book, given its ISBN. Useful when querying services for metadata by ISBN,
diff --git a/src/calibre/ebooks/mobi/debug/__init__.py b/src/calibre/ebooks/mobi/debug/__init__.py
index 65b1c31f65..673178a74e 100644
--- a/src/calibre/ebooks/mobi/debug/__init__.py
+++ b/src/calibre/ebooks/mobi/debug/__init__.py
@@ -10,5 +10,3 @@ def format_bytes(byts):
byts = bytearray(byts)
byts = [hex(b)[2:] for b in byts]
return ' '.join(byts)
-
-
diff --git a/src/calibre/ebooks/mobi/debug/headers.py b/src/calibre/ebooks/mobi/debug/headers.py
index 392687c62d..701fc389ee 100644
--- a/src/calibre/ebooks/mobi/debug/headers.py
+++ b/src/calibre/ebooks/mobi/debug/headers.py
@@ -123,8 +123,8 @@ class Record: # {{{
self.uid, self.raw[:4], len(self.raw))
# }}}
-# EXTH {{{
+# EXTH {{{
class EXTHRecord:
diff --git a/src/calibre/ebooks/mobi/debug/mobi6.py b/src/calibre/ebooks/mobi/debug/mobi6.py
index d2fb14e058..5db395e366 100644
--- a/src/calibre/ebooks/mobi/debug/mobi6.py
+++ b/src/calibre/ebooks/mobi/debug/mobi6.py
@@ -475,9 +475,9 @@ class CNCX: # {{{
ans.append('%10d : %s'%(k, v))
return '\n'.join(ans)
-
# }}}
+
class ImageRecord: # {{{
def __init__(self, idx, record, fmt):
@@ -844,5 +844,4 @@ def inspect_mobi(mobi_file, ddir):
for rec in getattr(f, attr):
rec.dump(tdir)
-
# }}}
diff --git a/src/calibre/ebooks/mobi/reader/__init__.py b/src/calibre/ebooks/mobi/reader/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/ebooks/mobi/reader/__init__.py
+++ b/src/calibre/ebooks/mobi/reader/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/mobi/reader/containers.py b/src/calibre/ebooks/mobi/reader/containers.py
index 5d367cd823..ab964ed5a2 100644
--- a/src/calibre/ebooks/mobi/reader/containers.py
+++ b/src/calibre/ebooks/mobi/reader/containers.py
@@ -44,5 +44,3 @@ class Container:
if imgtype != 'unknown':
return data, imgtype
return None, None
-
-
diff --git a/src/calibre/ebooks/mobi/reader/mobi8.py b/src/calibre/ebooks/mobi/reader/mobi8.py
index 8223fcbe74..eef3871d0a 100644
--- a/src/calibre/ebooks/mobi/reader/mobi8.py
+++ b/src/calibre/ebooks/mobi/reader/mobi8.py
@@ -37,8 +37,8 @@ Elem = namedtuple('Elem',
FlowInfo = namedtuple('FlowInfo',
'type format dir fname')
-# locate beginning and ending positions of tag with specific aid attribute
+# locate beginning and ending positions of tag with specific aid attribute
def locate_beg_end_of_tag(ml, aid):
pattern = br'''<[^>]*\said\s*=\s*['"]%s['"][^>]*>''' % aid
diff --git a/src/calibre/ebooks/mobi/utils.py b/src/calibre/ebooks/mobi/utils.py
index c4f9dc3b10..09c971beb2 100644
--- a/src/calibre/ebooks/mobi/utils.py
+++ b/src/calibre/ebooks/mobi/utils.py
@@ -424,8 +424,8 @@ def mobify_image(data):
data = png_data_to_gif_data(data)
return data
-# Font records {{{
+# Font records {{{
def read_font_record(data, extent=1040):
'''
diff --git a/src/calibre/ebooks/mobi/writer2/__init__.py b/src/calibre/ebooks/mobi/writer2/__init__.py
index ee0e098f16..b36984a9ba 100644
--- a/src/calibre/ebooks/mobi/writer2/__init__.py
+++ b/src/calibre/ebooks/mobi/writer2/__init__.py
@@ -10,4 +10,3 @@ UNCOMPRESSED = 1
PALMDOC = 2
HUFFDIC = 17480
PALM_MAX_IMAGE_SIZE = 63 * 1024
-
diff --git a/src/calibre/ebooks/mobi/writer2/indexer.py b/src/calibre/ebooks/mobi/writer2/indexer.py
index 841ea8ca86..2cc7bc99df 100644
--- a/src/calibre/ebooks/mobi/writer2/indexer.py
+++ b/src/calibre/ebooks/mobi/writer2/indexer.py
@@ -86,9 +86,9 @@ class TAGX: # {{{
self.add_tag(i)
return self.header(1) + bytes(self.byts)
-
# }}}
+
# Index Entries {{{
class IndexEntry:
diff --git a/src/calibre/ebooks/mobi/writer8/__init__.py b/src/calibre/ebooks/mobi/writer8/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/ebooks/mobi/writer8/__init__.py
+++ b/src/calibre/ebooks/mobi/writer8/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/mobi/writer8/header.py b/src/calibre/ebooks/mobi/writer8/header.py
index 839445128e..5eb07960a5 100644
--- a/src/calibre/ebooks/mobi/writer8/header.py
+++ b/src/calibre/ebooks/mobi/writer8/header.py
@@ -15,10 +15,16 @@ from calibre.ebooks.mobi.utils import align_block
from polyglot.builtins import as_bytes, iteritems
NULL = 0xffffffff
+
+
def zeroes(x):
return (b'\x00' * x)
+
+
def nulls(x):
return (b'\xff' * x)
+
+
def short(x):
return pack(b'>H', x)
diff --git a/src/calibre/ebooks/mobi/writer8/index.py b/src/calibre/ebooks/mobi/writer8/index.py
index 51b73d00e9..d18d543a24 100644
--- a/src/calibre/ebooks/mobi/writer8/index.py
+++ b/src/calibre/ebooks/mobi/writer8/index.py
@@ -11,10 +11,13 @@ from struct import pack
from calibre.ebooks.mobi.utils import CNCX, align_block, encint
from calibre.ebooks.mobi.writer8.header import Header
-TagMeta_ = namedtuple('TagMeta',
- 'name number values_per_entry bitmask end_flag')
+TagMeta_ = namedtuple('TagMeta', 'name number values_per_entry bitmask end_flag')
+
+
def TagMeta(x):
return TagMeta_(*x)
+
+
EndTagTable = TagMeta(('eof', 0, 0, 0, 1))
# map of mask to number of shifts needed, works with 1 bit and two-bit wide masks
@@ -296,7 +299,6 @@ class GuideIndex(Index):
class NCXIndex(Index):
-
''' The commented out parts have been seen in NCX indexes from MOBI 6
periodicals. Since we have no MOBI 8 periodicals to reverse engineer, leave
it for now. '''
diff --git a/src/calibre/ebooks/oeb/display/__init__.py b/src/calibre/ebooks/oeb/display/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/ebooks/oeb/display/__init__.py
+++ b/src/calibre/ebooks/oeb/display/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/oeb/polish/__init__.py b/src/calibre/ebooks/oeb/polish/__init__.py
index d91f720858..9c3d29d79e 100644
--- a/src/calibre/ebooks/oeb/polish/__init__.py
+++ b/src/calibre/ebooks/oeb/polish/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/oeb/polish/cascade.py b/src/calibre/ebooks/oeb/polish/cascade.py
index fb163e24f4..078fde148a 100644
--- a/src/calibre/ebooks/oeb/polish/cascade.py
+++ b/src/calibre/ebooks/oeb/polish/cascade.py
@@ -102,7 +102,6 @@ def iterdeclaration(decl):
class Values(tuple):
-
''' A tuple of `css_parser.css.Value ` (and its subclasses) objects. Also has a
`sheet_name` attribute that is the canonical name relative to which URLs
for this property should be resolved. '''
diff --git a/src/calibre/ebooks/oeb/polish/check/__init__.py b/src/calibre/ebooks/oeb/polish/check/__init__.py
index 0cbf055ec8..fb2e4b74e1 100644
--- a/src/calibre/ebooks/oeb/polish/check/__init__.py
+++ b/src/calibre/ebooks/oeb/polish/check/__init__.py
@@ -3,6 +3,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-
-
-
diff --git a/src/calibre/ebooks/oeb/polish/container.py b/src/calibre/ebooks/oeb/polish/container.py
index 3734ed1c21..e7142696f7 100644
--- a/src/calibre/ebooks/oeb/polish/container.py
+++ b/src/calibre/ebooks/oeb/polish/container.py
@@ -1129,8 +1129,8 @@ class Container(ContainerBase): # {{{
return '\n'.join(mismatches)
# }}}
-# EPUB {{{
+# EPUB {{{
class InvalidEpub(InvalidBook):
pass
@@ -1468,8 +1468,8 @@ class EpubContainer(Container):
# }}}
-# AZW3 {{{
+# AZW3 {{{
class InvalidMobi(InvalidBook):
pass
diff --git a/src/calibre/ebooks/oeb/polish/cover.py b/src/calibre/ebooks/oeb/polish/cover.py
index e250fccd8e..508343c234 100644
--- a/src/calibre/ebooks/oeb/polish/cover.py
+++ b/src/calibre/ebooks/oeb/polish/cover.py
@@ -105,10 +105,10 @@ def mark_as_cover(container, name):
else:
mark_as_cover_epub(container, name)
+
###############################################################################
# The delightful EPUB cover processing
-
def is_raster_image(media_type):
return media_type and media_type.lower() in {
'image/png', 'image/jpeg', 'image/jpg', 'image/gif'}
diff --git a/src/calibre/ebooks/oeb/polish/jacket.py b/src/calibre/ebooks/oeb/polish/jacket.py
index 272315b6cd..d2e87992c5 100644
--- a/src/calibre/ebooks/oeb/polish/jacket.py
+++ b/src/calibre/ebooks/oeb/polish/jacket.py
@@ -105,4 +105,3 @@ def add_or_replace_jacket(container):
container.insert_into_xml(container.opf_xpath('//opf:spine')[0], itemref,
index=index)
return found
-
diff --git a/src/calibre/ebooks/oeb/polish/opf.py b/src/calibre/ebooks/oeb/polish/opf.py
index f4448e2fda..f951c019a5 100644
--- a/src/calibre/ebooks/oeb/polish/opf.py
+++ b/src/calibre/ebooks/oeb/polish/opf.py
@@ -48,4 +48,3 @@ def set_guide_item(container, item_type, title, name, frag=None):
else:
container.remove_from_xml(m)
container.dirty(container.opf_name)
-
diff --git a/src/calibre/ebooks/oeb/polish/spell.py b/src/calibre/ebooks/oeb/polish/spell.py
index e52196487a..60debbe450 100644
--- a/src/calibre/ebooks/oeb/polish/spell.py
+++ b/src/calibre/ebooks/oeb/polish/spell.py
@@ -162,10 +162,10 @@ def count_chars_in_escaped_html(text, counter, file_name, node, attr, locale):
_opf_file_as = '{%s}file-as' % OPF_NAMESPACES['opf']
opf_spell_tags = {'title', 'creator', 'subject', 'description', 'publisher'}
+
# We can only use barename() for tag names and simple attribute checks so that
# this code matches up with the syntax highlighter base spell checking
-
def read_words_from_opf(root, words, file_name, book_locale):
for tag in root.iterdescendants('*'):
if barename(tag.tag) in opf_spell_tags:
diff --git a/src/calibre/ebooks/oeb/polish/tests/__init__.py b/src/calibre/ebooks/oeb/polish/tests/__init__.py
index 0cbf055ec8..fb2e4b74e1 100644
--- a/src/calibre/ebooks/oeb/polish/tests/__init__.py
+++ b/src/calibre/ebooks/oeb/polish/tests/__init__.py
@@ -3,6 +3,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-
-
-
diff --git a/src/calibre/ebooks/oeb/stylizer.py b/src/calibre/ebooks/oeb/stylizer.py
index 8edd64fece..162fe8f8b5 100644
--- a/src/calibre/ebooks/oeb/stylizer.py
+++ b/src/calibre/ebooks/oeb/stylizer.py
@@ -438,6 +438,7 @@ def is_only_number(x: str) -> bool:
except Exception:
return False
+
def is_svg_text_tag(x):
return getattr(x, 'tag', '') in svg_text_tags
diff --git a/src/calibre/ebooks/oeb/transforms/embed_fonts.py b/src/calibre/ebooks/oeb/transforms/embed_fonts.py
index 3cb1740cf4..5f6a743354 100644
--- a/src/calibre/ebooks/oeb/transforms/embed_fonts.py
+++ b/src/calibre/ebooks/oeb/transforms/embed_fonts.py
@@ -86,7 +86,6 @@ def used_font(style, embedded_fonts):
class EmbedFonts:
-
'''
Embed all referenced fonts, if found on system. Must be called after CSS flattening.
'''
diff --git a/src/calibre/ebooks/oeb/transforms/jacket.py b/src/calibre/ebooks/oeb/transforms/jacket.py
index ecc10f80b6..26cabb09d2 100644
--- a/src/calibre/ebooks/oeb/transforms/jacket.py
+++ b/src/calibre/ebooks/oeb/transforms/jacket.py
@@ -160,8 +160,8 @@ class Jacket(Base):
if opts.insert_metadata:
self.insert_metadata(metadata)
-# Render Jacket {{{
+# Render Jacket {{{
def get_rating(rating, rchar, e_rchar):
ans = ''
diff --git a/src/calibre/ebooks/oeb/transforms/page_margin.py b/src/calibre/ebooks/oeb/transforms/page_margin.py
index 804be2ce60..dea03502d0 100644
--- a/src/calibre/ebooks/oeb/transforms/page_margin.py
+++ b/src/calibre/ebooks/oeb/transforms/page_margin.py
@@ -40,7 +40,6 @@ class NegativeTextIndent(Exception):
class RemoveFakeMargins:
-
'''
Remove left and right margins from paragraph/divs if the same margin is specified
on almost all the elements at that level.
diff --git a/src/calibre/ebooks/oeb/transforms/rasterize.py b/src/calibre/ebooks/oeb/transforms/rasterize.py
index 3604dda111..b35a8f044f 100644
--- a/src/calibre/ebooks/oeb/transforms/rasterize.py
+++ b/src/calibre/ebooks/oeb/transforms/rasterize.py
@@ -22,6 +22,7 @@ from polyglot.urllib import urldefrag
IMAGE_TAGS = {XHTML('img'), XHTML('object')}
KEEP_ATTRS = {'class', 'style', 'width', 'height', 'align'}
+
def test_svg(): # {{{
TEST_PNG_DATA_URI='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAWJQTFRFAAAAAAAAAAAAAAAAAAAAAQEAAgIBAwIBBgQCBwUCCAYDCggECwkEDgsFDwwFEA0GHRcKHxkLIBkLIxwMJR0NJx8OKCAOKCAPKSAPMScSPTAWQTQXQzUYSjsaSjsbSzsbUD8dUUAdVEMeWkggW0ggW0ghW0khXUohYk4ja1Umb1gocVoocVopclspc1spdV0qd18reF8riW0xjXEzl3g2mns3nn04nn45n345oIA6ooE7o4I7pII7pIM7pYQ7p4U8qYY8rYo+s45Bxp1Hx55Hy6FJy6JJzaRJz6RKz6RLz6VL0qdL1KpM1apM1qtN16xN2KxN2K1O2a1O2q1O265P3K9P3bBQ3rBP37FP37FQ37JQ4rNR47VR5LVR7LxV7bxV7r1V7r5W8L9W8MBW8b9V8b9W8cBW8cBX8sBW8sBX8sFW8sFX88BX88FW88FX88FY88JX88JY9MFX9MJX9MJY9MNYSw0rOAAAAAR0Uk5T2+rr8giKtGMAAAFDSURBVDjLhdNFUwNBEIbhJWkkuLu7u5PgHtwWl0CGnW34aJLl/3OgUlRlGfKepqafmstUW1Yw8E9By6IMWVn/z7OsQOpYNrE0H4lEwuFwZHmyLnUb+AUzIiLMItDgrWIfKH3mnz4RA6PX/8Im8xuEgVfxxG33g+rVi9OT46OdPQ0kDgv8gCg3FMrLphkNyCD9BYiIqEErraP5ZrDGDrw2MoIhsPACGUH5g2gVqzWDKQ/gETKCZmHwbo4ZbHhJ1q1kBMMJCKbJCCof35V+qjCDOUCrMTKCFkc8vU5GENpW8NwmMxhVccYsGUHVvWKOFhlBySJicV6u7+7s6Ozq6anxgT44Lwy4jlKK4br96WDl09GA/gA4zp7gLh2MM3MS+EgCGl+iD9JB4cDZzbV9ZV/atn1+frvfaPhuX4HMq0cZsjKt/zfXXmDab9zjGwAAAABJRU5ErkJggg=='
return f'''
diff --git a/src/calibre/ebooks/oeb/transforms/rescale.py b/src/calibre/ebooks/oeb/transforms/rescale.py
index 78c9614979..422dca9526 100644
--- a/src/calibre/ebooks/oeb/transforms/rescale.py
+++ b/src/calibre/ebooks/oeb/transforms/rescale.py
@@ -9,7 +9,6 @@ from calibre import fit_image
class RescaleImages:
-
'Rescale all images to fit inside given screen size'
def __init__(self, check_colorspaces=False):
diff --git a/src/calibre/ebooks/oeb/transforms/subset.py b/src/calibre/ebooks/oeb/transforms/subset.py
index 01f1a1bd92..5531ba1141 100644
--- a/src/calibre/ebooks/oeb/transforms/subset.py
+++ b/src/calibre/ebooks/oeb/transforms/subset.py
@@ -123,7 +123,6 @@ def elem_style(style_rules, cls, inherited_style):
class SubsetFonts:
-
'''
Subset all embedded fonts. Must be run after CSS flattening, as it requires
CSS normalization and flattening to work.
diff --git a/src/calibre/ebooks/pdb/haodoo/__init__.py b/src/calibre/ebooks/pdb/haodoo/__init__.py
index c2a96b7708..3c0958cb29 100644
--- a/src/calibre/ebooks/pdb/haodoo/__init__.py
+++ b/src/calibre/ebooks/pdb/haodoo/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/pdf/html_writer.py b/src/calibre/ebooks/pdf/html_writer.py
index 43dc22df4d..2deb7d7c24 100644
--- a/src/calibre/ebooks/pdf/html_writer.py
+++ b/src/calibre/ebooks/pdf/html_writer.py
@@ -45,9 +45,10 @@ from calibre.utils.webengine import secure_webengine, send_reply, setup_profile
from polyglot.builtins import as_bytes, iteritems
from polyglot.urllib import urlparse
+# }}}
+
OK, KILL_SIGNAL = range(0, 2)
HANG_TIME = 60 # seconds
-# }}}
# Utils {{{
@@ -131,6 +132,7 @@ def fix_fullscreen_images(container):
svg.set('width', '100vw')
svg.set('height', '100vh')
container.dirty(file_name)
+
# }}}
@@ -480,6 +482,7 @@ def job_for_name(container, name, margins, page_layout):
new_margins = QMarginsF(*resolve_margins(margins, page_layout))
page_layout.setMargins(new_margins)
return index_file, page_layout, name
+
# }}}
@@ -515,6 +518,7 @@ def create_margin_files(container):
if margins:
margins = dict_to_margins(json.loads(margins))
yield MarginFile(name, margins)
+
# }}}
@@ -680,6 +684,7 @@ def fix_links(pdf_doc, anchor_locations, name_anchor_map, mark_links, log):
return loc.as_tuple
pdf_doc.alter_links(replace_link, mark_links)
+
# }}}
@@ -801,7 +806,6 @@ def add_pagenum_toc(root, toc, opts, page_number_display_map):
# Fonts {{{
-
def all_glyph_ids_in_w_arrays(arrays, as_set=False):
ans = set()
for w in arrays:
diff --git a/src/calibre/ebooks/pdf/image_writer.py b/src/calibre/ebooks/pdf/image_writer.py
index ceb2035b53..3809317c96 100644
--- a/src/calibre/ebooks/pdf/image_writer.py
+++ b/src/calibre/ebooks/pdf/image_writer.py
@@ -37,7 +37,6 @@ class PDFMetadata: # {{{
# Page layout {{{
-
def parse_pdf_page_size(spec, unit='inch', dpi=72.0):
width, sep, height = spec.lower().partition('x')
if height:
diff --git a/src/calibre/ebooks/pdf/reflow.py b/src/calibre/ebooks/pdf/reflow.py
index e31c19eb01..d0763bc76c 100644
--- a/src/calibre/ebooks/pdf/reflow.py
+++ b/src/calibre/ebooks/pdf/reflow.py
@@ -104,6 +104,7 @@ def adjacent_quotes(first_string, second_string):
or (last_char == '’' and first_char == '‘') \
or (last_char == '”' and first_char == '“'))
+
class Font:
def __init__(self, spec):
@@ -113,6 +114,7 @@ class Font:
self.color = spec.get('color')
self.family = spec.get('family')
+
class Element:
def __init__(self):
@@ -125,6 +127,7 @@ class Element:
def __hash__(self):
return hash(self.id)
+
class DocStats:
def __init__(self):
@@ -132,6 +135,7 @@ class DocStats:
= self.line_space = self.para_space = self.indent_min_odd = self.indent_min_even = 0
self.font_size = 0
+
class Image(Element):
def __init__(self, img, opts, log, idc):
@@ -389,6 +393,7 @@ class Text(Element):
f.write(self.to_html().encode('utf-8'))
f.write('\n')
+
class Paragraph(Text):
def __init__(self, text, font_map, opts, log, idc):
@@ -426,6 +431,7 @@ class Paragraph(Text):
f.write(self.to_html().encode('utf-8'))
f.write('\n')
+
class FontSizeStats(dict):
def __init__(self, stats):
@@ -437,6 +443,7 @@ class FontSizeStats(dict):
self.most_common_size, self.chars_at_most_common_size = sz, chars
self[sz] = chars/total
+
class Interval:
def __init__(self, left, right):
@@ -462,13 +469,13 @@ class Interval:
def __hash__(self):
return hash('(%f,%f)'%self.left, self.right)
+
class Column:
# A column contains an element if the element bulges out to
# the left or the right by at most HFUZZ*col width.
HFUZZ = 0.2
-
def __init__(self):
self.left = self.right = self.top = self.bottom = 0
self.width = self.height = 0
@@ -548,6 +555,7 @@ class Box(list):
ans.append('%s>'%self.tag)
return ans
+
class ImageBox(Box):
def __init__(self, img):
@@ -640,7 +648,6 @@ class Region:
idx)
col.add(elem)
-
def collect_stats(self):
for column in self.columns:
column.collect_stats()
@@ -724,7 +731,6 @@ class Region:
self.boxes[-1].append(elem)
-
class Page:
def __init__(self, page, font_map, opts, log, idc):
@@ -1351,7 +1357,6 @@ class Page:
region.collect_stats()
region.linearize()
-
def to_html(self):
# If ans.append is used, newlines are inserted between each element
ans = []
@@ -1422,6 +1427,7 @@ class Page:
return ans
+
class PDFDocument:
def __init__(self, xml, opts, log):
@@ -2070,7 +2076,6 @@ class PDFDocument:
last_block = block
last_region = region
-
def render(self):
#### Where does the title come from if not run from command line?
title = 'Converted Ebook'
diff --git a/src/calibre/ebooks/pdf/render/__init__.py b/src/calibre/ebooks/pdf/render/__init__.py
index fba7748a38..c555cf1377 100644
--- a/src/calibre/ebooks/pdf/render/__init__.py
+++ b/src/calibre/ebooks/pdf/render/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/ebooks/unihandecode/jadecoder.py b/src/calibre/ebooks/unihandecode/jadecoder.py
index ed1e05798e..16a31fcda6 100644
--- a/src/calibre/ebooks/unihandecode/jadecoder.py
+++ b/src/calibre/ebooks/unihandecode/jadecoder.py
@@ -50,16 +50,19 @@ def itaiji_init(self):
if self._itaijidict is None:
self._itaijidict = pickle.loads(dictdata(Configurations.jisyo_itaiji))
+
def kanwa_init(self):
if self._jisyo_table is None:
with self._lock:
if self._jisyo_table is None:
self._jisyo_table = pickle.loads(dictdata(Configurations.jisyo_kanwa))
+
Jisyo.__init__ = jisyo_init
Itaiji.__init__ = itaiji_init
Kanwa.__init__ = kanwa_init
+
class Jadecoder(Unidecoder):
def __init__(self):
diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py
index a2cd86732e..712d960830 100644
--- a/src/calibre/gui2/__init__.py
+++ b/src/calibre/gui2/__init__.py
@@ -302,7 +302,6 @@ QIcon.icon_as_png = icon_resource_manager.icon_as_png
QIcon.is_ok = lambda self: not self.isNull() and len(self.availableSizes()) > 0
QIcon.cached_icon = icon_resource_manager.cached_icon
-
# Setup gprefs {{{
gprefs = JSONConfig('gui')
@@ -623,7 +622,6 @@ def _config(): # {{{
config = _config()
-
# }}}
QSettings.setPath(QSettings.Format.IniFormat, QSettings.Scope.UserScope, config_dir)
@@ -1605,6 +1603,7 @@ def open_local_file(path):
_ea_lock = Lock()
+
def simple_excepthook(t, v, tb):
return sys.__excepthook__(t, v, tb)
diff --git a/src/calibre/gui2/actions/__init__.py b/src/calibre/gui2/actions/__init__.py
index 5282d6b911..0b18ce5b00 100644
--- a/src/calibre/gui2/actions/__init__.py
+++ b/src/calibre/gui2/actions/__init__.py
@@ -85,7 +85,6 @@ def menu_action_unique_name(plugin, unique_name):
class InterfaceAction(QObject):
-
'''
A plugin representing an "action" that can be taken in the graphical user
interface. All the items in the toolbar and context menus are implemented
@@ -445,6 +444,7 @@ class InterfaceAction(QObject):
'''
pass
+
class InterfaceActionWithLibraryDrop(InterfaceAction):
'''
Subclass of InterfaceAction that implements methods to execute the default action
diff --git a/src/calibre/gui2/actions/copy_to_library.py b/src/calibre/gui2/actions/copy_to_library.py
index a17d5d1a19..e706c50ea4 100644
--- a/src/calibre/gui2/actions/copy_to_library.py
+++ b/src/calibre/gui2/actions/copy_to_library.py
@@ -334,7 +334,6 @@ class DuplicatesQuestion(QDialog): # {{{
@property
def ids(self):
return {int(i.data(Qt.ItemDataRole.UserRole)) for i in self.items if i.checkState() == Qt.CheckState.Checked}
-
# }}}
diff --git a/src/calibre/gui2/actions/device.py b/src/calibre/gui2/actions/device.py
index 1db7bd37b9..91493f5ff8 100644
--- a/src/calibre/gui2/actions/device.py
+++ b/src/calibre/gui2/actions/device.py
@@ -175,9 +175,9 @@ class ShareConnMenu(QMenu): # {{{
def set_state(self, device_connected, device):
self.connect_to_folder_action.setEnabled(not device_connected)
-
# }}}
+
class SendToDeviceAction(InterfaceAction):
name = 'Send To Device'
diff --git a/src/calibre/gui2/actions/preferences.py b/src/calibre/gui2/actions/preferences.py
index fdb6ebe5b5..8885780ccc 100644
--- a/src/calibre/gui2/actions/preferences.py
+++ b/src/calibre/gui2/actions/preferences.py
@@ -65,7 +65,6 @@ class PreferencesAction(InterfaceAction):
triggered=partial(self.do_config, initial_plugin=(p.category, p.name),
close_after_initial=True))
-
def get_plugins(self):
from calibre.gui2.dialogs.plugin_updater import FILTER_NOT_INSTALLED, PluginUpdaterDialog
d = PluginUpdaterDialog(self.gui,
diff --git a/src/calibre/gui2/bars.py b/src/calibre/gui2/bars.py
index b839ffb6da..f75537e208 100644
--- a/src/calibre/gui2/bars.py
+++ b/src/calibre/gui2/bars.py
@@ -353,8 +353,8 @@ class MenuAction(QAction): # {{{
self.setText(self.clone.text())
# }}}
-# MenuBar {{{
+# MenuBar {{{
if ismacos:
# On OS X we need special handling for the application global menu bar and
diff --git a/src/calibre/gui2/book_details.py b/src/calibre/gui2/book_details.py
index e3d922e12e..c5fe3bfa61 100644
--- a/src/calibre/gui2/book_details.py
+++ b/src/calibre/gui2/book_details.py
@@ -408,8 +408,8 @@ def render_data(mi, use_roman_numbers=True, all_fields=False, pref_name='book_di
# }}}
-# Context menu {{{
+# Context menu {{{
def add_format_entries(menu, data, book_info, copy_menu, search_menu):
from calibre.ebooks.oeb.polish.main import SUPPORTED
@@ -780,7 +780,6 @@ class CoverView(QWidget): # {{{
self.animation.setStartValue(QSize(0, 0))
self.animation.valueChanged.connect(self.value_changed)
-
self.default_pixmap = QApplication.instance().cached_qpixmap('default_cover.png', device_pixel_ratio=self.devicePixelRatio())
self.pixmap = self.default_pixmap
self.pwidth = self.pheight = None
@@ -1036,8 +1035,8 @@ class CoverView(QWidget): # {{{
# }}}
-# Book Info {{{
+# Book Info {{{
class BookInfo(HTMLDisplay):
@@ -1316,6 +1315,7 @@ class DetailsLayout(QSplitter): # {{{
cover.do_layout()
# }}}
+
# Drag 'n drop {{{
class DropMixin:
diff --git a/src/calibre/gui2/catalog/catalog_epub_mobi.py b/src/calibre/gui2/catalog/catalog_epub_mobi.py
index 2f413f3b24..e23acfdb57 100644
--- a/src/calibre/gui2/catalog/catalog_epub_mobi.py
+++ b/src/calibre/gui2/catalog/catalog_epub_mobi.py
@@ -850,7 +850,6 @@ class PluginWidget(QWidget,Ui_Form):
class CheckableTableWidgetItem(QTableWidgetItem):
-
'''
Borrowed from kiwidude
'''
@@ -905,7 +904,6 @@ class ComboBox(NoWheelComboBox):
class GenericRulesTable(QTableWidget):
-
'''
Generic methods for managing rows in a QTableWidget
'''
diff --git a/src/calibre/gui2/comments_editor.py b/src/calibre/gui2/comments_editor.py
index e970df3f4b..58d994da82 100644
--- a/src/calibre/gui2/comments_editor.py
+++ b/src/calibre/gui2/comments_editor.py
@@ -327,6 +327,7 @@ def fix_html(original_html, original_txt, remove_comments=True, callback=None):
ans = '%s
'%ans
return xml_replace_entities(ans)
+
class EditorWidget(QTextEdit, LineEditECM): # {{{
data_changed = pyqtSignal()
@@ -1199,7 +1200,6 @@ class EditorWidget(QTextEdit, LineEditECM): # {{{
# Highlighter {{{
-
State_Text = -1
State_DocType = 0
State_Comment = 1
diff --git a/src/calibre/gui2/device_drivers/mtp_config.py b/src/calibre/gui2/device_drivers/mtp_config.py
index 4c45121e37..704205e3b2 100644
--- a/src/calibre/gui2/device_drivers/mtp_config.py
+++ b/src/calibre/gui2/device_drivers/mtp_config.py
@@ -219,8 +219,8 @@ class IgnoredDevices(QWidget): # {{{
# }}}
-# Rules {{{
+# Rules {{{
class Rule(QWidget):
diff --git a/src/calibre/gui2/dialogs/catalog.py b/src/calibre/gui2/dialogs/catalog.py
index 9c5909e012..b665be6480 100644
--- a/src/calibre/gui2/dialogs/catalog.py
+++ b/src/calibre/gui2/dialogs/catalog.py
@@ -19,7 +19,6 @@ from calibre.gui2.dialogs.catalog_ui import Ui_Dialog
class Catalog(QDialog, Ui_Dialog):
-
''' Catalog Dialog builder'''
def __init__(self, parent, dbspec, ids, db):
diff --git a/src/calibre/gui2/dialogs/edit_category_notes.py b/src/calibre/gui2/dialogs/edit_category_notes.py
index 4093bc0c58..697d2b62f1 100644
--- a/src/calibre/gui2/dialogs/edit_category_notes.py
+++ b/src/calibre/gui2/dialogs/edit_category_notes.py
@@ -76,6 +76,7 @@ class AskLink(Dialog): # {{{
@property
def url(self):
return self.url_edit.text().strip()
+
# }}}
@@ -213,7 +214,6 @@ class AskImage(Dialog):
# }}}
-
class NoteEditorWidget(EditorWidget):
insert_images_separately = True
diff --git a/src/calibre/gui2/dialogs/plugin_updater.py b/src/calibre/gui2/dialogs/plugin_updater.py
index 1487c2aaab..2184a88d32 100644
--- a/src/calibre/gui2/dialogs/plugin_updater.py
+++ b/src/calibre/gui2/dialogs/plugin_updater.py
@@ -132,7 +132,6 @@ def get_installed_plugin_status(display_plugin):
class ImageTitleLayout(QHBoxLayout):
-
'''
A reusable layout widget displaying an image followed by a title
'''
@@ -158,7 +157,6 @@ class ImageTitleLayout(QHBoxLayout):
class SizePersistedDialog(QDialog):
-
'''
This dialog is a base class for any dialogs that want their size/position
restored when they are next opened.
diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py
index 1d1e1b286e..4974b39bf0 100644
--- a/src/calibre/gui2/dialogs/quickview.py
+++ b/src/calibre/gui2/dialogs/quickview.py
@@ -36,7 +36,6 @@ from calibre.utils.iso8601 import UNDEFINED_DATE
class TableItem(QTableWidgetItem):
-
'''
A QTableWidgetItem that sorts on a separate string and uses ICU rules
'''
diff --git a/src/calibre/gui2/dialogs/scheduler.py b/src/calibre/gui2/dialogs/scheduler.py
index c8c70457ac..faf2155586 100644
--- a/src/calibre/gui2/dialogs/scheduler.py
+++ b/src/calibre/gui2/dialogs/scheduler.py
@@ -86,8 +86,8 @@ class RecipesView(QTreeView):
QTreeView.currentChanged(self, current, previous)
self.parent().current_changed(current, previous)
-# Time/date widgets {{{
+# Time/date widgets {{{
class Base(QWidget):
diff --git a/src/calibre/gui2/dialogs/tag_categories.py b/src/calibre/gui2/dialogs/tag_categories.py
index 70234c2206..91647a3189 100644
--- a/src/calibre/gui2/dialogs/tag_categories.py
+++ b/src/calibre/gui2/dialogs/tag_categories.py
@@ -14,7 +14,6 @@ from calibre.utils.icu import primary_contains, primary_sort_key, strcmp
class TagCategories(QDialog, Ui_TagCategories):
-
'''
The structure of user_categories stored in preferences is
{cat_name: [ [name, category, v], [], [] ]}, cat_name: [ [name, cat, v] ...]}
diff --git a/src/calibre/gui2/dialogs/template_line_editor.py b/src/calibre/gui2/dialogs/template_line_editor.py
index 6f500e92f9..e3882953d3 100644
--- a/src/calibre/gui2/dialogs/template_line_editor.py
+++ b/src/calibre/gui2/dialogs/template_line_editor.py
@@ -13,7 +13,6 @@ from calibre.gui2.dialogs.template_dialog import TemplateDialog
class TemplateLineEditor(QLineEdit):
-
'''
Extend the context menu of a QLineEdit to include more actions.
'''
diff --git a/src/calibre/gui2/icon_theme.py b/src/calibre/gui2/icon_theme.py
index 3a647c6c8c..8dac058af7 100644
--- a/src/calibre/gui2/icon_theme.py
+++ b/src/calibre/gui2/icon_theme.py
@@ -498,8 +498,8 @@ def create_theme(folder=None, parent=None):
icon_resource_manager.set_theme()
# }}}
-# Choose Theme {{{
+# Choose Theme {{{
def download_cover(cover_url, etag=None, cached=b''):
url = BASE_URL + cover_url
diff --git a/src/calibre/gui2/init.py b/src/calibre/gui2/init.py
index 649e670c0d..9a44c2f7ff 100644
--- a/src/calibre/gui2/init.py
+++ b/src/calibre/gui2/init.py
@@ -122,8 +122,8 @@ class LibraryViewMixin: # {{{
v.set_current_row(0)
if v is self.library_view and v.row_count() == 0:
self.book_details.reset_info()
+# }}}
- # }}}
class UpdateLabel(QLabel): # {{{
@@ -135,6 +135,7 @@ class UpdateLabel(QLabel): # {{{
pass
# }}}
+
class VersionLabel(QLabel): # {{{
def __init__(self, parent):
@@ -172,6 +173,7 @@ class VersionLabel(QLabel): # {{{
return QLabel.paintEvent(self, ev)
# }}}
+
class StatusBar(QStatusBar): # {{{
def __init__(self, parent=None):
@@ -237,9 +239,9 @@ class StatusBar(QStatusBar): # {{{
def clear_message(self):
self.clearMessage()
-
# }}}
+
class GridViewButton(LayoutButton): # {{{
def __init__(self, gui):
@@ -270,10 +272,9 @@ class GridViewButton(LayoutButton): # {{{
def restore_state(self):
if gprefs.get('grid view visible', False):
self.toggle()
-
-
# }}}
+
class SearchBarButton(LayoutButton): # {{{
def __init__(self, gui):
@@ -304,10 +305,9 @@ class SearchBarButton(LayoutButton): # {{{
def restore_state(self):
self.setChecked(bool(gprefs.get('search bar visible', True)))
-
-
# }}}
+
class VLTabs(QTabBar): # {{{
def __init__(self, parent):
@@ -487,6 +487,7 @@ class VLTabs(QTabBar): # {{{
# }}}
+
class StatusBarButton(QToolButton):
def __init__(self, parent, action_name, pref_name, on_click):
@@ -798,5 +799,4 @@ class LayoutMixin: # {{{
selected = len(v.selectionModel().selectedRows())
library_total, total, current = v.model().counts()
self.status_bar.update_state(library_total, total, current, selected)
-
# }}}
diff --git a/src/calibre/gui2/jobs.py b/src/calibre/gui2/jobs.py
index e08be8ff45..fe3e8dbd6f 100644
--- a/src/calibre/gui2/jobs.py
+++ b/src/calibre/gui2/jobs.py
@@ -417,8 +417,8 @@ class FilterModel(QSortFilterProxyModel): # {{{
# }}}
-# Jobs UI {{{
+# Jobs UI {{{
class ProgressBarDelegate(QAbstractItemDelegate): # {{{
diff --git a/src/calibre/gui2/keyboard.py b/src/calibre/gui2/keyboard.py
index dbbc7562ab..f159d3335a 100644
--- a/src/calibre/gui2/keyboard.py
+++ b/src/calibre/gui2/keyboard.py
@@ -115,7 +115,6 @@ def finalize(shortcuts, custom_keys_map={}): # {{{
ac.setShortcuts(list(keys))
return keys_map
-
# }}}
@@ -194,8 +193,8 @@ class Manager(QObject): # {{{
# }}}
-# Model {{{
+# Model {{{
class Node:
@@ -567,9 +566,9 @@ class Editor(QFrame): # {{{
ans.append(ks)
return tuple(ans)
-
# }}}
+
class Delegate(QStyledItemDelegate): # {{{
changed_signal = pyqtSignal()
diff --git a/src/calibre/gui2/library/alternate_views.py b/src/calibre/gui2/library/alternate_views.py
index 29c2340edb..073d89d1dd 100644
--- a/src/calibre/gui2/library/alternate_views.py
+++ b/src/calibre/gui2/library/alternate_views.py
@@ -133,8 +133,8 @@ def image_to_data(image): # {{{
return ret
# }}}
-# Drag 'n Drop {{{
+# Drag 'n Drop {{{
def qt_item_view_base_class(self):
for q in (QTableView, QListView, QTreeView):
@@ -331,8 +331,8 @@ def setup_dnd_interface(cls_or_self):
self.setDragDropMode(QAbstractItemView.DragDropMode.DragDrop)
# }}}
-# Manage slave views {{{
+# Manage slave views {{{
def sync(func):
@wraps(func)
@@ -436,8 +436,8 @@ class AlternateViews:
self.current_view.marked_changed(old_marked, current_marked)
# }}}
-# Rendering of covers {{{
+# Rendering of covers {{{
class CoverDelegate(QStyledItemDelegate):
diff --git a/src/calibre/gui2/library/annotations.py b/src/calibre/gui2/library/annotations.py
index c31f86e93e..e97c10d227 100644
--- a/src/calibre/gui2/library/annotations.py
+++ b/src/calibre/gui2/library/annotations.py
@@ -226,7 +226,6 @@ class AnnotsResultsDelegate(ResultsDelegate):
text = parts[0]
return False, before, text, after, bool(result.get('annotation', {}).get('notes'))
-
# }}}
diff --git a/src/calibre/gui2/library/caches.py b/src/calibre/gui2/library/caches.py
index 9d85bb3508..6007f04738 100644
--- a/src/calibre/gui2/library/caches.py
+++ b/src/calibre/gui2/library/caches.py
@@ -24,7 +24,6 @@ class ThumbnailCache(TC):
class CoverCache(dict):
-
'''
This is a RAM cache to speed up rendering of covers by storing them as
QPixmaps. It is possible that it is called from multiple threads, thus the
diff --git a/src/calibre/gui2/library/delegates.py b/src/calibre/gui2/library/delegates.py
index 96d02b1bcd..ed0cc8a723 100644
--- a/src/calibre/gui2/library/delegates.py
+++ b/src/calibre/gui2/library/delegates.py
@@ -134,12 +134,14 @@ class UpdateEditorGeometry:
initial_geometry.adjust(delta_x, 0, delta_width, 0)
editor.setGeometry(initial_geometry)
+
class EditableTextDelegate:
def set_editor_data(self, editor, index):
n = editor.metaObject().userProperty().name()
editor.setProperty(n, get_val_for_textlike_columns(index))
+
class DateTimeEdit(DateTimeEditBase): # {{{
def __init__(self, parent, format_):
@@ -151,8 +153,8 @@ class DateTimeEdit(DateTimeEditBase): # {{{
# }}}
-# Number Editor {{{
+# Number Editor {{{
def make_clearing_spinbox(spinbox):
@@ -184,8 +186,8 @@ ClearingDoubleSpinBox = make_clearing_spinbox(QDoubleSpinBox)
# }}}
-# setter for text-like delegates. Return '' if CTRL is pushed {{{
+# setter for text-like delegates. Return '' if CTRL is pushed {{{
def check_key_modifier(which_modifier):
v = QApplication.keyboardModifiers() & (Qt.KeyboardModifier.ControlModifier | Qt.KeyboardModifier.ShiftModifier)
@@ -203,7 +205,6 @@ def get_val_for_textlike_columns(index_):
class StyledItemDelegate(QStyledItemDelegate):
-
'''
When closing an editor and opening another, Qt sometimes picks what appears
to be a random line and column for the second editor. This function checks
diff --git a/src/calibre/gui2/library/notes.py b/src/calibre/gui2/library/notes.py
index 94a1217a84..448d0c909d 100644
--- a/src/calibre/gui2/library/notes.py
+++ b/src/calibre/gui2/library/notes.py
@@ -350,7 +350,6 @@ class SearchInput(QWidget):
r.restriction_changed.connect(self.search_changed)
l.addWidget(r)
-
@property
def current_query(self):
return {
diff --git a/src/calibre/gui2/lrf_renderer/text.py b/src/calibre/gui2/lrf_renderer/text.py
index cef8455882..ac23be30aa 100644
--- a/src/calibre/gui2/lrf_renderer/text.py
+++ b/src/calibre/gui2/lrf_renderer/text.py
@@ -17,10 +17,16 @@ from polyglot.builtins import string_or_bytes
def WEIGHT_MAP(wt):
return int(wt / 10 - 1)
+
+
def NULL(a, b):
return a
+
+
def COLOR(a, b):
return QColor(*a)
+
+
def WEIGHT(a, b):
return WEIGHT_MAP(a)
diff --git a/src/calibre/gui2/main_window.py b/src/calibre/gui2/main_window.py
index aa8a50aed9..a4d6247788 100644
--- a/src/calibre/gui2/main_window.py
+++ b/src/calibre/gui2/main_window.py
@@ -26,7 +26,6 @@ Launch the Graphical User Interface
class GarbageCollector(QObject):
-
'''
Disable automatic garbage collection and instead collect manually
every INTERVAL milliseconds.
diff --git a/src/calibre/gui2/metadata/basic_widgets.py b/src/calibre/gui2/metadata/basic_widgets.py
index f3ea2dad74..4739ff4cbf 100644
--- a/src/calibre/gui2/metadata/basic_widgets.py
+++ b/src/calibre/gui2/metadata/basic_widgets.py
@@ -222,8 +222,8 @@ def make_undoable(spinbox):
return UndoableSpinbox
-# Title {{{
+# Title {{{
class TitleEdit(EnLineEdit, ToMetadataMixin):
@@ -357,8 +357,8 @@ class TitleSortEdit(TitleEdit, ToMetadataMixin, LineEditIndicators):
# }}}
-# Authors {{{
+# Authors {{{
class AuthorsEdit(EditWithComplete, ToMetadataMixin):
@@ -622,8 +622,8 @@ class AuthorSortEdit(EnLineEdit, ToMetadataMixin, LineEditIndicators):
# }}}
-# Series {{{
+# Series {{{
class SeriesEdit(EditWithComplete, ToMetadataMixin):
@@ -794,8 +794,8 @@ class BuddyLabel(QLabel): # {{{
self.setAlignment(Qt.AlignmentFlag.AlignRight|Qt.AlignmentFlag.AlignVCenter)
# }}}
-# Formats {{{
+# Formats {{{
class Format(QListWidgetItem):
@@ -1603,8 +1603,8 @@ class LanguagesEdit(LE, ToMetadataMixin): # {{{
self.update_recently_used()
# }}}
-# Identifiers {{{
+# Identifiers {{{
class Identifiers(Dialog):
@@ -1845,6 +1845,7 @@ class IdentifiersEdit(QLineEdit, ToMetadataMixin, LineEditIndicators):
return False
# }}}
+
class IndicatorLineEdit(QLineEdit, LineEditIndicators):
pass
@@ -1978,8 +1979,8 @@ class PublisherEdit(EditWithComplete, ToMetadataMixin): # {{{
# }}}
-# DateEdit {{{
+# DateEdit {{{
class DateEdit(make_undoable(DateTimeEdit), ToMetadataMixin):
diff --git a/src/calibre/gui2/metadata/diff.py b/src/calibre/gui2/metadata/diff.py
index 61be77adae..6a79820247 100644
--- a/src/calibre/gui2/metadata/diff.py
+++ b/src/calibre/gui2/metadata/diff.py
@@ -55,8 +55,8 @@ from polyglot.builtins import iteritems, itervalues
Widgets = namedtuple('Widgets', 'new old label button')
-# Widgets {{{
+# Widgets {{{
class LineEdit(EditWithComplete):
@@ -626,7 +626,6 @@ class CoverZoom(QWidget):
class CompareMany(QDialog):
-
def __init__(self, ids, get_metadata, field_metadata, parent=None,
window_title=None,
reject_button_tooltip=None,
@@ -747,27 +746,22 @@ class CompareMany(QDialog):
b.setFocus(Qt.FocusReason.OtherFocusReason)
self.next_called = False
-
def show_zoomed_cover(self, pixmap):
self.cover_zoom.set_pixmap(pixmap)
self.stack.setCurrentIndex(1)
-
@property
def mark_rejected(self):
return self.markq.isChecked()
-
def action_button_clicked(self):
self.action_button_action(self.ids[0])
-
def accept(self):
self.save_geometry(gprefs, 'diff_dialog_geom')
self.compare_widget.save_comments_controls_state()
super().accept()
-
def reject(self):
if self.stack.currentIndex() == 1:
self.stack.setCurrentIndex(0)
@@ -780,12 +774,10 @@ class CompareMany(QDialog):
self.compare_widget.save_comments_controls_state()
super().reject()
-
@property
def current_mi(self):
return self.compare_widget.current_mi
-
def show_current_item(self):
self.setWindowTitle(self.window_title + _(' [%(num)d of %(tot)d]') % dict(
num=(self.total - len(self.ids) + 1), tot=self.total))
@@ -819,7 +811,6 @@ class CompareMany(QDialog):
return self.accept()
self.show_current_item()
-
def previous_item(self):
if self.previous_items:
# get the last book id from the previous items list and remove it from the previous items list
@@ -838,7 +829,6 @@ class CompareMany(QDialog):
self.ids.insert(0, last_previous_item)
self.show_current_item()
-
def accept_all_remaining(self):
self.next_item(True)
for id_ in self.ids:
@@ -847,7 +837,6 @@ class CompareMany(QDialog):
self.ids = []
self.accept()
-
def reject_all_remaining(self):
from calibre.gui2.dialogs.confirm_delete import confirm
if not confirm(ngettext(
@@ -863,7 +852,6 @@ class CompareMany(QDialog):
self.ids = []
self.accept()
-
def keyPressEvent(self, ev):
if ev.key() in (Qt.Key.Key_Enter, Qt.Key.Key_Return):
ev.accept()
diff --git a/src/calibre/gui2/notify.py b/src/calibre/gui2/notify.py
index 0754067cb4..3cc81213ef 100644
--- a/src/calibre/gui2/notify.py
+++ b/src/calibre/gui2/notify.py
@@ -277,5 +277,6 @@ def develop_win():
initialize_toast(__appname__, MAIN_APP_UID)
notify('calibre notification', 'hello world', icon())
+
if __name__ == '__main__':
hello()
diff --git a/src/calibre/gui2/preferences/__init__.py b/src/calibre/gui2/preferences/__init__.py
index c56e2c0b21..92689d62f6 100644
--- a/src/calibre/gui2/preferences/__init__.py
+++ b/src/calibre/gui2/preferences/__init__.py
@@ -42,7 +42,6 @@ class AbortInitialize(Exception):
class ConfigWidgetInterface:
-
'''
This class defines the interface that all widgets displayed in the
Preferences dialog must implement. See :class:`ConfigWidgetBase` for
@@ -118,6 +117,7 @@ class ConfigWidgetInterface:
r = r | bool(getattr(t, method)(*args))
return r
+
def set_help_tips(gui_obj, tt):
if tt:
if not str(gui_obj.whatsThis()):
@@ -265,7 +265,6 @@ class CommaSeparatedList(Setting):
class ConfigWidgetBase(QWidget, ConfigWidgetInterface):
-
'''
Base class that contains code to easily add standard config widgets like
checkboxes, combo boxes, text fields and so on. See the :meth:`register`
@@ -497,7 +496,6 @@ class TableWidgetWithMoveByKeyPress(QTableWidget):
# Testing {{{
-
def test_widget(category, name, gui=None):
show_config_widget(category, name, gui=gui, show_restart_msg=True)
diff --git a/src/calibre/gui2/preferences/look_feel.py b/src/calibre/gui2/preferences/look_feel.py
index acbd7fdddf..893aeb6193 100644
--- a/src/calibre/gui2/preferences/look_feel.py
+++ b/src/calibre/gui2/preferences/look_feel.py
@@ -137,9 +137,8 @@ class DefaultAuthorLink(QWidget): # {{{
self.custom_url.setVisible(k == 'url')
# }}}
+
# IdLinksEditor {{{
-
-
class IdLinksRuleEdit(Dialog):
def __init__(self, key='', name='', template='', parent=None):
@@ -286,7 +285,6 @@ class QVDisplayedFields(DisplayedFields): # {{{
def commit(self):
if self.changed:
self.db.new_api.set_pref('qv_display_fields', self.fields)
-
# }}}
@@ -638,7 +636,6 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
self.tb_partition_import_layout_button.clicked.connect(partial(self.import_layout,
model=self.tb_categories_to_part_model))
-
self.bd_vertical_cats_model = BDVerticalCats(self.gui.current_db, self.tb_hierarchy_tab.tb_hierarchical_cats)
self.bd_vertical_cats_model.dataChanged.connect(self.changed_signal)
self.bd_vertical_cats.setModel(self.bd_vertical_cats_model)
diff --git a/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py b/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py
index 139123a95f..be00accbcb 100644
--- a/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py
+++ b/src/calibre/gui2/preferences/look_feel_tabs/tb_hierarchy.py
@@ -54,7 +54,6 @@ class TBHierarchicalFields(DisplayedFields): # {{{
# }}}
-
class TbHierarchyTab(ConfigTabWidget, Ui_Form):
def genesis(self, gui):
diff --git a/src/calibre/gui2/preferences/main.py b/src/calibre/gui2/preferences/main.py
index e75e48350a..caf6d121e7 100644
--- a/src/calibre/gui2/preferences/main.py
+++ b/src/calibre/gui2/preferences/main.py
@@ -44,8 +44,8 @@ from calibre.gui2.preferences import AbortCommit, AbortInitialize, get_plugin, i
ICON_SIZE = 32
-# Title Bar {{{
+# Title Bar {{{
class Message(QWidget):
@@ -215,7 +215,6 @@ class Browser(QScrollArea): # {{{
w.plugin_activated.connect(self.show_plugin.emit)
self._layout.addStretch(1)
-
# }}}
diff --git a/src/calibre/gui2/preferences/plugins.py b/src/calibre/gui2/preferences/plugins.py
index 0e013456a2..7da65c1b8a 100644
--- a/src/calibre/gui2/preferences/plugins.py
+++ b/src/calibre/gui2/preferences/plugins.py
@@ -218,9 +218,9 @@ class PluginModel(QAbstractItemModel, AdaptSQP): # {{{
return plugin
return None
-
# }}}
+
class ConfigWidget(ConfigWidgetBase, Ui_Form):
supports_restoring_to_defaults = False
diff --git a/src/calibre/gui2/preferences/server.py b/src/calibre/gui2/preferences/server.py
index fef223e98c..668908d001 100644
--- a/src/calibre/gui2/preferences/server.py
+++ b/src/calibre/gui2/preferences/server.py
@@ -109,7 +109,6 @@ else:
# Advanced {{{
-
def init_opt(widget, opt, layout):
widget.name, widget.default_val = opt.name, opt.default
if opt.longdoc:
@@ -446,11 +445,10 @@ class MainTab(QWidget): # {{{
def settings(self):
return {'auth': self.opt_auth.isChecked(), 'port': self.opt_port.value()}
-
# }}}
-# Users {{{
+# Users {{{
class NewUser(QDialog):
@@ -900,7 +898,6 @@ class Users(QWidget):
def display_user_data(self, username=None):
self.user_display.show_user(username, self.user_data)
-
# }}}
diff --git a/src/calibre/gui2/progress_indicator/__init__.py b/src/calibre/gui2/progress_indicator/__init__.py
index 9452a8e3c1..49646c2e4f 100644
--- a/src/calibre/gui2/progress_indicator/__init__.py
+++ b/src/calibre/gui2/progress_indicator/__init__.py
@@ -8,6 +8,7 @@ from calibre_extensions.progress_indicator import SpinAnimator, draw_snake_spinn
draw_snake_spinner
+
class WaitPanel(QWidget):
def __init__(self, msg, parent=None, size=256, interval=10):
diff --git a/src/calibre/gui2/save.py b/src/calibre/gui2/save.py
index bdfd30790c..cb5457c326 100644
--- a/src/calibre/gui2/save.py
+++ b/src/calibre/gui2/save.py
@@ -65,7 +65,6 @@ class SpooledFile(SpooledTemporaryFile): # {{{
newfile.seek(orig.tell(), 0)
self._rolled = True
-
# }}}
diff --git a/src/calibre/gui2/store/stores/amazon_de_plugin.py b/src/calibre/gui2/store/stores/amazon_de_plugin.py
index 17c64fae3a..ec4b72b594 100644
--- a/src/calibre/gui2/store/stores/amazon_de_plugin.py
+++ b/src/calibre/gui2/store/stores/amazon_de_plugin.py
@@ -28,6 +28,5 @@ class AmazonKindleStore(Base, StorePlugin):
pass
-
if __name__ == '__main__':
Base().develop_plugin()
diff --git a/src/calibre/gui2/tag_browser/__init__.py b/src/calibre/gui2/tag_browser/__init__.py
index ad82601065..1f6b29ebfa 100644
--- a/src/calibre/gui2/tag_browser/__init__.py
+++ b/src/calibre/gui2/tag_browser/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2011, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/gui2/tag_browser/ui.py b/src/calibre/gui2/tag_browser/ui.py
index cf947fc13f..5cb533241f 100644
--- a/src/calibre/gui2/tag_browser/ui.py
+++ b/src/calibre/gui2/tag_browser/ui.py
@@ -1099,5 +1099,4 @@ class TagBrowserWidget(QFrame): # {{{
return
return QFrame.keyPressEvent(self, ev)
-
# }}}
diff --git a/src/calibre/gui2/tag_browser/view.py b/src/calibre/gui2/tag_browser/view.py
index abb481fb18..6503dc292e 100644
--- a/src/calibre/gui2/tag_browser/view.py
+++ b/src/calibre/gui2/tag_browser/view.py
@@ -253,7 +253,7 @@ class TagDelegate(QStyledItemDelegate): # {{{
editor = EnLineEdit(parent)
return editor
- # }}}
+# }}}
class TagsView(QTreeView): # {{{
@@ -1637,5 +1637,4 @@ class TagsView(QTreeView): # {{{
if not expansion[0]:
self.collapse(idx)
-
- # }}}
+# }}}
diff --git a/src/calibre/gui2/toc/__init__.py b/src/calibre/gui2/toc/__init__.py
index d91f720858..9c3d29d79e 100644
--- a/src/calibre/gui2/toc/__init__.py
+++ b/src/calibre/gui2/toc/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/gui2/toc/main.py b/src/calibre/gui2/toc/main.py
index 015d2f4289..6736a2ca3b 100644
--- a/src/calibre/gui2/toc/main.py
+++ b/src/calibre/gui2/toc/main.py
@@ -1012,7 +1012,6 @@ class TOCView(QWidget): # {{{
def undo(self):
self.tocw.pop_history()
-
# }}}
diff --git a/src/calibre/gui2/tools.py b/src/calibre/gui2/tools.py
index 4852c7e504..153b4cd275 100644
--- a/src/calibre/gui2/tools.py
+++ b/src/calibre/gui2/tools.py
@@ -136,8 +136,8 @@ def convert_single_ebook(parent, db, book_ids, auto_conversion=False, # {{{
return jobs, changed, bad
# }}}
-# Bulk convert {{{
+# Bulk convert {{{
def convert_bulk_ebook(parent, queue, db, book_ids, out_format=None, args=[]):
total = len(book_ids)
@@ -327,7 +327,6 @@ def fetch_scheduled_recipe(arg): # {{{
recs.append(('recipe_specific_option', serialized, OptionRecommendation.HIGH))
return 'gui_convert_recipe', args, _('Fetch news from %s')%arg['title'], fmt.upper(), [pt]
-
# }}}
diff --git a/src/calibre/gui2/trash.py b/src/calibre/gui2/trash.py
index ec3801935d..8ac8a74914 100644
--- a/src/calibre/gui2/trash.py
+++ b/src/calibre/gui2/trash.py
@@ -314,8 +314,6 @@ class TrashView(Dialog):
det_msg='\n'.join(det_msg), show=True)
-
-
if __name__ == '__main__':
from calibre.gui2 import Application
from calibre.library import db
diff --git a/src/calibre/gui2/tts/piper.py b/src/calibre/gui2/tts/piper.py
index 67e0c7106c..fe38147d7e 100644
--- a/src/calibre/gui2/tts/piper.py
+++ b/src/calibre/gui2/tts/piper.py
@@ -757,7 +757,6 @@ class ThreadedPipeReader(PipeReader):
self.queue.put((data, is_stdout, None))
-
def duration_of_raw_audio_data(data: bytes, sample_rate: int = HIGH_QUALITY_SAMPLE_RATE, bytes_per_sample: int = 2, num_channels: int = 1) -> float:
total_num_of_samples = len(data) / bytes_per_sample
num_of_samples_per_channel = total_num_of_samples / num_channels
diff --git a/src/calibre/gui2/tts/types.py b/src/calibre/gui2/tts/types.py
index ce4a4e52fc..fd1f8548b2 100644
--- a/src/calibre/gui2/tts/types.py
+++ b/src/calibre/gui2/tts/types.py
@@ -109,7 +109,6 @@ class Voice(NamedTuple):
return (self.quality.value, self.basic_name.lower())
-
def qvoice_to_voice(v: QVoice) -> QVoice:
lang = canonicalize_lang(QLocale.languageToCode(v.language())) or 'und'
country = QLocale.territoryToString(v.locale().territory())
diff --git a/src/calibre/gui2/tweak_book/check.py b/src/calibre/gui2/tweak_book/check.py
index e34d04ccf3..8ee77ff392 100644
--- a/src/calibre/gui2/tweak_book/check.py
+++ b/src/calibre/gui2/tweak_book/check.py
@@ -53,6 +53,7 @@ def prefix_for_level(level):
text += ': '
return text
+
def build_error_message(error, with_level=False, with_line_numbers=False):
prefix = ''
filename = error.name
@@ -62,6 +63,7 @@ def build_error_message(error, with_level=False, with_line_numbers=False):
filename = f'{filename}:{error.line}'
return f'{prefix}{error.msg}\xa0\xa0\xa0\xa0[{filename}]'
+
class Delegate(QStyledItemDelegate):
def initStyleOption(self, option, index):
diff --git a/src/calibre/gui2/tweak_book/editor/canvas.py b/src/calibre/gui2/tweak_book/editor/canvas.py
index 6cd5f92d0a..4a60782c68 100644
--- a/src/calibre/gui2/tweak_book/editor/canvas.py
+++ b/src/calibre/gui2/tweak_book/editor/canvas.py
@@ -107,7 +107,6 @@ def get_selection_rect(img, sr, target):
class Trim(Command):
-
''' Remove the areas of the image outside the current selection. '''
TEXT = _('Trim image')
@@ -117,7 +116,6 @@ class Trim(Command):
class AutoTrim(Trim):
-
''' Auto trim borders from the image '''
TEXT = _('Auto-trim image')
@@ -200,7 +198,6 @@ class Normalize(Command):
class Replace(Command):
-
''' Replace the current image with another image. If there is a selection,
only the region of the selection is replaced. '''
diff --git a/src/calibre/gui2/tweak_book/editor/insert_resource.py b/src/calibre/gui2/tweak_book/editor/insert_resource.py
index ed6f2c66be..02a4fcc20c 100644
--- a/src/calibre/gui2/tweak_book/editor/insert_resource.py
+++ b/src/calibre/gui2/tweak_book/editor/insert_resource.py
@@ -95,8 +95,8 @@ class ChooseName(Dialog): # {{{
super().accept()
# }}}
-# Images {{{
+# Images {{{
class ImageDelegate(QStyledItemDelegate):
@@ -373,6 +373,7 @@ class InsertImage(Dialog):
def filter_changed(self, *args):
f = str(self.filter.text())
self.fm.setFilterFixedString(f)
+
# }}}
diff --git a/src/calibre/gui2/tweak_book/editor/smarts/python.py b/src/calibre/gui2/tweak_book/editor/smarts/python.py
index 4e8a0a090a..50814e9a39 100644
--- a/src/calibre/gui2/tweak_book/editor/smarts/python.py
+++ b/src/calibre/gui2/tweak_book/editor/smarts/python.py
@@ -16,6 +16,7 @@ from calibre.gui2.tweak_book.editor.smarts.utils import get_text_before_cursor,
def get_leading_whitespace_on_block(editor, previous=False):
return expand_tabs(lw(editor, previous=previous))
+
tw = 4 # The tab width (hardcoded to the pep8 value)
diff --git a/src/calibre/gui2/tweak_book/editor/smarts/utils.py b/src/calibre/gui2/tweak_book/editor/smarts/utils.py
index 8ece27b29e..88fe80524d 100644
--- a/src/calibre/gui2/tweak_book/editor/smarts/utils.py
+++ b/src/calibre/gui2/tweak_book/editor/smarts/utils.py
@@ -16,6 +16,8 @@ def get_text_around_cursor(editor, before=True):
get_text_before_cursor = get_text_around_cursor
+
+
def get_text_after_cursor(editor):
return get_text_around_cursor(editor, before=False)
diff --git a/src/calibre/gui2/tweak_book/editor/snippets.py b/src/calibre/gui2/tweak_book/editor/snippets.py
index c598e2829b..2e1ea5cef0 100644
--- a/src/calibre/gui2/tweak_book/editor/snippets.py
+++ b/src/calibre/gui2/tweak_book/editor/snippets.py
@@ -47,6 +47,8 @@ from polyglot.builtins import codepoint_to_chr, iteritems, itervalues
def string_length(x):
return strlen(str(x)) # Needed on narrow python builds, as subclasses of unicode dont work
+
+
KEY = Qt.Key.Key_J
MODIFIER = Qt.KeyboardModifier.MetaModifier if ismacos else Qt.KeyboardModifier.ControlModifier
@@ -108,6 +110,7 @@ obtain some advantage from it? But.
} # }}}
+
# Parsing of snippets {{{
escape = unescape = None
@@ -202,8 +205,8 @@ def snippets(refresh=False):
_snippets = sorted(iteritems(_snippets), key=(lambda key_snip:string_length(key_snip[0].trigger)), reverse=True)
return _snippets
-# Editor integration {{{
+# Editor integration {{{
class EditorTabStop:
@@ -457,8 +460,8 @@ class SnippetManager(QObject):
return False
# }}}
-# Config {{{
+# Config {{{
class SnippetTextEdit(PlainTextEdit):
diff --git a/src/calibre/gui2/tweak_book/editor/syntax/__init__.py b/src/calibre/gui2/tweak_book/editor/syntax/__init__.py
index 0cbf055ec8..fb2e4b74e1 100644
--- a/src/calibre/gui2/tweak_book/editor/syntax/__init__.py
+++ b/src/calibre/gui2/tweak_book/editor/syntax/__init__.py
@@ -3,6 +3,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-
-
-
diff --git a/src/calibre/gui2/tweak_book/editor/syntax/javascript.py b/src/calibre/gui2/tweak_book/editor/syntax/javascript.py
index aa85f607e6..3cc1605e80 100644
--- a/src/calibre/gui2/tweak_book/editor/syntax/javascript.py
+++ b/src/calibre/gui2/tweak_book/editor/syntax/javascript.py
@@ -23,7 +23,6 @@ JS_IDENT = JS_IDENT_START + '(?:' + JS_IDENT_PART + ')*'
class JavascriptLexer(RegexLexer):
-
'''
For JavaScript source code. This is based on the pygments JS highlighter,
bu that does not handle multi-line comments in streaming mode, so we had to
diff --git a/src/calibre/gui2/tweak_book/editor/syntax/utils.py b/src/calibre/gui2/tweak_book/editor/syntax/utils.py
index 3abe8dc480..6673f4b3a3 100644
--- a/src/calibre/gui2/tweak_book/editor/syntax/utils.py
+++ b/src/calibre/gui2/tweak_book/editor/syntax/utils.py
@@ -47,6 +47,3 @@ def format_for_pygments_token(theme, cache, token):
return ans
cache[token] = ans = NULL_FMT
return ans
-
-
-
diff --git a/src/calibre/gui2/tweak_book/editor/themes.py b/src/calibre/gui2/tweak_book/editor/themes.py
index 5b92845aa2..a47a495543 100644
--- a/src/calibre/gui2/tweak_book/editor/themes.py
+++ b/src/calibre/gui2/tweak_book/editor/themes.py
@@ -341,8 +341,8 @@ def builtin_theme_names():
def all_theme_names():
return builtin_theme_names() + custom_theme_names()
-# Custom theme creation/editing {{{
+# Custom theme creation/editing {{{
class CreateNewTheme(Dialog):
@@ -500,8 +500,8 @@ class Property(QWidget):
self.data['underline'] = str(self.underline.currentText()) or None
self.changed.emit()
-# Help text {{{
+# Help text {{{
HELP_TEXT = _('''\
Creating a custom theme
diff --git a/src/calibre/gui2/tweak_book/plugin.py b/src/calibre/gui2/tweak_book/plugin.py
index 4565d794ec..6be40c449f 100644
--- a/src/calibre/gui2/tweak_book/plugin.py
+++ b/src/calibre/gui2/tweak_book/plugin.py
@@ -18,7 +18,6 @@ from polyglot.builtins import itervalues
class Tool:
-
'''
The base class for individual tools in an Edit Book plugin. Useful members include:
diff --git a/src/calibre/gui2/tweak_book/polish.py b/src/calibre/gui2/tweak_book/polish.py
index fae596202f..f57f4295e8 100644
--- a/src/calibre/gui2/tweak_book/polish.py
+++ b/src/calibre/gui2/tweak_book/polish.py
@@ -163,8 +163,8 @@ def show_report(changed, title, report, parent, show_current_diff):
if d.show_changes:
show_current_diff(allow_revert=True)
-# CompressImages {{{
+# CompressImages {{{
class ImageItemDelegate(QStyledItemDelegate):
@@ -277,7 +277,6 @@ class CompressImages(Dialog):
return self.webp.jq.value()
-
class CompressImagesProgress(Dialog):
gui_loop = pyqtSignal(object, object, object)
diff --git a/src/calibre/gui2/tweak_book/preferences.py b/src/calibre/gui2/tweak_book/preferences.py
index 1d7b6d58ee..4c070ef76e 100644
--- a/src/calibre/gui2/tweak_book/preferences.py
+++ b/src/calibre/gui2/tweak_book/preferences.py
@@ -472,7 +472,6 @@ class PreviewSettings(BasicSettings): # {{{
# ToolbarSettings {{{
-
class ToolbarList(QListWidget):
def __init__(self, parent=None):
diff --git a/src/calibre/gui2/tweak_book/preview.py b/src/calibre/gui2/tweak_book/preview.py
index bdc7ff7f73..a0e4e4a2c7 100644
--- a/src/calibre/gui2/tweak_book/preview.py
+++ b/src/calibre/gui2/tweak_book/preview.py
@@ -65,8 +65,8 @@ def get_data(name):
return editors[name].get_raw_data()
return current_container().raw_data(name)
-# Parsing of html to add linenumbers {{{
+# Parsing of html to add linenumbers {{{
def parse_html(raw):
root = parse(raw, decoder=lambda x:x.decode('utf-8'), line_numbers=True, linenumber_attribute='data-lnum')
@@ -175,8 +175,8 @@ class ParseWorker(Thread):
parse_worker = ParseWorker()
# }}}
-# Override network access to load data "live" from the editors {{{
+# Override network access to load data "live" from the editors {{{
class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
@@ -238,7 +238,6 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
if self.requests:
return QTimer.singleShot(10, self.check_for_parse)
-
# }}}
diff --git a/src/calibre/gui2/tweak_book/reports.py b/src/calibre/gui2/tweak_book/reports.py
index c4adb09e93..4b7adb3194 100644
--- a/src/calibre/gui2/tweak_book/reports.py
+++ b/src/calibre/gui2/tweak_book/reports.py
@@ -260,8 +260,8 @@ class FilesView(QTableView):
# }}}
-# Files {{{
+# Files {{{
class FilesModel(FileCollection):
@@ -363,8 +363,8 @@ class FilesWidget(QWidget):
# }}}
-# Jump {{{
+# Jump {{{
def jump_to_location(loc):
from calibre.gui2.tweak_book.boss import get_boss
@@ -405,8 +405,8 @@ class Jump:
jump = Jump()
# }}}
-# Images {{{
+# Images {{{
class ImagesDelegate(QStyledItemDelegate):
@@ -564,8 +564,8 @@ class ImagesWidget(QWidget):
self.files.save_table('image-files-table')
# }}}
-# Links {{{
+# Links {{{
class LinksModel(FileCollection):
@@ -728,8 +728,8 @@ class LinksWidget(QWidget):
save_state('links-view-splitter', bytearray(self.splitter.saveState()))
# }}}
-# Words {{{
+# Words {{{
class WordsModel(FileCollection):
@@ -828,8 +828,8 @@ class WordsWidget(QWidget):
self.words.save_table('words-table')
# }}}
-# Characters {{{
+# Characters {{{
class CharsModel(FileCollection):
@@ -947,8 +947,8 @@ class CharsWidget(QWidget):
# }}}
-# CSS {{{
+# CSS {{{
class CSSRulesModel(QAbstractItemModel):
@@ -1196,8 +1196,8 @@ class CSSWidget(QWidget):
# }}}
-# Classes {{{
+# Classes {{{
class ClassesModel(CSSRulesModel):
@@ -1331,8 +1331,8 @@ class ClassesWidget(CSSWidget):
# }}}
-# Wrapper UI {{{
+# Wrapper UI {{{
class ReportsWidget(QWidget):
diff --git a/src/calibre/gui2/tweak_book/search.py b/src/calibre/gui2/tweak_book/search.py
index b2e90183fe..47865f97c1 100644
--- a/src/calibre/gui2/tweak_book/search.py
+++ b/src/calibre/gui2/tweak_book/search.py
@@ -67,7 +67,6 @@ from polyglot.builtins import error_message, iteritems
class AnimatablePushButton(QPushButton):
-
'A push button that can be animated without actually emitting a clicked signal'
def __init__(self, *args, **kwargs):
diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py
index 284c32bf37..0cf6abb9d4 100644
--- a/src/calibre/gui2/tweak_book/spell.py
+++ b/src/calibre/gui2/tweak_book/spell.py
@@ -95,6 +95,7 @@ def country_map():
_country_map = msgpack_loads(P('localization/iso3166.calibre_msgpack', data=True, allow_user_override=False))
return _country_map
+
def current_languages_dictionaries(reread=False):
all_dictionaries = builtin_dictionaries() | custom_dictionaries(reread=reread)
languages = defaultdict(lambda : defaultdict(set))
@@ -103,6 +104,7 @@ def current_languages_dictionaries(reread=False):
languages[locale.langcode][locale.countrycode].add(d)
return languages
+
class AddDictionary(QDialog): # {{{
def __init__(self, parent=None):
@@ -257,8 +259,8 @@ class AddDictionary(QDialog): # {{{
QDialog.accept(self)
# }}}
-# User Dictionaries {{{
+# User Dictionaries {{{
class UserWordList(QListWidget):
@@ -521,9 +523,9 @@ class ManageUserDictionaries(Dialog):
d = cls()
d.exec()
-
# }}}
+
class ManageDictionaries(Dialog): # {{{
def __init__(self, parent=None):
@@ -715,8 +717,8 @@ class ManageDictionaries(Dialog): # {{{
d.exec()
# }}}
-# Spell Check Dialog {{{
+# Spell Check Dialog {{{
class WordsModel(QAbstractTableModel):
@@ -1639,8 +1641,8 @@ class SpellCheck(Dialog):
d.exec()
# }}}
-# Find next occurrence {{{
+# Find next occurrence {{{
def find_next(word, locations, current_editor, current_editor_name,
gui_parent, show_editor, edit_file):
diff --git a/src/calibre/gui2/tweak_book/widgets.py b/src/calibre/gui2/tweak_book/widgets.py
index 9887ebf1f5..4e617b6a80 100644
--- a/src/calibre/gui2/tweak_book/widgets.py
+++ b/src/calibre/gui2/tweak_book/widgets.py
@@ -287,8 +287,8 @@ class ImportForeign(Dialog): # {{{
return src, dest
# }}}
-# Quick Open {{{
+# Quick Open {{{
def make_highlighted_text(emph, text, positions):
positions = sorted(set(positions) - {-1})
@@ -516,8 +516,8 @@ class QuickOpen(Dialog):
# }}}
-# Filterable names list {{{
+# Filterable names list {{{
class NamesDelegate(QStyledItemDelegate):
@@ -619,8 +619,8 @@ def create_filterable_names_list(names, filter_text=None, parent=None, model=Nam
# }}}
-# Insert Link {{{
+# Insert Link {{{
class AnchorsModel(QAbstractListModel):
@@ -1110,8 +1110,8 @@ class FilterCSS(Dialog): # {{{
# }}}
-# Add Cover {{{
+# Add Cover {{{
class CoverView(QWidget):
diff --git a/src/calibre/gui2/ui.py b/src/calibre/gui2/ui.py
index 6d14ba58e2..e34182a3cc 100644
--- a/src/calibre/gui2/ui.py
+++ b/src/calibre/gui2/ui.py
@@ -112,7 +112,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
SavedSearchBoxMixin, SearchRestrictionMixin, LayoutMixin, UpdateMixin,
EbookDownloadMixin
):
-
'The main GUI'
proceed_requested = pyqtSignal(object, object)
diff --git a/src/calibre/gui2/viewer/__init__.py b/src/calibre/gui2/viewer/__init__.py
index b321fb5539..87d2eef191 100644
--- a/src/calibre/gui2/viewer/__init__.py
+++ b/src/calibre/gui2/viewer/__init__.py
@@ -56,7 +56,6 @@ def url_for_book_in_library():
return ans
-
class PerformanceMonitor:
def __init__(self):
diff --git a/src/calibre/gui2/viewer/search.py b/src/calibre/gui2/viewer/search.py
index 948501644b..1965bd8751 100644
--- a/src/calibre/gui2/viewer/search.py
+++ b/src/calibre/gui2/viewer/search.py
@@ -610,7 +610,6 @@ class Results(QTreeWidget): # {{{
self.context_menu.popup(self.mapToGlobal(point))
return True
-
def viewportEvent(self, ev):
if hasattr(self, 'gesture_manager'):
ret = self.gesture_manager.handle_event(ev)
diff --git a/src/calibre/gui2/viewer/web_view.py b/src/calibre/gui2/viewer/web_view.py
index b39fc82fcb..cea2c3fbd8 100644
--- a/src/calibre/gui2/viewer/web_view.py
+++ b/src/calibre/gui2/viewer/web_view.py
@@ -56,8 +56,8 @@ from polyglot.functools import lru_cache
SANDBOX_HOST = FAKE_HOST.rpartition('.')[0] + '.sandbox'
-# Override network access to load data from the book {{{
+# Override network access to load data from the book {{{
def set_book_path(path, pathtoebook):
set_book_path.pathtoebook = pathtoebook
diff --git a/src/calibre/gui2/widgets.py b/src/calibre/gui2/widgets.py
index c6cba20c72..5bc0b9b0d1 100644
--- a/src/calibre/gui2/widgets.py
+++ b/src/calibre/gui2/widgets.py
@@ -426,6 +426,7 @@ class ImageView(QWidget, ImageDropMixin):
draw_size(p, target, ow, oh)
# }}}
+
# CoverView {{{
class RoundedPixmap(QGraphicsPixmapItem):
@@ -472,8 +473,8 @@ class CoverView(QGraphicsView, ImageDropMixin):
# }}}
-# BasicList {{{
+# BasicList {{{
class BasicListItem(QListWidgetItem):
@@ -1100,7 +1101,6 @@ class SplitterHandle(QSplitterHandle):
self.double_clicked.emit(self)
-
class PaperSizes(QComboBox): # {{{
system_default_paper_size = None
diff --git a/src/calibre/gui2/widgets2.py b/src/calibre/gui2/widgets2.py
index bc3ff90242..5667d02e3a 100644
--- a/src/calibre/gui2/widgets2.py
+++ b/src/calibre/gui2/widgets2.py
@@ -239,7 +239,6 @@ class CenteredToolButton(RightClickButton):
class Dialog(QDialog):
-
'''
An improved version of Qt's QDialog class. This automatically remembers the
last used size, automatically connects the signals for QDialogButtonBox,
@@ -876,7 +875,6 @@ class MessagePopup(QLabel):
self.move((p.width() - self.width()) // 2, self.OFFSET_FROM_TOP)
-
if __name__ == '__main__':
from calibre.gui2 import Application
app = Application([])
diff --git a/src/calibre/library/add_to_library.py b/src/calibre/library/add_to_library.py
index 8a65a62809..5b07247bc1 100644
--- a/src/calibre/library/add_to_library.py
+++ b/src/calibre/library/add_to_library.py
@@ -45,7 +45,6 @@ def find_folders_under(root, db, add_root=True, # {{{
ans.remove(root)
return ans
-
# }}}
@@ -142,7 +141,6 @@ def books_in_folder(folder, one_per_folder, # {{{
books[key].add(path)
return [FormatCollection(folder, x) for x in books.values() if x]
-
# }}}
diff --git a/src/calibre/library/caches.py b/src/calibre/library/caches.py
index afbfb5da81..3ce620f9b0 100644
--- a/src/calibre/library/caches.py
+++ b/src/calibre/library/caches.py
@@ -119,9 +119,9 @@ class MetadataBackup(Thread): # {{{
with open(path, 'wb') as f:
f.write(raw)
-
# }}}
+
# Global utility function for get_match here and in gui2/library.py
# This is a global for performance
pref_use_primary_find_in_search = False
diff --git a/src/calibre/library/catalogs/__init__.py b/src/calibre/library/catalogs/__init__.py
index c12037d7b7..f693d9a08e 100644
--- a/src/calibre/library/catalogs/__init__.py
+++ b/src/calibre/library/catalogs/__init__.py
@@ -26,4 +26,3 @@ class EmptyCatalogException(Exception):
class InvalidGenresSourceFieldException(Exception):
pass
-
diff --git a/src/calibre/library/catalogs/csv_xml.py b/src/calibre/library/catalogs/csv_xml.py
index c874c8d7d6..f123b20bbc 100644
--- a/src/calibre/library/catalogs/csv_xml.py
+++ b/src/calibre/library/catalogs/csv_xml.py
@@ -17,7 +17,6 @@ from calibre.utils.localization import _
class CSV_XML(CatalogPlugin):
-
'CSV/XML catalog generator'
Option = namedtuple('Option', 'option, default, dest, action, help')
diff --git a/src/calibre/library/catalogs/epub_mobi.py b/src/calibre/library/catalogs/epub_mobi.py
index d03b38ced2..bbf729ebf5 100644
--- a/src/calibre/library/catalogs/epub_mobi.py
+++ b/src/calibre/library/catalogs/epub_mobi.py
@@ -22,7 +22,6 @@ Option = namedtuple('Option', 'option, default, dest, action, help')
class EPUB_MOBI(CatalogPlugin):
-
'EPUB catalog generator'
name = 'Catalog_EPUB_MOBI'
diff --git a/src/calibre/library/field_metadata.py b/src/calibre/library/field_metadata.py
index c3c8a45ec8..9763044a1f 100644
--- a/src/calibre/library/field_metadata.py
+++ b/src/calibre/library/field_metadata.py
@@ -28,8 +28,8 @@ category_icon_map = {
'languages' : 'languages.png',
}
-# Builtin metadata {{{
+# Builtin metadata {{{
def _builtin_field_metadata():
# This is a function so that changing the UI language allows newly created
diff --git a/src/calibre/linux.py b/src/calibre/linux.py
index 39ec4ca80c..1cffadeb35 100644
--- a/src/calibre/linux.py
+++ b/src/calibre/linux.py
@@ -103,8 +103,8 @@ class PreserveMIMEDefaults: # {{{
raise
# }}}
-# Uninstall script {{{
+# Uninstall script {{{
UNINSTALL = '''\
#!/bin/sh
@@ -236,8 +236,8 @@ CALIBRE_LINUX_INSTALLER_HEREDOC
# }}}
-# Completion {{{
+# Completion {{{
class ZshCompleter: # {{{
diff --git a/src/calibre/prints.py b/src/calibre/prints.py
index 75f095b2ee..14120b0e3b 100644
--- a/src/calibre/prints.py
+++ b/src/calibre/prints.py
@@ -46,6 +46,7 @@ def prints(*a, **kw):
except Exception:
pass
+
def debug_print(*args, **kw):
'''
Prints debug information to the console if debugging is enabled.
diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py
index f10826adbe..29a90e97e2 100644
--- a/src/calibre/ptempfile.py
+++ b/src/calibre/ptempfile.py
@@ -157,7 +157,6 @@ def _make_dir(suffix, prefix, base):
class PersistentTemporaryFile:
-
'''
A file-like object that is a temporary file that is available even after being closed on
all platforms. It is automatically deleted on normal program termination.
@@ -208,7 +207,6 @@ def PersistentTemporaryDirectory(suffix='', prefix='', dir=None):
class TemporaryDirectory:
-
'''
A temporary directory to be used in a with statement.
'''
diff --git a/src/calibre/scraper/qt_backend.py b/src/calibre/scraper/qt_backend.py
index e48bacd157..fd97be198e 100644
--- a/src/calibre/scraper/qt_backend.py
+++ b/src/calibre/scraper/qt_backend.py
@@ -41,6 +41,7 @@ def qurl_to_key(url: QUrl | str) -> str:
Headers = list[tuple[str, str]]
+
class Request(TypedDict):
id: int
url: str
diff --git a/src/calibre/scraper/simple.py b/src/calibre/scraper/simple.py
index 1b936a4a1c..c91e601613 100644
--- a/src/calibre/scraper/simple.py
+++ b/src/calibre/scraper/simple.py
@@ -8,6 +8,7 @@ from threading import Lock
overseers = []
+
def cleanup_overseers():
browsers = tuple(filter(None, (x() for x in overseers)))
del overseers[:]
diff --git a/src/calibre/scraper/webengine_backend.py b/src/calibre/scraper/webengine_backend.py
index 230ef644e4..6200ec250a 100644
--- a/src/calibre/scraper/webengine_backend.py
+++ b/src/calibre/scraper/webengine_backend.py
@@ -43,7 +43,6 @@ def create_base_profile(cache_name='', allow_js=False):
return ans
-
class DownloadRequest(QObject):
aborted_on_timeout: bool = False
diff --git a/src/calibre/srv/ajax.py b/src/calibre/srv/ajax.py
index 7499d2cef4..40b3841b4f 100644
--- a/src/calibre/srv/ajax.py
+++ b/src/calibre/srv/ajax.py
@@ -54,8 +54,8 @@ def category_icon(category, meta): # {{{
return icon
# }}}
-# Book metadata {{{
+# Book metadata {{{
def book_to_json(ctx, rd, db, book_id,
get_category_urls=True, device_compatible=False, device_for_template=None):
@@ -233,8 +233,8 @@ def books(ctx, rd, library_id):
# }}}
-# Categories (Tag Browser) {{{
+# Categories (Tag Browser) {{{
@endpoint('/ajax/categories/{library_id=None}', postprocess=json)
def categories(ctx, rd, library_id):
@@ -526,8 +526,8 @@ def books_in(ctx, rd, encoded_category, encoded_item, library_id):
return result
# }}}
-# Search {{{
+# Search {{{
def search_result(ctx, rd, db, query, num, offset, sort, sort_order, vl=''):
multisort = [(sanitize_sort_field_name(db.field_metadata, s), ensure_val(o, 'asc', 'desc') == 'asc')
diff --git a/src/calibre/srv/auth.py b/src/calibre/srv/auth.py
index 623d40bd67..a22a60bd5e 100644
--- a/src/calibre/srv/auth.py
+++ b/src/calibre/srv/auth.py
@@ -215,7 +215,6 @@ class DigestAuth: # {{{
class AuthController:
-
'''
Implement Basic/Digest authentication for the Content server. Android browsers
cannot handle HTTP AUTH when downloading files, as the download is handed
diff --git a/src/calibre/srv/auto_reload.py b/src/calibre/srv/auto_reload.py
index dc99a0877d..658e13dbbb 100644
--- a/src/calibre/srv/auto_reload.py
+++ b/src/calibre/srv/auto_reload.py
@@ -31,8 +31,8 @@ MAX_RETRIES = 10
class NoAutoReload(EnvironmentError):
pass
-# Filesystem watcher {{{
+# Filesystem watcher {{{
class WatcherBase:
@@ -332,8 +332,8 @@ class Worker:
s.close()
self.log.error('Restarted server did not start listening on:', self.port)
-# WebSocket reload notifier {{{
+# WebSocket reload notifier {{{
class ReloadHandler(DummyHandler):
diff --git a/src/calibre/srv/content.py b/src/calibre/srv/content.py
index 761361f9a8..34a88bef35 100644
--- a/src/calibre/srv/content.py
+++ b/src/calibre/srv/content.py
@@ -529,7 +529,6 @@ def data_file(rd, fname, path, stat_result):
return rd.filesystem_file_with_custom_etag(share_open(path, 'rb'), stat_result.st_dev, stat_result.st_ino, stat_result.st_size, stat_result.st_mtime)
-
@endpoint('/data-files/get/{book_id}/{relpath}/{library_id=None}', types={'book_id': int})
def get_data_file(ctx, rd, book_id, relpath, library_id):
db = get_db(ctx, rd, library_id)
diff --git a/src/calibre/srv/http_request.py b/src/calibre/srv/http_request.py
index b0d4c54e9b..b83d6c1381 100644
--- a/src/calibre/srv/http_request.py
+++ b/src/calibre/srv/http_request.py
@@ -20,8 +20,8 @@ protocol_map = {(1, 0):HTTP1, (1, 1):HTTP11}
quoted_slash = re.compile(br'%2[fF]')
HTTP_METHODS = {'HEAD', 'GET', 'PUT', 'POST', 'TRACE', 'DELETE', 'OPTIONS'}
-# Parse URI {{{
+# Parse URI {{{
def parse_request_uri(uri):
'''Parse a Request-URI into (scheme, authority, path).
@@ -125,7 +125,6 @@ def normalize_header_name(name):
class HTTPHeaderParser:
-
'''
Parse HTTP headers. Use this class by repeatedly calling the created object
with a single line at a time and checking the finished attribute. Can raise ValueError
diff --git a/src/calibre/srv/http_response.py b/src/calibre/srv/http_response.py
index 81fdf0aed4..97b6ec910e 100644
--- a/src/calibre/srv/http_response.py
+++ b/src/calibre/srv/http_response.py
@@ -153,8 +153,8 @@ def get_ranges(headervalue, content_length): # {{{
return result
# }}}
-# gzip transfer encoding {{{
+# gzip transfer encoding {{{
def gzip_prefix():
# See http://www.gzip.org/zlib/rfc-gzip.html
diff --git a/src/calibre/srv/legacy.py b/src/calibre/srv/legacy.py
index 744317a8dc..38a6d7e423 100644
--- a/src/calibre/srv/legacy.py
+++ b/src/calibre/srv/legacy.py
@@ -118,7 +118,6 @@ def build_navigation(start, num, total, url_base): # {{{
E.tr(left_buttons, right_buttons),
class_='buttons')
return E.div(tagline, buttons, class_='navigation')
-
# }}}
diff --git a/src/calibre/srv/metadata.py b/src/calibre/srv/metadata.py
index 14c1a4fb37..2ab6fe2a9f 100644
--- a/src/calibre/srv/metadata.py
+++ b/src/calibre/srv/metadata.py
@@ -157,7 +157,6 @@ def category_item_as_json(x, clear_rating=False):
return ans
-
def get_gpref(name: str, defval = None):
gprefs = getattr(get_gpref, 'gprefs', None)
if gprefs is None:
@@ -619,8 +618,8 @@ def render_categories(opts, db, category_data):
def categories_as_json(ctx, rd, db, opts, vl):
return ctx.get_tag_browser(rd, db, opts, partial(render_categories, opts), vl=vl)
-# Test tag browser {{{
+# Test tag browser {{{
def dump_categories_tree(data):
root, items = data['root'], data['item_map']
diff --git a/src/calibre/srv/opds.py b/src/calibre/srv/opds.py
index 295780f78d..11c39df191 100644
--- a/src/calibre/srv/opds.py
+++ b/src/calibre/srv/opds.py
@@ -240,9 +240,9 @@ def ACQUISITION_ENTRY(book_id, updated, request_context):
return ans
-
# }}}
+
default_feed_title = __appname__ + ' ' + _('Library')
diff --git a/src/calibre/srv/render_book.py b/src/calibre/srv/render_book.py
index 9a6a38a6d5..e3d10a6a85 100644
--- a/src/calibre/srv/render_book.py
+++ b/src/calibre/srv/render_book.py
@@ -327,7 +327,6 @@ def parse_smil_time(x):
return seconds
-
def transform_smil(container, name, link_uid, virtualize_resources, virtualized_names, smil_map):
root = container.parsed(name)
text_tag, audio_tag = SMIL('text'), SMIL('audio')
@@ -588,7 +587,6 @@ def process_exploded_book(
def needs_work(mt):
return mt in OEB_STYLES or mt in OEB_DOCS or mt in ('image/svg+xml', 'application/smil', 'application/smil+xml')
-
bookmark_data = None
if save_bookmark_data:
bm_file = 'META-INF/calibre_bookmarks.txt'
diff --git a/src/calibre/srv/standalone.py b/src/calibre/srv/standalone.py
index 69c78b44cf..255f5f10b3 100644
--- a/src/calibre/srv/standalone.py
+++ b/src/calibre/srv/standalone.py
@@ -51,8 +51,6 @@ def daemonize(): # {{{
# Redirect standard file descriptors.
speedup.detach(os.devnull)
-
-
# }}}
diff --git a/src/calibre/srv/utils.py b/src/calibre/srv/utils.py
index 36be98ecfb..cdc8c291df 100644
--- a/src/calibre/srv/utils.py
+++ b/src/calibre/srv/utils.py
@@ -265,8 +265,8 @@ class Cookie(SimpleCookie):
def custom_fields_to_display(db):
return frozenset(db.field_metadata.ignorable_field_keys())
-# Logging {{{
+# Logging {{{
class ServerLog(ThreadSafeLog):
exception_traceback_level = ThreadSafeLog.WARN
diff --git a/src/calibre/srv/web_socket.py b/src/calibre/srv/web_socket.py
index 50163aec67..c136bea0a6 100644
--- a/src/calibre/srv/web_socket.py
+++ b/src/calibre/srv/web_socket.py
@@ -172,8 +172,8 @@ class ReadFrame: # {{{
# }}}
-# Sending frames {{{
+# Sending frames {{{
def create_frame(fin, opcode, payload, mask=None, rsv=0):
if isinstance(payload, str):
@@ -525,11 +525,10 @@ class DummyHandler:
def handle_websocket_close(self, connection_id):
pass
+
# Testing {{{
-# Run this file with calibre-debug and use wstest to run the Autobahn test
-# suite
-
+# Run this file with calibre-debug and use wstest to run the Autobahn test suite
class EchoHandler:
diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py
index c917115a75..0068066a06 100644
--- a/src/calibre/utils/config.py
+++ b/src/calibre/utils/config.py
@@ -302,7 +302,6 @@ dynamic = DynamicConfig()
class XMLConfig(dict):
-
'''
Similar to :class:`DynamicConfig`, except that it uses an XML storage
backend instead of a pickle file.
diff --git a/src/calibre/utils/config_base.py b/src/calibre/utils/config_base.py
index cfb9101159..5d06ef11cd 100644
--- a/src/calibre/utils/config_base.py
+++ b/src/calibre/utils/config_base.py
@@ -603,8 +603,8 @@ if prefs['installation_uuid'] is None:
import uuid
prefs['installation_uuid'] = str(uuid.uuid4())
-# Read tweaks
+# Read tweaks
def tweaks_file():
return os.path.join(config_dir, 'tweaks.json')
diff --git a/src/calibre/utils/copy_files.py b/src/calibre/utils/copy_files.py
index 346c1a8520..87e392e755 100644
--- a/src/calibre/utils/copy_files.py
+++ b/src/calibre/utils/copy_files.py
@@ -18,6 +18,7 @@ if iswindows:
WINDOWS_SLEEP_FOR_RETRY_TIME = 2 # seconds
WindowsFileId = tuple[int, int, int]
+
class UnixFileCopier:
def __init__(self, delete_all=False, allow_move=False):
@@ -73,7 +74,6 @@ def windows_lock_path_and_callback(path: str, f: Callable) -> None:
class WindowsFileCopier:
-
'''
Locks all files before starting the copy, ensuring other processes cannot interfere
'''
diff --git a/src/calibre/utils/copy_files_test.py b/src/calibre/utils/copy_files_test.py
index 6e26eb71cb..0100d2d8c1 100644
--- a/src/calibre/utils/copy_files_test.py
+++ b/src/calibre/utils/copy_files_test.py
@@ -119,5 +119,6 @@ class TestCopyFiles(unittest.TestCase):
self.assertFalse(tuple(walk(self.d())))
self.ae(before, frozenset(walk(src)), 'Source files were deleted despite there being an error')
+
def find_tests():
return unittest.defaultTestLoader.loadTestsFromTestCase(TestCopyFiles)
diff --git a/src/calibre/utils/date.py b/src/calibre/utils/date.py
index 60a52aac5b..8100e4ad9b 100644
--- a/src/calibre/utils/date.py
+++ b/src/calibre/utils/date.py
@@ -285,8 +285,8 @@ def utcfromtimestamp(stamp):
def timestampfromdt(dt, assume_utc=True):
return (as_utc(dt, assume_utc=assume_utc) - EPOCH).total_seconds()
-# Format date functions {{{
+# Format date functions {{{
def fd_format_hour(dt, ampm, hr):
l = len(hr)
@@ -389,8 +389,8 @@ def format_date(dt, format, assume_utc=False, as_utc=False):
# }}}
-# Clean date functions {{{
+# Clean date functions {{{
def cd_has_hour(tt, dt):
tt['hour'] = dt.hour
diff --git a/src/calibre/utils/exim.py b/src/calibre/utils/exim.py
index 4e12dde715..25a1ec73dc 100644
--- a/src/calibre/utils/exim.py
+++ b/src/calibre/utils/exim.py
@@ -27,6 +27,7 @@ from polyglot.builtins import error_message, iteritems
# Export {{{
+
class FileDest:
def __init__(self, key, exporter, mtime=None):
@@ -223,6 +224,7 @@ def export(destdir, library_paths=None, dbmap=None, progress1=None, progress2=No
progress1(_('Completed'), total, total)
# }}}
+
# Import {{{
class Chunk(NamedTuple):
diff --git a/src/calibre/utils/ffml_processor.py b/src/calibre/utils/ffml_processor.py
index 56fbf8682a..f8643ad1dc 100644
--- a/src/calibre/utils/ffml_processor.py
+++ b/src/calibre/utils/ffml_processor.py
@@ -12,6 +12,7 @@ from calibre import prepare_string_for_xml
# This must be something that will never naturally occur in documentation
MARKUP_ERROR = '*' + _('Template documentation markup error') + '*:'
+
@unique
class NodeKinds(IntEnum):
@@ -176,7 +177,6 @@ class UrlNode(Node):
return prepare_string_for_xml(self._url)
-
class FFMLProcessor:
r'''
This class is parser for the Formatter Function Markup Language (FFML). It
diff --git a/src/calibre/utils/file_type_icons.py b/src/calibre/utils/file_type_icons.py
index 0946ff9bf6..b4b52d811d 100644
--- a/src/calibre/utils/file_type_icons.py
+++ b/src/calibre/utils/file_type_icons.py
@@ -52,6 +52,3 @@ EXT_MAP = {
'docx' : 'docx',
'opml' : 'opml',
}
-
-
-
diff --git a/src/calibre/utils/filenames.py b/src/calibre/utils/filenames.py
index 6a4d4c74d1..c26ce1b627 100644
--- a/src/calibre/utils/filenames.py
+++ b/src/calibre/utils/filenames.py
@@ -359,7 +359,6 @@ def windows_nlinks(path):
class WindowsAtomicFolderMove:
-
'''
Move all the files inside a specified folder in an atomic fashion,
preventing any other process from locking a file while the operation is
diff --git a/src/calibre/utils/fonts/scanner.py b/src/calibre/utils/fonts/scanner.py
index bfdc27e40d..c1dccb809a 100644
--- a/src/calibre/utils/fonts/scanner.py
+++ b/src/calibre/utils/fonts/scanner.py
@@ -21,8 +21,8 @@ from polyglot.builtins import itervalues
class NoFonts(ValueError):
pass
-# Font dirs {{{
+# Font dirs {{{
def default_font_dirs():
return [
@@ -123,8 +123,8 @@ def font_dirs():
return fc_list()
# }}}
-# Build font family maps {{{
+# Build font family maps {{{
def font_priority(font):
'''
diff --git a/src/calibre/utils/fonts/sfnt/__init__.py b/src/calibre/utils/fonts/sfnt/__init__.py
index 2aee477c14..2375c60053 100644
--- a/src/calibre/utils/fonts/sfnt/__init__.py
+++ b/src/calibre/utils/fonts/sfnt/__init__.py
@@ -76,4 +76,3 @@ def load_font(stream_or_path):
raw = raw.read()
from calibre.utils.fonts.sfnt.container import Sfnt
return Sfnt(raw)
-
diff --git a/src/calibre/utils/fonts/sfnt/cff/__init__.py b/src/calibre/utils/fonts/sfnt/cff/__init__.py
index fba7748a38..c555cf1377 100644
--- a/src/calibre/utils/fonts/sfnt/cff/__init__.py
+++ b/src/calibre/utils/fonts/sfnt/cff/__init__.py
@@ -4,6 +4,3 @@
__license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
-
-
diff --git a/src/calibre/utils/fonts/sfnt/cff/constants.py b/src/calibre/utils/fonts/sfnt/cff/constants.py
index d43bdda9c9..5b80094a04 100644
--- a/src/calibre/utils/fonts/sfnt/cff/constants.py
+++ b/src/calibre/utils/fonts/sfnt/cff/constants.py
@@ -5,7 +5,6 @@ __license__ = 'GPL v3'
__copyright__ = '2012, Kovid Goyal '
__docformat__ = 'restructuredtext en'
-
# cff_standard_strings {{{
# The 391 Standard Strings as used in the CFF format.
# from Adobe Technical None #5176, version 1.0, 18 March 1998
@@ -77,7 +76,6 @@ cff_standard_strings = [
]
# }}}
-
STANDARD_CHARSETS = [ # {{{
# ISOAdobe
('.notdef', 'space', 'exclam', 'quotedbl', 'numbersign', 'dollar',
@@ -178,4 +176,3 @@ STANDARD_CHARSETS = [ # {{{
'seveninferior', 'eightinferior', 'nineinferior', 'centinferior',
'dollarinferior', 'periodinferior', 'commainferior'),
] # }}}
-
diff --git a/src/calibre/utils/fonts/sfnt/common.py b/src/calibre/utils/fonts/sfnt/common.py
index 8fd02a03a2..636f074005 100644
--- a/src/calibre/utils/fonts/sfnt/common.py
+++ b/src/calibre/utils/fonts/sfnt/common.py
@@ -28,7 +28,6 @@ class Unpackable:
class SimpleListTable(list):
-
'A table that contains a list of subtables'
child_class = None
@@ -53,7 +52,6 @@ class SimpleListTable(list):
class ListTable(OrderedDict):
-
'A table that contains an ordered mapping of table tag to subtable'
child_class = None
diff --git a/src/calibre/utils/fonts/sfnt/errors.py b/src/calibre/utils/fonts/sfnt/errors.py
index b74af2351c..909637bfcd 100644
--- a/src/calibre/utils/fonts/sfnt/errors.py
+++ b/src/calibre/utils/fonts/sfnt/errors.py
@@ -12,4 +12,3 @@ class UnsupportedFont(ValueError):
class NoGlyphs(ValueError):
pass
-
diff --git a/src/calibre/utils/fonts/sfnt/metrics.py b/src/calibre/utils/fonts/sfnt/metrics.py
index 5207c57480..3abd4548f2 100644
--- a/src/calibre/utils/fonts/sfnt/metrics.py
+++ b/src/calibre/utils/fonts/sfnt/metrics.py
@@ -10,7 +10,6 @@ from calibre.utils.fonts.utils import get_all_font_names
class FontMetrics:
-
'''
Get various metrics for the specified sfnt. All the metrics are returned in
units of pixels. To calculate a metric you have to specify the font size
diff --git a/src/calibre/utils/fonts/sfnt/subset.py b/src/calibre/utils/fonts/sfnt/subset.py
index 214ca7d2bd..3d2ff5f66e 100644
--- a/src/calibre/utils/fonts/sfnt/subset.py
+++ b/src/calibre/utils/fonts/sfnt/subset.py
@@ -193,8 +193,8 @@ def subset(raw, individual_chars, ranges=(), warnings=None):
raw, new_sizes = sfnt()
return raw, old_sizes, new_sizes
-# CLI {{{
+# CLI {{{
def option_parser():
import textwrap
@@ -307,8 +307,8 @@ if __name__ == '__main__':
main(sys.argv)
# }}}
-# Tests {{{
+# Tests {{{
def test_mem():
import gc
@@ -385,5 +385,4 @@ def all():
print('Total:', total, 'Unsupported:', len(unsupported), 'Failed:',
len(failed), 'Warnings:', len(warnings))
-
# }}}
diff --git a/src/calibre/utils/formatter_functions.py b/src/calibre/utils/formatter_functions.py
index 6aa2b072c4..fc792ab55a 100644
--- a/src/calibre/utils/formatter_functions.py
+++ b/src/calibre/utils/formatter_functions.py
@@ -1268,7 +1268,6 @@ the :ref:`select` function to get the modification time for a specific format. N
that format names are always uppercase, as in EPUB.
''')
-
def evaluate(self, formatter, kwargs, mi, locals, fmt):
fmt_data = mi.get('format_metadata', {})
try:
@@ -2535,7 +2534,6 @@ on a device has its own device name. The ``storage_location_key`` names are
``'main'``, ``'carda'`` and ``'cardb'``. This function works only in the GUI.
''')
-
def evaluate(self, formatter, kwargs, mi, locals, storage_location):
# We can't use get_database() here because we need the device manager.
# In other words, the function really does need the GUI
diff --git a/src/calibre/utils/img.py b/src/calibre/utils/img.py
index dc20adebe2..d80d35cf89 100644
--- a/src/calibre/utils/img.py
+++ b/src/calibre/utils/img.py
@@ -63,8 +63,8 @@ def load_jxr_data(data):
# }}}
-# png <-> gif {{{
+# png <-> gif {{{
def png_data_to_gif_data(data):
from PIL import Image
@@ -103,8 +103,8 @@ def gif_data_to_png_data(data, discard_animation=False):
# }}}
-# Loading images {{{
+# Loading images {{{
def set_image_allocation_limit(size_in_mb=1024):
with suppress(ImportError): # for people running form source
@@ -162,8 +162,8 @@ def image_and_format_from_data(data):
return r.read(), fmt
# }}}
-# Saving images {{{
+# Saving images {{{
def image_to_data(img, compression_quality=95, fmt='JPEG', png_compression_level=9, jpeg_optimized=True, jpeg_progressive=False):
'''
@@ -302,8 +302,8 @@ def save_cover_data_to(
f.write(image_to_data(img, compression_quality, fmt, compression_quality // 10) if changed else data)
# }}}
-# Overlaying images {{{
+# Overlaying images {{{
def blend_on_canvas(img, width, height, bgcolor='#ffffff'):
' Blend the `img` onto a canvas with the specified background color and size '
@@ -370,8 +370,8 @@ def blend_image(img, bgcolor='#ffffff'):
return canvas
# }}}
-# Image borders {{{
+# Image borders {{{
def add_borders_to_image(img, left=0, top=0, right=0, bottom=0, border_color='#ffffff'):
img = image_from_data(img)
@@ -394,8 +394,8 @@ def remove_borders_from_image(img, fuzz=None):
return ans if ans.size() != img.size() else img
# }}}
-# Cropping/scaling of images {{{
+# Cropping/scaling of images {{{
def resize_image(img, width, height):
return img.scaled(int(width), int(height), Qt.AspectRatioMode.IgnoreAspectRatio, Qt.TransformationMode.SmoothTransformation)
@@ -450,8 +450,8 @@ def crop_image(img, x, y, width, height):
# }}}
-# Image transformations {{{
+# Image transformations {{{
def grayscale_image(img):
return imageops.grayscale(image_from_data(img))
@@ -536,8 +536,8 @@ def eink_dither_image(img):
# }}}
-# Optimization of images {{{
+# Optimization of images {{{
def run_optimizer(file_path, cmd, as_filter=False, input_data=None):
file_path = os.path.abspath(file_path)
@@ -660,8 +660,10 @@ def encode_jpeg(file_path, quality=80):
def encode_webp(file_path, quality=75, m=6, metadata='all'):
return run_cwebp(file_path, False, quality, m, metadata)
+
# }}}
+
# PIL images {{{
def align8to32(bytes, width, mode):
'''
@@ -794,6 +796,7 @@ def read_alt_text(pil_im_or_path, target_lang='') -> str:
# }}}
+
def test(): # {{{
from glob import glob
diff --git a/src/calibre/utils/logging.py b/src/calibre/utils/logging.py
index 059b1e2fdb..e008e30fc0 100644
--- a/src/calibre/utils/logging.py
+++ b/src/calibre/utils/logging.py
@@ -245,7 +245,6 @@ class ThreadSafeWrapper(Log):
class GUILog(ThreadSafeLog):
-
'''
Logs in HTML and plain text as unicode. Ideal for display in a GUI context.
'''
diff --git a/src/calibre/utils/matcher.py b/src/calibre/utils/matcher.py
index 35097adedd..9a76773c94 100644
--- a/src/calibre/utils/matcher.py
+++ b/src/calibre/utils/matcher.py
@@ -167,7 +167,6 @@ class FilesystemMatcher(Matcher):
# Python implementation of the scoring algorithm {{{
-
def calc_score_for_char(ctx, prev, current, distance):
factor = 1.0
ans = ctx.max_score_per_char
@@ -251,7 +250,6 @@ class PyScorer:
self.memory = {}
yield process_item(self, item, needle)
-
# }}}
diff --git a/src/calibre/utils/network.py b/src/calibre/utils/network.py
index d93e98f736..0fd399039a 100644
--- a/src/calibre/utils/network.py
+++ b/src/calibre/utils/network.py
@@ -109,6 +109,7 @@ def internet_connected():
return internet_connected.checker()
+
def is_ipv6_addr(addr):
import socket
try:
diff --git a/src/calibre/utils/open_with/osx.py b/src/calibre/utils/open_with/osx.py
index 5adae681d8..1e56705a70 100644
--- a/src/calibre/utils/open_with/osx.py
+++ b/src/calibre/utils/open_with/osx.py
@@ -17,8 +17,8 @@ from polyglot.builtins import iteritems, string_or_bytes
application_locations = ('/Applications', '~/Applications', '~/Desktop')
-# Public UTI MAP {{{
+# Public UTI MAP {{{
def generate_public_uti_map():
from html5_parser import parse
diff --git a/src/calibre/utils/ordered_dict.py b/src/calibre/utils/ordered_dict.py
index d11fc6cda0..00bf5e2d9d 100644
--- a/src/calibre/utils/ordered_dict.py
+++ b/src/calibre/utils/ordered_dict.py
@@ -9,4 +9,3 @@ __docformat__ = 'restructuredtext en'
from collections import OrderedDict
OrderedDict
-
diff --git a/src/calibre/utils/podofo/__init__.py b/src/calibre/utils/podofo/__init__.py
index 28c168d57f..33de681772 100644
--- a/src/calibre/utils/podofo/__init__.py
+++ b/src/calibre/utils/podofo/__init__.py
@@ -267,6 +267,5 @@ def develop(path=sys.argv[-1]):
p.title = 'test'
-
if __name__ == '__main__':
develop()
diff --git a/src/calibre/utils/rapydscript.py b/src/calibre/utils/rapydscript.py
index 2d76214f7d..223423eee2 100644
--- a/src/calibre/utils/rapydscript.py
+++ b/src/calibre/utils/rapydscript.py
@@ -32,8 +32,8 @@ COMPILER_PATH = 'rapydscript/compiler.js.xz'
def abspath(x):
return os.path.realpath(os.path.abspath(x))
-# Update RapydScript {{{
+# Update RapydScript {{{
def update_rapydscript():
import lzma
@@ -49,8 +49,8 @@ def update_rapydscript():
f.write(raw)
# }}}
-# Compiler {{{
+# Compiler {{{
def to_dict(obj):
return dict(zip(list(obj.keys()), list(obj.values())))
@@ -508,8 +508,8 @@ def compile_srv():
# }}}
-# Translations {{{
+# Translations {{{
def create_pot(source_files):
c = compiler()
diff --git a/src/calibre/utils/seven_zip.py b/src/calibre/utils/seven_zip.py
index 29263daf3f..044de4d661 100644
--- a/src/calibre/utils/seven_zip.py
+++ b/src/calibre/utils/seven_zip.py
@@ -52,7 +52,6 @@ def extract(path_or_stream, location):
# Test {{{
-
def test_basic():
from tempfile import TemporaryDirectory
diff --git a/src/calibre/utils/smartypants.py b/src/calibre/utils/smartypants.py
index e2cf4d46a3..cf943d2cf9 100644
--- a/src/calibre/utils/smartypants.py
+++ b/src/calibre/utils/smartypants.py
@@ -877,7 +877,6 @@ def run_tests(return_tests=False):
self.assertEqual(sp('''"Isn't this fun?"'''), '''“Isn’t this fun?”''')
self.assertEqual(sp("'abc'"), '‘abc’')
-
tests = unittest.defaultTestLoader.loadTestsFromTestCase(TestSmartypantsAllAttributes)
if return_tests:
return tests
diff --git a/src/calibre/utils/speedups.py b/src/calibre/utils/speedups.py
index ae6672ea76..bc35265b89 100644
--- a/src/calibre/utils/speedups.py
+++ b/src/calibre/utils/speedups.py
@@ -6,7 +6,6 @@ import os
class ReadOnlyFileBuffer:
-
''' A zero copy implementation of a file like object. Uses memoryviews for efficiency. '''
def __init__(self, raw: bytes, name: str = ''):
diff --git a/src/calibre/utils/spell/__init__.py b/src/calibre/utils/spell/__init__.py
index 0cbf055ec8..fb2e4b74e1 100644
--- a/src/calibre/utils/spell/__init__.py
+++ b/src/calibre/utils/spell/__init__.py
@@ -3,6 +3,3 @@
__license__ = 'GPL v3'
__copyright__ = '2013, Kovid Goyal '
-
-
-
diff --git a/src/calibre/utils/terminal.py b/src/calibre/utils/terminal.py
index b3c87c0d23..46eae7f030 100644
--- a/src/calibre/utils/terminal.py
+++ b/src/calibre/utils/terminal.py
@@ -196,7 +196,6 @@ def windows_terminfo():
from ctypes.wintypes import SHORT, WORD
class COORD(Structure):
-
'''struct in wincon.h'''
_fields_ = [
('X', SHORT),
@@ -204,7 +203,6 @@ def windows_terminfo():
]
class SMALL_RECT(Structure):
-
'''struct in wincon.h.'''
_fields_ = [
('Left', SHORT),
@@ -214,7 +212,6 @@ def windows_terminfo():
]
class CONSOLE_SCREEN_BUFFER_INFO(Structure):
-
'''struct in wincon.h.'''
_fields_ = [
('dwSize', COORD),
diff --git a/src/calibre/utils/threadpool.py b/src/calibre/utils/threadpool.py
index 4dffda8ff8..85a89ce1cb 100644
--- a/src/calibre/utils/threadpool.py
+++ b/src/calibre/utils/threadpool.py
@@ -62,8 +62,8 @@ class NoWorkersAvailable(Exception):
'''No worker threads available to process remaining requests.'''
pass
-# classes
+# classes
class WorkerThread(threading.Thread):
'''Background thread connected to the requests/results queues.
@@ -235,8 +235,8 @@ class ThreadPool:
except NoResultsPending:
break
-# helper functions
+# helper functions
def makeRequests(callable, args_list, callback=None, exc_callback=None):
'''Create several work requests for same callable with different arguments.
@@ -267,11 +267,11 @@ def makeRequests(callable, args_list, callback=None, exc_callback=None):
)
return requests
+
################
# USAGE EXAMPLE
################
-
if __name__ == '__main__':
import random
import time
diff --git a/src/calibre/utils/unrar.py b/src/calibre/utils/unrar.py
index 1ecf2d836b..b68533a202 100644
--- a/src/calibre/utils/unrar.py
+++ b/src/calibre/utils/unrar.py
@@ -120,7 +120,6 @@ def extract_cover_image(stream):
# Test normal RAR file {{{
-
def test_basic():
stream = BytesIO(b"Rar!\x1a\x07\x00\xcf\x90s\x00\x00\r\x00\x00\x00\x00\x00\x00\x00\x14\xe7z\x00\x80#\x00\x17\x00\x00\x00\r\x00\x00\x00\x03\xc2\xb3\x96o\x00\x00\x00\x00\x1d3\x03\x00\x00\x00\x00\x00CMT\x0c\x00\x8b\xec\x8e\xef\x14\xf6\xe6h\x04\x17\xff\xcd\x0f\xffk9b\x11]^\x80\xd3dt \x90+\x00\x14\x00\x00\x00\x08\x00\x00\x00\x03\xf1\x84\x93\\\xb9]yA\x1d3\t\x00\xa4\x81\x00\x001\\sub-one\x00\xc0\x0c\x00\x8f\xec\x89\xfe.JM\x86\x82\x0c_\xfd\xfd\xd7\x11\x1a\xef@\x9eHt \x80'\x00\x0e\x00\x00\x00\x04\x00\x00\x00\x03\x9f\xa8\x17\xf8\xaf]yA\x1d3\x07\x00\xa4\x81\x00\x00one.txt\x00\x08\xbf\x08\xae\xf3\xca\x87\xfeo\xfe\xd2n\x80-Ht \x82:\x00\x18\x00\x00\x00\x10\x00\x00\x00\x03\xa86\x81\xdf\xf9fyA\x1d3\x1a\x00\xa4\x81\x00\x00\xe8\xaf\xb6\xe6\xaf\x94\xe5\xb1\x81.txt\x00\x8bh\xf6\xd4kA\\.\x00txt\x0c\x00\x8b\xec\x8e\xef\x14\xf6\xe2l\x91\x189\xff\xdf\xfe\xc2\xd3:g\x9a\x19F=cYt \x928\x00\x11\x00\x00\x00\x08\x00\x00\x00\x03\x7f\xd6\xb6\x7f\xeafyA\x1d3\x16\x00\xa4\x81\x00\x00F\xc3\xbc\xc3\x9fe.txt\x00\x01\x00F\xfc\xdfe\x00.txt\x00\xc0 0xffff:
@@ -310,7 +308,6 @@ def _EndRecData(fpin):
class ZipInfo :
-
'''Class with attributes describing each file in the ZIP archive.'''
__slots__ = (
@@ -457,7 +454,6 @@ class ZipInfo :
class _ZipDecrypter:
-
'''Class to handle decryption of files stored within a ZIP archive.
ZIP supports a password-based form of encryption. Even though known
@@ -516,7 +512,6 @@ class _ZipDecrypter:
class ZipExtFile(io.BufferedIOBase):
-
'''File-like object for reading an archive member.
Is returned by ZipFile.open().
'''
@@ -720,7 +715,6 @@ class ZipExtFile(io.BufferedIOBase):
class ZipFile:
-
''' Class with methods to open, read, write, close, list and update zip files.
z = ZipFile(file, mode="r", compression=ZIP_STORED, allowZip64=False)
@@ -1534,7 +1528,6 @@ def safe_replace(zipstream, name, datastream, extra_replacements={},
class PyZipFile(ZipFile):
-
'''Class to create ZIP archives with Python library files and packages.'''
def writepy(self, pathname, basename=''):
diff --git a/src/calibre/web/feeds/recipes/collection.py b/src/calibre/web/feeds/recipes/collection.py
index c854376bae..9f211c08c2 100644
--- a/src/calibre/web/feeds/recipes/collection.py
+++ b/src/calibre/web/feeds/recipes/collection.py
@@ -58,7 +58,6 @@ def normalize_language(x: str) -> str:
def serialize_recipe(urn, recipe_class):
from xml.sax.saxutils import quoteattr
-
def attr(n, d, normalize=lambda x: x):
ans = getattr(recipe_class, n, d)
if isinstance(ans, bytes):
diff --git a/src/calibre/web/feeds/templates.py b/src/calibre/web/feeds/templates.py
index e4a8af5257..ec4fb22300 100644
--- a/src/calibre/web/feeds/templates.py
+++ b/src/calibre/web/feeds/templates.py
@@ -23,8 +23,8 @@ def attrs(*args, **kw):
kw['class'] = ' '.join(args)
return kw
-# Regular templates
+# Regular templates
class Template:
diff --git a/src/calibre/web/fetch/simple.py b/src/calibre/web/fetch/simple.py
index 86ba934c50..f740dbfe95 100644
--- a/src/calibre/web/fetch/simple.py
+++ b/src/calibre/web/fetch/simple.py
@@ -43,7 +43,6 @@ class FetchError(Exception):
class closing:
-
'Context to automatically close something at the end of a block.'
def __init__(self, thing):
diff --git a/src/calibre/web/site_parsers/natgeo.py b/src/calibre/web/site_parsers/natgeo.py
index 88a2dcb3f5..b767f721ae 100644
--- a/src/calibre/web/site_parsers/natgeo.py
+++ b/src/calibre/web/site_parsers/natgeo.py
@@ -105,6 +105,7 @@ def parse_body(x):
if isinstance(y, dict):
yield from parse_body(y)
+
def parse_bdy(item):
c = item['cntnt']
if item.get('type') == 'inline':
@@ -130,6 +131,7 @@ def parse_bdy(item):
yield '<{tag}>{markup}{tag}>'.format(
tag=item['type'], markup=c['mrkup'])
+
def parse_article(edg):
sc = edg['schma']
yield '' + escape(edg['sctn']) + '
'
diff --git a/src/odf/attrconverters.py b/src/odf/attrconverters.py
index 5fcb15d69f..a3874151ad 100644
--- a/src/odf/attrconverters.py
+++ b/src/odf/attrconverters.py
@@ -65,8 +65,8 @@ def cnv_boolean(attribute, arg, element):
return 'true'
return 'false'
-# Potentially accept color values
+# Potentially accept color values
def cnv_color(attribute, arg, element):
''' A RGB color in conformance with §5.9.11 of [XSL], that is a RGB color in notation “#rrggbb”, where
@@ -87,8 +87,8 @@ def cnv_data_source_has_labels(attribute, arg, element):
raise ValueError(f"'{unicode_type(arg)}' not allowed")
return unicode_type(arg)
-# Understand different date formats
+# Understand different date formats
def cnv_date(attribute, arg, element):
''' A dateOrDateTime value is either an [xmlschema-2] date value or an [xmlschema-2] dateTime
@@ -241,8 +241,8 @@ def cnv_DrawNameRef(attribute, arg, element):
except:
return arg
-# Must accept list of Style objects
+# Must accept list of Style objects
def cnv_NCNames(attribute, arg, element):
return ' '.join(arg)
@@ -294,8 +294,8 @@ def cnv_textnoteclass(attribute, arg, element):
raise ValueError(f"'{unicode_type(arg)}' not allowed")
return unicode_type(arg)
-# Understand different time formats
+# Understand different time formats
def cnv_time(attribute, arg, element):
return unicode_type(arg)
diff --git a/src/odf/element.py b/src/odf/element.py
index 99b4ade679..14794d21fa 100644
--- a/src/odf/element.py
+++ b/src/odf/element.py
@@ -87,8 +87,8 @@ def _nssplit(qualifiedName):
def _nsassign(namespace):
return nsdict.setdefault(namespace,'ns' + unicode_type(len(nsdict)))
-# Exceptions
+# Exceptions
class IllegalChild(Exception):
''' Complains if you add an element to a parent where it is not allowed '''
diff --git a/src/odf/odf2xhtml.py b/src/odf/odf2xhtml.py
index 6c3afa678a..d70702b8f1 100644
--- a/src/odf/odf2xhtml.py
+++ b/src/odf/odf2xhtml.py
@@ -77,7 +77,6 @@ if False: # Added by Kovid
class StyleToCSS:
-
''' The purpose of the StyleToCSS class is to contain the rules to convert
ODF styles to CSS2. Since it needs the generic fonts, it would probably
make sense to also contain the Styles in a dict as well..
@@ -378,7 +377,6 @@ special_styles = {
class ODF2XHTML(handler.ContentHandler):
-
''' The ODF2XHTML parses an ODF file and produces XHTML'''
def __init__(self, generate_css=True, embedable=False):
@@ -1665,7 +1663,6 @@ dl.notes dd:last-of-type { page-break-after: avoid }
class ODF2XHTMLembedded(ODF2XHTML):
-
''' The ODF2XHTML parses an ODF file and produces XHTML'''
def __init__(self, lines, generate_css=True, embedable=False):
diff --git a/src/odf/opendocument.py b/src/odf/opendocument.py
index 6d1365b90f..383d7bf95b 100644
--- a/src/odf/opendocument.py
+++ b/src/odf/opendocument.py
@@ -560,8 +560,8 @@ class OpenDocument:
self.rebuild_caches()
return self.element_dict.get(obj.qname, [])
-# Convenience functions
+# Convenience functions
def OpenDocumentChart():
''' Creates a chart document '''