Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Remove empty paragraphs
  • Loading branch information
kthoden committed Feb 15, 2019
1 parent 9904abf commit fcdf3c8
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions imxml2django.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2018-09-13 15:15:48 (kthoden)>
# Time-stamp: <2019-02-15 15:23:43 (kthoden)>

"""
Create an XML file that can be inserted into the Django database
Expand Down Expand Up @@ -639,13 +639,17 @@ def djangoParseObject(xmlElement, indent=False, listtype=None, listnumber=0, uid
# throw them out for the time being
xmlResult = etree.Element("temp")
else:
xmlElement.tag = "EOAparagraph"
quoted_paragraph = xmlElement.get("rend")
if quoted_paragraph is not None and quoted_paragraph == "quoted":
xmlElement.set("rend", "quoted")
xmlElement.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlResult = xmlElement
if xmlElement.getchildren() == [] and not xmlElement.text:
logging.debug(f"Removing empty paragraph")
xmlResult = etree.Element("temp")
else:
xmlElement.tag = "EOAparagraph"
quoted_paragraph = xmlElement.get("rend")
if quoted_paragraph is not None and quoted_paragraph == "quoted":
xmlElement.set("rend", "quoted")
xmlElement.set("order", str(intObjectNumber))
intObjectNumber += 1
xmlResult = xmlElement
else:
print("SPECIAL: %s - %s" % (xmlElement, xmlElement.text))
xmlResult = xmlElement
Expand Down

0 comments on commit fcdf3c8

Please sign in to comment.