diff --git a/imxml2django.py b/imxml2django.py index 0416d98..2ee43bb 100755 --- a/imxml2django.py +++ b/imxml2django.py @@ -267,33 +267,38 @@ def djangoParseObject(xmlElement, indent=False, listtype=None, listnumber=0, uid # Create basic Element EOAfigure xmlEOAfigure = etree.Element("EOAfigure") # Copy Image - strImageFileString = xmlElement.find(".//file").text - strImageFileString = strImageFileString.rstrip("\n") - strImageFileDir = os.path.dirname(strImageFileString) - strImageFileDir = re.sub("/", "", strImageFileDir) - strImageFileName = os.path.basename(strImageFileString) - strImageFileNamewoSuffix = os.path.splitext(strImageFileName)[0] - shutil.copy(os.getcwd() + "/" + strImageFileString, os.getcwd() + "/CONVERT/django/images/" + strImageFileDir + strImageFileName) - logging.debug("Django figure %s." % strImageFileName) - # yellow - if os.path.splitext(strImageFileName)[1].lower() == ".pdf": - logging.debug("Found a PDF file") - strImageFilepath = libeoaconvert.sanitizeImage(os.getcwd() + "/CONVERT/django/images/" + strImageFileDir + strImageFileName, GM_PATH, TL_PATH) - xmlEOAfigure.set("file", strImageFileDir + strImageFileName.replace(".pdf", ".png")) - logging.debug("The filename is %s" % xmlEOAfigure.get("file")) + if xmlElement.get("type") == "hionly": + logging.debug("Found hyperimage figure, continuing") + pass else: - xmlEOAfigure.set("file", strImageFileDir + strImageFileName) - xmlEOAfigure.set("width", xmlElement.find(".//width").text + "px;") - xmlEOAfigure.set("order", str(intObjectNumber)) + strImageFileString = xmlElement.find(".//file").text + strImageFileString = strImageFileString.rstrip("\n") + strImageFileDir = os.path.dirname(strImageFileString) + strImageFileDir = re.sub("/", "", strImageFileDir) + strImageFileName = os.path.basename(strImageFileString) + strImageFileNamewoSuffix = os.path.splitext(strImageFileName)[0] + shutil.copy(os.getcwd() + "/" + strImageFileString, os.getcwd() + "/CONVERT/django/images/" + strImageFileDir + strImageFileName) + logging.debug("Django figure %s." % strImageFileName) + # yellow + if os.path.splitext(strImageFileName)[1].lower() == ".pdf": + logging.debug("Found a PDF file") + strImageFilepath = libeoaconvert.sanitizeImage(os.getcwd() + "/CONVERT/django/images/" + strImageFileDir + strImageFileName, GM_PATH, TL_PATH) + xmlEOAfigure.set("file", strImageFileDir + strImageFileName.replace(".pdf", ".png")) + logging.debug("The filename is %s" % xmlEOAfigure.get("file")) + else: + xmlEOAfigure.set("file", strImageFileDir + strImageFileName) + xmlEOAfigure.set("width", xmlElement.find(".//width").text + "px;") + xmlEOAfigure.set("order", str(intObjectNumber)) + # Insert Caption + xmlEOAfigure.append(xmlElement.find(".//caption")) + xmlResult.append(xmlEOAfigure) + intObjectNumber += 1 # Insert visual Number and uid strFigureNumber = dictFigures[xmlElement.find(".//anchor").get("id")] xmlEOAfigure.set("number", strFigureNumber) strFigureUID = xmlElement.find(".//anchor").get("id") xmlEOAfigure.set("id", strFigureUID) - # Insert Caption - xmlEOAfigure.append(xmlElement.find(".//caption")) - xmlResult.append(xmlEOAfigure) elif xmlElement.findall(".//EOAtable"): xmlResult = etree.Element("EOAtable") xmlRawTable = xmlElement.find(".//table")