1
0
mirror of https://github.com/gryf/ebook-converter.git synced 2026-04-24 15:11:30 +02:00

Finalizing logging transition.

This commit is contained in:
2021-06-24 20:31:37 +02:00
parent 230fe90e69
commit 0a9536b180
16 changed files with 74 additions and 94 deletions
+8 -14
View File
@@ -351,7 +351,7 @@ def align_block(raw, multiple=4, pad=b'\0'):
return raw + pad*(multiple - extra)
def detect_periodical(toc, log=None):
def detect_periodical(toc, log):
'''
Detect if the TOC object toc contains a periodical that conforms to the
structure required by kindlegen to generate a periodical.
@@ -360,25 +360,19 @@ def detect_periodical(toc, log=None):
return False
for node in toc.iterdescendants():
if node.depth() == 1 and node.klass != 'article':
if log is not None:
log.debug(
'Not a periodical: Deepest node does not have '
'class="article"')
log.debug('Not a periodical: Deepest node does not have '
'class="article"')
return False
if node.depth() == 2 and node.klass != 'section':
if log is not None:
log.debug(
'Not a periodical: Second deepest node does not have'
' class="section"')
log.debug('Not a periodical: Second deepest node does not have '
'class="section"')
return False
if node.depth() == 3 and node.klass != 'periodical':
if log is not None:
log.debug('Not a periodical: Third deepest node'
' does not have class="periodical"')
log.debug('Not a periodical: Third deepest node does not have '
'class="periodical"')
return False
if node.depth() > 3:
if log is not None:
log.debug('Not a periodical: Has nodes of depth > 3')
log.debug('Not a periodical: Has nodes of depth > 3')
return False
return True