diff --git a/src/imxml2django.py b/src/imxml2django.py index 040fd55..e5a850a 100755 --- a/src/imxml2django.py +++ b/src/imxml2django.py @@ -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 @@ -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 @@ -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: @@ -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 @@ -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 @@ -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 @@ -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(): @@ -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()