mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
4b7d303560
commit
a4721656b0
@ -302,28 +302,32 @@ def align_block(raw, multiple=4, pad=b'\0'):
|
|||||||
return raw + pad*(multiple - extra)
|
return raw + pad*(multiple - extra)
|
||||||
|
|
||||||
|
|
||||||
def detect_periodical(toc, log):
|
def detect_periodical(toc, log=None):
|
||||||
'''
|
'''
|
||||||
Detect if the TOC object toc contains a periodical that conforms to the
|
Detect if the TOC object toc contains a periodical that conforms to the
|
||||||
structure required by kindlegen to generate a periodical.
|
structure required by kindlegen to generate a periodical.
|
||||||
'''
|
'''
|
||||||
for node in toc.iterdescendants():
|
for node in toc.iterdescendants():
|
||||||
if node.depth() == 1 and node.klass != 'article':
|
if node.depth() == 1 and node.klass != 'article':
|
||||||
log.debug(
|
if log is not None:
|
||||||
|
log.debug(
|
||||||
'Not a periodical: Deepest node does not have '
|
'Not a periodical: Deepest node does not have '
|
||||||
'class="article"')
|
'class="article"')
|
||||||
return False
|
return False
|
||||||
if node.depth() == 2 and node.klass != 'section':
|
if node.depth() == 2 and node.klass != 'section':
|
||||||
log.debug(
|
if log is not None:
|
||||||
|
log.debug(
|
||||||
'Not a periodical: Second deepest node does not have'
|
'Not a periodical: Second deepest node does not have'
|
||||||
' class="section"')
|
' class="section"')
|
||||||
return False
|
return False
|
||||||
if node.depth() == 3 and node.klass != 'periodical':
|
if node.depth() == 3 and node.klass != 'periodical':
|
||||||
log.debug('Not a periodical: Third deepest node'
|
if log is not None:
|
||||||
|
log.debug('Not a periodical: Third deepest node'
|
||||||
' does not have class="periodical"')
|
' does not have class="periodical"')
|
||||||
return False
|
return False
|
||||||
if node.depth() > 3:
|
if node.depth() > 3:
|
||||||
log.debug('Not a periodical: Has nodes of depth > 3')
|
if log is not None:
|
||||||
|
log.debug('Not a periodical: Has nodes of depth > 3')
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user