|
|
|
@ -138,8 +138,12 @@ def wrapTags(tag, xmlCantoFile): |
|
|
|
used to add <tercets>, <canto>, and <text> tags around <canto> body |
|
|
|
""" |
|
|
|
xmlCanto = getXMLFileName(xmlCantoFile) |
|
|
|
cantoNum = str(int(xmlCanto.split('-')[0])) |
|
|
|
canticle = xmlCanto.split('-')[1] |
|
|
|
if tag == 'TEI': |
|
|
|
openTag = '<TEI xmlns="http://www.tei-c.org/ns/1.0">\n' |
|
|
|
elif tag == 'canto': |
|
|
|
openTag = '<' + tag + ' canticle="' + canticle + '"' + ' c_num="' + cantoNum + '">\n' |
|
|
|
else: |
|
|
|
openTag = '<' + tag + '>\n' |
|
|
|
closeTag = '\n</' + tag + '>' |
|
|
|
@ -151,7 +155,7 @@ def wrapTags(tag, xmlCantoFile): |
|
|
|
xmlCantoContents.write(closeTag) |
|
|
|
xmlCantoContents.close() |
|
|
|
|
|
|
|
def addTEIHeaderTags(xmlCantoFile): |
|
|
|
def addTEIHeader(xmlCantoFile): |
|
|
|
""" |
|
|
|
The following is the minimum required TEI header |
|
|
|
<TEI xmlns="http://www.tei-c.org/ns/1.0"> |
|
|
|
@ -177,6 +181,16 @@ def addTEIHeaderTags(xmlCantoFile): |
|
|
|
""" |
|
|
|
xmlCanto = getXMLFileName(xmlCantoFile) |
|
|
|
|
|
|
|
def addXMLHeader(xmlCantoFile): |
|
|
|
xmlCanto = getXMLFileName(xmlCantoFile) |
|
|
|
xmlHeader = '<?xml version="1.0" encoding="UTF-8"?>\n\n' |
|
|
|
with open(xmlCanto, 'r') as xmlCantoContents: |
|
|
|
contents = xmlCantoContents.read() |
|
|
|
with open(xmlCanto, 'w') as xmlCantoContents: |
|
|
|
xmlCantoContents.write(xmlHeader) |
|
|
|
xmlCantoContents.write(contents) |
|
|
|
xmlCantoContents.close() |
|
|
|
|
|
|
|
def addSpaces(xmlCantoFile): |
|
|
|
""" |
|
|
|
Add a given number of spaces before each opening and closing tag. |
|
|
|
@ -238,9 +252,9 @@ def main(): |
|
|
|
wrapTags('tercets', xmlCantoName) |
|
|
|
wrapTags('canto', xmlCantoName) |
|
|
|
wrapTags('text', xmlCantoName) |
|
|
|
#addTEIHeaderTags() |
|
|
|
wrapTags('TEI', xmlCantoName) |
|
|
|
addSpaces(xmlCantoName) |
|
|
|
addXMLHeader(xmlCantoName) |
|
|
|
os.remove(cantoFile) # don't delete txt files while debugging so you don't have to keep copying them |
|
|
|
|
|
|
|
|
|
|
|
|