The problem seems to come from the test in test_navpoint_for_removal(), in container.py:
link_path.lower() is tested against each dict.key, but link_path is only a substring of the key, so it fails.
I've ran this code (modifying delete_broken_toc_links()):
Code:
print(f'html_names_map {html_names_map}')
def test_navpoint_for_removal(navpoint):
src = navpoint.xpath('ncx:content/@src', namespaces={'ncx':NCX_NS})
print(f'\nnavpoint {navpoint}\nsrc {src}')
if len(src):
src = urlunquote(src[0]).partition('#')[0]
link_path = self.abshref(src, self.ncx_name)
if link_path.lower() not in html_names_map:
self.log('\t TOC Navpoint broken to remove of:', src)
print('link_path {} | link_path in html_names_map: {}, lowered: {}'.format(link_path, link_path in html_names_map, link_path.lower() in html_names_map))
return True
return False
which gives this log:
Spoiler:
Quote:
Modify ePubs version (1, 7, 0)
Logfile for book ID 594 (Nana / Émile Zola)
Job details 594
Modifying: /tmp/calibre_5.99.8_tmp_fc8ryo62/cx_qk4o0_modify_epub/594.epub
Parsing xml file: Ops/content.opf
Parsing xml file: Ops/toc.ncx
Looking for broken links in the NCX
html_names_map {
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/16.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/11.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/14.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/8.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/12.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/1.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/3.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/7.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/2.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/10.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/4.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/15.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/9.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/5.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/13.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/17.html': True
'/tmp/calibre_5.99.8_tmp_fc8ryo62/ops/6.html': True
}
navpoint
src ['1.html']
TOC Navpoint broken to remove of: 1.html
link_path Ops/1.html | link_path in html_names_map: False, lowered: False
navpoint
src ['3.html']
TOC Navpoint broken to remove of: 3.html
link_path Ops/3.html | link_path in html_names_map: False, lowered: False
navpoint
src ['4.html']
TOC Navpoint broken to remove of: 4.html
link_path Ops/4.html | link_path in html_names_map: False, lowered: False
navpoint
src ['5.html']
TOC Navpoint broken to remove of: 5.html
link_path Ops/5.html | link_path in html_names_map: False, lowered: False
navpoint
src ['6.html']
TOC Navpoint broken to remove of: 6.html
link_path Ops/6.html | link_path in html_names_map: False, lowered: False
navpoint
src ['7.html']
TOC Navpoint broken to remove of: 7.html
link_path Ops/7.html | link_path in html_names_map: False, lowered: False
navpoint
src ['8.html']
TOC Navpoint broken to remove of: 8.html
link_path Ops/8.html | link_path in html_names_map: False, lowered: False
navpoint
src ['9.html']
TOC Navpoint broken to remove of: 9.html
link_path Ops/9.html | link_path in html_names_map: False, lowered: False
navpoint
src ['10.html']
TOC Navpoint broken to remove of: 10.html
link_path Ops/10.html | link_path in html_names_map: False, lowered: False
navpoint
src ['11.html']
TOC Navpoint broken to remove of: 11.html
link_path Ops/11.html | link_path in html_names_map: False, lowered: False
navpoint
src ['12.html']
TOC Navpoint broken to remove of: 12.html
link_path Ops/12.html | link_path in html_names_map: False, lowered: False
navpoint
src ['13.html']
TOC Navpoint broken to remove of: 13.html
link_path Ops/13.html | link_path in html_names_map: False, lowered: False
navpoint
src ['14.html']
TOC Navpoint broken to remove of: 14.html
link_path Ops/14.html | link_path in html_names_map: False, lowered: False
navpoint
src ['15.html']
TOC Navpoint broken to remove of: 15.html
link_path Ops/15.html | link_path in html_names_map: False, lowered: False
navpoint
src ['16.html']
TOC Navpoint broken to remove of: 16.html
link_path Ops/16.html | link_path in html_names_map: False, lowered: False
navpoint
src ['17.html']
TOC Navpoint broken to remove of: 17.html
link_path Ops/17.html | link_path in html_names_map: False, lowered: False
Looking for non dc: elements in manifest
Removing child:
Removing child:
Removing child:
ePub updated in 0.34 seconds
|