Skip to content

Commit

Permalink
gettext is in libeoaconvert
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Mar 4, 2020
1 parent 5a2d9c8 commit 4767017
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions src/imxml2django.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: <2020-02-28 17:32:23 (kthoden)>
# Time-stamp: <2020-03-04 15:01:57 (kthoden)>

"""
Create an XML file that can be inserted into the Django database
Expand Down Expand Up @@ -255,15 +255,6 @@ def debug_chapters(xmlEOAchapters):
chap_num += 1
# def debug_chapters ends here

def gettext(xmlElement):
"""Maintain text and strip subchildren"""
xmlText = xmlElement.text or ""
for xmlChild in xmlElement:
xmlText += gettext(xmlChild)
if xmlChild.tail:
xmlText += xmlChild.tail
return xmlText
# def gettext ends here

def djangoParseObject(xmlElement, indent=False, listtype=None, listnumber=0, uid=None):
# Get Dictionaries of Numbers via Global Variables
Expand Down Expand Up @@ -1042,7 +1033,7 @@ def check_publication_cfg(configuration_file):
else:
xmlEOAchapter.set("number", "")
logging.info("-----------------------------------------------------")
logging.info(gettext(xmlChapterHeadline))
logging.info(libeoaconvert.gettext(xmlChapterHeadline))
xmlEOAchapter.append(djangoParseHeadline(xmlChapterHeadline))
# Deal with EOAauthor
if xmlChapter.find(".//EOAauthor") is not None:
Expand All @@ -1067,7 +1058,7 @@ def check_publication_cfg(configuration_file):
xmlEOAsection.set("number", dictSections[xmlChapterChild.get("id")])
intObjectNumber += 1
xmlHead = xmlChapter.find(".//head")
logging.debug("Section '%s'" % gettext(xmlHead))
logging.debug("Section '%s'" % libeoaconvert.gettext(xmlHead))
xmlEOAsection.append(djangoParseHeadline(xmlHead))
xmlEOAchapter.append(xmlEOAsection)
# Iterate over Children of Section
Expand All @@ -1081,7 +1072,7 @@ def check_publication_cfg(configuration_file):
xmlEOAsubsection.set("number", dictSections[xmlSectionChild.get("id")])
intObjectNumber += 1
xmlHead = xmlSectionChild.find(".//head")
logging.debug("Subsection '%s'" % gettext(xmlHead))
logging.debug("Subsection '%s'" % libeoaconvert.gettext(xmlHead))
xmlEOAsubsection.append(djangoParseHeadline(xmlHead))
xmlEOAchapter.append(xmlEOAsubsection)
# Iterate over children of Subsection
Expand All @@ -1092,7 +1083,7 @@ def check_publication_cfg(configuration_file):
xmlEOAsubsubsection.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlHead = xmlSubsectionChild.find(".//head")
logging.debug(gettext(xmlHead))
logging.debug(libeoaconvert.gettext(xmlHead))
xmlEOAsubsubsection.append(djangoParseHeadline(xmlHead))
xmlEOAchapter.append(xmlEOAsubsubsection)
# Iterate over children of Subsubsection
Expand All @@ -1118,7 +1109,7 @@ def check_publication_cfg(configuration_file):
xmlEOAparasection.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlHead = xmlSubsubsectionChild.find(".//head")
logging.debug(gettext(xmlHead))
logging.debug(libeoaconvert.gettext(xmlHead))
xmlEOAparasection.append(djangoParseHeadline(xmlHead))
xmlEOAchapter.append(xmlEOAparasection)
for xmlParasectionChild in xmlSubsubsectionChild.iterchildren():
Expand Down Expand Up @@ -1737,7 +1728,7 @@ def bring_footnote_down_django(footnote, fragment, footnote_number, object_numbe

# Using the gettext function here, because of subelements
# strEOAindextext = xmlEOAindex.text
strEOAindextext = gettext(xmlEOAindex)
strEOAindextext = libeoaconvert.gettext(xmlEOAindex)
strEOAindextext = strEOAindextext.replace("\n", " ")

index_children = xmlEOAindex.getchildren()
Expand Down

0 comments on commit 4767017

Please sign in to comment.