diff --git a/imxml2epub.py b/imxml2epub.py index 46a63eb..9d6deaa 100755 --- a/imxml2epub.py +++ b/imxml2epub.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2018-08-22 15:49:01 (kthoden)> +# Time-stamp: <2019-03-29 15:45:37 (kthoden)> """ Convert a customized DocBook XML file into a set of files that constitute the contents of an EPUB file. @@ -496,6 +496,7 @@ def addToTocncx(tocncx, Label, intTechnicalChapterNumber): # Copy File of the Image # If it's in a subfolder, name of folder and name of image will be merged strImageFileString = xmlFigure.find(".//file").text + logging.debug(f"Working on image {strImageFileString}.") strImageFileString = strImageFileString.rstrip("\n") strImageFileDir = os.path.dirname(strImageFileString) # Remove / from path @@ -508,7 +509,7 @@ def addToTocncx(tocncx, Label, intTechnicalChapterNumber): elif strImageFileName_Suffix.lower() in [".png", ".pdf"]: extension_and_mime = "png" else: - print("Found an unrecognized image suffix: %s" % strImageFileName_Suffix) + logging.error(f"Found an unrecognized image suffix: {strImageFileName_Suffix}") sys.exit() strImageFilepath = libeoaconvert.sanitizeImage(os.getcwd() + "/CONVERT/epub/OEBPS/images/" + strImageFileDir + strImageFileName, GM_PATH, TL_PATH) @@ -1405,7 +1406,7 @@ class FootnoteError(Exception): etree.strip_attributes(xmlEbookTree, "id-text", "noindent", "type", "label", "spacebefore", "rend") # also contained "id" etree.strip_elements(xmlEbookTree, "citekey", with_tail=False) -# Write every Part and Chapter into one file +logging.info("Write every Part and Chapter into one file") xmlChapters = xmlEbookTree.findall("//div1") listParts = [] intTechnicalChapterNumber = 1 @@ -1450,7 +1451,7 @@ class FootnoteError(Exception): # Content_OPF hinzufügen intTechnicalChapterNumber += 1 -# Convert Facsimile-Parts +logging.info("Convert Facsimile-Parts") xmlParts = xmlEbookTree.findall("//div0") for xmlPart in xmlParts: print("-------------") @@ -1486,14 +1487,14 @@ class FootnoteError(Exception): # Content_OPF hinzufügen intTechnicalChapterNumber += 1 -# Saving toc.ncx +logging.info("Saving toc.ncx") tmpFileName = os.getcwd() + "/CONVERT/epub/OEBPS/toc.ncx" tmpFile = open (tmpFileName, "w") tmpResult = etree.tostring(tocncx, pretty_print=True, encoding="unicode") tmpFile.write(tmpResult) tmpFile.close() -# Saving content.opf +logging.info("Saving content.opf") tmpFileName = os.getcwd() + "/CONVERT/epub/OEBPS/content.opf" tmpFile = open (tmpFileName, "w") tmpResult = etree.tostring(contentopf, pretty_print=True, encoding="unicode") @@ -1504,8 +1505,9 @@ class FootnoteError(Exception): # Finishing various Stuff # ############################################################################ -# Write Temporary XML-Tree +logging.info("Write Temporary XML-Tree") ergebnisdatei = open("tmp_files/Devel_ebook.xml", "w") ergebnis = etree.tostring(xmlEbookTree, pretty_print=True, encoding="unicode") ergebnisdatei.write(ergebnis) ergebnisdatei.close() +logging.info("Finished!")