Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bibliography
  • Loading branch information
Klaus Thoden committed Feb 13, 2018
1 parent 80ce7b7 commit 922fe03
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions eoaconvert.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-02-12 16:57:53 (kthoden)>
# Time-stamp: <2018-02-13 13:18:39 (kthoden)>

# license?
__version__= "1.0"
Expand Down Expand Up @@ -1152,7 +1152,12 @@ def cleanup():
xmlBibliography = xmlTree.find(".//EOAprintbibliography")
xmlBibliography.clear()
xmlBibliography.tag = "div"
xmlBibliography.getparent().tag = "div"

bib_parent = xmlBibliography.getparent()
bib_parent.tag = "div"
# bib_parent.set("order", "1")

# xmlBibliography.getparent().tag = "div"
#xmlBibliography.addnext(xmlBibliographyDiv)

###############
Expand Down Expand Up @@ -1183,31 +1188,31 @@ def cleanup():
###############
# old version #
###############
xml_bib_entries = xmlBibTree.findall(".//entry")
intNumberOfEntry = 0
for xmlEntry in xml_bib_entries:
if intNumberOfEntry == 0:
# Don't check for previous author if first entry of the Bibliography
bibEntry = Bibitem(xmlEntry)
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"
else:
bibEntry = Bibitem(xmlEntry)
# Check if author of previous Entry is the same
bibEntryPrevious = Bibitem(xml_bib_entries[intNumberOfEntry - 1])
if bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
elif bibEntryPrevious.fullauthorlastfirst()[0] == bibEntry.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
elif bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
else:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"

xmlNew = etree.fromstring(strNewentry)
# next one writes the bibliography into the document
# xmlBibliography.append(xmlNew)

intNumberOfEntry += 1
# xml_bib_entries = xmlBibTree.findall(".//entry")
# intNumberOfEntry = 0
# for xmlEntry in xml_bib_entries:
# if intNumberOfEntry == 0:
# # Don't check for previous author if first entry of the Bibliography
# bibEntry = Bibitem(xmlEntry)
# strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"
# else:
# bibEntry = Bibitem(xmlEntry)
# # Check if author of previous Entry is the same
# bibEntryPrevious = Bibitem(xml_bib_entries[intNumberOfEntry - 1])
# if bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
# strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
# elif bibEntryPrevious.fullauthorlastfirst()[0] == bibEntry.fullauthorlastfirst()[0]:
# strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
# elif bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
# strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
# else:
# strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"

# xmlNew = etree.fromstring(strNewentry)
# # next one writes the bibliography into the document
# # xmlBibliography.append(xmlNew)

# intNumberOfEntry += 1
######################
# end of old version #
######################
Expand Down Expand Up @@ -1580,7 +1585,7 @@ def cleanup():
# Pickle the 'data' dictionary using the highest protocol available.
pickle.dump(data_to_pickle, f, pickle.HIGHEST_PROTOCOL)

grep_command = "grep -A1 -B2 'argument of \\\EOAfn;' %s-tralics.log" % options.filename
grep_command = "grep -A1 -B2 'argument of \\\EOAfn' %s-tralics.log" % options.filename
grep_command_arguments = shlex.split(grep_command)
grep_result = subprocess.Popen(grep_command_arguments, stdout=subprocess.PIPE)
grep_output = grep_result.stdout.read()
Expand Down

0 comments on commit 922fe03

Please sign in to comment.