Skip to content

Commit

Permalink
Report fleshed out
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Thoden committed Mar 5, 2018
1 parent 541e687 commit 035a952
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion prepare_tei.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,42 @@ def fix_tei_header(xml_tree, bibfile_string):
return xml_tree
# def fix_tei_header ends here

def plural(num, noun):
"""Return singular or plural form of noun, depending on num.
Works only when a noun's plural is formed with 's'. """

if num == 1:
return noun
else:
return noun + "s"
# def plural ends here

def evaluate_report(report):
"""Print collection of not found items"""

print(report)
print("="*60)
print(' '*4, "Conversion report")
print("-"*60)
if len(report["bad_figures"]) > 0:
print("{} {} could not be linked to a file in the image directory:".format(len(report["bad_figures"]), plural(len(report["bad_figures"]), "figure")))
for item in report["bad_figures"]:
print(' '*4, item)
else:
print("All figures were linked.")
if len(report["not_cited"]) > 0:
print("{} {} could not be found in the bibliography database:".format(len(report["not_cited"]), plural(len(report["not_cited"]), "citation")))
for item in report["not_cited"]:
print(' '*4, item)
else:
print("All citekeys were found in the bibliography database.")
if len(report["bad_pageref"]) > 0:
print("{} page {} could not be parsed into start and end value:".format(len(report["bad_pageref"]), plural(len(report["bad_pageref"]), "reference")))
for item in report["bad_pageref"]:
print(' '*4, item)
else:
print("All page references could be parsed into discrete values.")
print("="*60)
# def evaluate_report ends here

def main():
Expand Down

0 comments on commit 035a952

Please sign in to comment.