Skip to content

Commit

Permalink
Deduplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Klaus Thoden committed Jan 22, 2018
1 parent 994c826 commit 1b34412
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions eoaconvert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-01-22 16:45:16 (kthoden)>
# Time-stamp: <2018-01-22 16:59:11 (kthoden)>

# license?
__version__= "1.0"
Expand Down Expand Up @@ -969,7 +969,10 @@ def cleanup():
for x in jsonObj:
print(x["title"])

# the old solution

####################
# the old solution #
####################
# Copy interim .bbl-File to interim bib.tex file
interim_bibtex_file = (options.filename) + "bib.tex"
try:
Expand Down Expand Up @@ -1040,6 +1043,10 @@ def cleanup():
xmlBibTree = etree.parse((options.filename + "bib.xml"), xmlParser2)
xmlEntries = xmlBibTree.findall(".//entry")

###########################
# end of the old solution #
###########################

make_bibchecker(bib_database, set_citations)

# If Bibliography-Type is monograph search for EOAbibliography and make it all
Expand All @@ -1057,30 +1064,24 @@ def cleanup():
# Don't check for previous author if first entry of the Bibliography
bibEntry = Bibitem(xmlEntry)
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"
xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)
else:
bibEntry = Bibitem(xmlEntry)
# Check if author of previous Entry is the same
bibEntryPrevious = Bibitem(xmlEntries[intNumberOfEntry - 1])
if bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)
elif bibEntryPrevious.fullauthorlastfirst()[0] == bibEntry.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)
elif bibEntry.fullauthorlastfirst()[0] == bibEntryPrevious.fullauthorlastfirst()[0]:
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=True) + "</p>"
xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)
else:
print("dieser fall")
strNewentry = "<p class=\"bibliography\">" + createBibEntryAuthorYear(bibEntry, boolSameAuthor=False) + "</p>"
print("a new entry", strNewentry)
xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)

xmlNew = etree.fromstring(strNewentry)
xmlBibliography.append(xmlNew)

intNumberOfEntry += 1

# If Bibliography-Type is anthology search for EOAbibliography and make one per chapter
Expand Down

0 comments on commit 1b34412

Please sign in to comment.