summaryrefslogtreecommitdiffstats
path: root/modules/calvinscommentaries/combine_calcom.py
diff options
context:
space:
mode:
Diffstat (limited to 'modules/calvinscommentaries/combine_calcom.py')
-rwxr-xr-xmodules/calvinscommentaries/combine_calcom.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/calvinscommentaries/combine_calcom.py b/modules/calvinscommentaries/combine_calcom.py
index 48be2eb..37d8e18 100755
--- a/modules/calvinscommentaries/combine_calcom.py
+++ b/modules/calvinscommentaries/combine_calcom.py
@@ -22,6 +22,9 @@ import sys
now = datetime.now() # for general timestamping purposes
+MAGIC_SEPARATOR_START = "%%% combine_calcom.py START %%%"
+MAGIC_SEPARATOR_END = "%%% combine_calcom.py END %%%"
+
def do_head_replacements(doc):
@@ -45,6 +48,14 @@ def do_body_corrections(doc):
# Correct <scripCom>
rootNode = utils.getRoot(doc)
thml.expandScripComNodes(rootNode)
+ # Add a comment that we are going to use later...
+ body = utils.getNodesFromXPath(doc, '//ThML.body')[0]
+ body.childNodes.insert(0, doc.createComment(MAGIC_SEPARATOR_START))
+ body.childNodes.insert(1, doc.createTextNode("\n"))
+ body.appendChild(doc.createComment(MAGIC_SEPARATOR_END))
+ body.appendChild(doc.createTextNode("\n"))
+
+
# Other corrections
corrections = {
# id attributes can now contain duplicates due to combination
@@ -64,9 +75,7 @@ def combine(templatefile, allfiles):
# templatexml.writexml iterates over them
mainBody.childNodes = LazyNodes(templatexml, allfiles, do_body_corrections, '//ThML.body')
- fh = open('calvinscommentaries.thml', 'wb')
- utils.writexml(templatexml, fh)
- fh.close()
+ utils.writexml(templatexml, sys.stdout)
def main(filenames):
combine(filenames[0], filenames)