Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Feature for including pdfless chapters
These are chapters that don't offer a PDF for download
  • Loading branch information
Klaus Thoden committed Nov 13, 2018
1 parent 41bf929 commit bd9f730
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions build_frontmatter.py
Expand Up @@ -95,7 +95,7 @@ def get_publication_info(eoa_pub_id, eoa_cursor):
return rows
# def get_publication_info ends here

def get_chapters(eoa_pub_id, eoa_cursor):
def get_chapters(eoa_pub_id, eoa_cursor, include_pdfless=False):
"""Queries database for information about the individual chapters.
Return the first row including all the fields below"""
Expand All @@ -109,13 +109,16 @@ def get_chapters(eoa_pub_id, eoa_cursor):

rows = eoa_cursor.fetchall()

for row in rows:
if len(row[7]) == 0:
print_error("There seems to be no file attached to chapter '%s'. Removing it." % row[1])
if include_pdfless:
return rows
else:
for row in rows:
if len(row[7]) == 0:
print_error("There seems to be no file attached to chapter '%s'. Removing it." % row[1])

rows[:] = [row for row in rows if len(row[7]) > 0]
rows[:] = [row for row in rows if len(row[7]) > 0]

return rows
return rows
# get_chapters ends here

def format_authors_old(result_list, start_range, end_range):
Expand Down Expand Up @@ -694,7 +697,7 @@ def create_xhtml(eoa_publication):

base_url = which_publisher(eoa_publication_info["Serie"])

chapter_files = get_chapters(eoa_pub_id, eoa_cursor)
chapter_files = get_chapters(eoa_pub_id, eoa_cursor, include_pdfless=True)

if len(chapter_files) == 0:
print_error("Found no chapter files.")
Expand Down

0 comments on commit bd9f730

Please sign in to comment.