Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Option for writing conversion log to file
  • Loading branch information
kthoden committed Dec 21, 2018
1 parent 2c1d168 commit 7011ef6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions fix_tei.py
Expand Up @@ -522,7 +522,7 @@ def add_tei_frontpart():
return frontpart
# def add_tei_frontpart ends here

def evaluate_report(report):
def evaluate_report(report, printlog, filename):
"""Print report of conversion."""

report_string = "="*60 + "\n"
Expand All @@ -549,8 +549,11 @@ def evaluate_report(report):
report_string += ("All page references could be parsed into discrete values.\n")
report_string += "="*60 + "\n"

print(report_string)

if printlog:
print(report_string)
else:
with open(filename.replace(".xml", ".log"), "w") as f:
f.write(report_string)
return
# def evaluate_report ends here

Expand Down Expand Up @@ -608,7 +611,7 @@ def main():
# the '#' sign is a bad choice!
# mod_string = convert_references(xml_string)

mod_string2, cited = convert_citations(xml_string)
mod_string2, cited = convert_citations(xml_string, args.citedrangetext)

used_citekeys = [unescape(c) for c in cited]
citekeys_not_in_bib = validate_citations(used_citekeys, bibdata)
Expand Down Expand Up @@ -716,7 +719,7 @@ def main():
if args.finalize:
pass
else:
evaluate_report(report)
evaluate_report(report, args.printlog, args.teifile)
# def main ends here

if __name__ == '__main__':
Expand Down

0 comments on commit 7011ef6

Please sign in to comment.