[LyX/master] ePub: copy images into the ePub archive.

Thibaut Cuvelier tcuvelier at lyx.org
Mon Feb 8 05:42:22 UTC 2021


On Mon, 8 Feb 2021 at 00:56, Stephan Witt <st.witt at gmx.net> wrote:

> Hi Thibaut,
>
> sorry for having python 2.7 on Mac…
>

It's not like you have a choice there :)!


> to overcome this:
>
> 00:39:31.061: Command to execute:
> 00:39:31.062: "xsltproc" -stringparam base.dir
> "/var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY"
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/../docbook/epub3/chunk.xsl"
> "In
> 00:39:31.062: tro.xml"
> 00:39:31.062: Generated ePub contents.
> 00:39:31.062: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/ar01s02.xhtml
> for section
> 00:39:31.062: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/ar01s03.xhtml
> for section(sec.Helfen)
> 00:39:31.062: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/index.xhtml
> for article
> 00:39:31.063: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/docbook-epub.css
> for article
> 00:39:31.063: Generating EPUB package files.
> 00:39:31.063: Generating image list ...
> 00:39:31.063: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/package.opf
> for article
> 00:39:31.063: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/../META-INF/container.xml
> for article
> 00:39:31.063: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/../mimetype
> for article
> 00:39:31.064: Generating NCX file ...
> 00:39:31.064: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpmUoLhY/OEBPS/toc.ncx
> for article
> 00:39:31.064: Traceback (most recent call last):
> 00:39:31.064:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 179, in <module>
> 00:39:31.064:     DocBookToEpub(sys.argv).transform()
> 00:39:31.064:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 174, in transform
> 00:39:31.064:     self.copy_images()
> 00:39:31.065:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 150, in copy_images
> 00:39:31.065:     self.change_image_paths(self.output_dir +
> '/OEBPS/package.opf')
> 00:39:31.065:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 132, in change_image_paths
> 00:39:31.065:     with open(file, 'r', encoding='utf8') as f:
> 00:39:31.065: TypeError: 'encoding' is an invalid keyword argument for
> this function
> support/Systemcall.cpp (291): Systemcall: 'python
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py"
> none none "xsltproc" none "Intro.xml" "Intro.epub"' finished with exit code
> 1
>
> I had to add
>
> "from io import open"
>
> to docbook2epub.py (patch attached).


I've pushed this patch, it does not seem to cause problems elsewhere at
least.


> Next problem is the image path of the referenced clipart „Fussnote.png“:
>
> 00:52:28.850: Exportiere ...
> 00:52:28.855: (buffer-export epub)
> 00:52:28.981: python
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py"
> none none "xsltproc" none "Intro.xml" "Intro.epub"
> 00:52:29.188: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/ar01-toc.xhtml
> for article
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/ar01s02.xhtml
> for section
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/ar01s03.xhtml
> for section(sec.Helfen)
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/index.xhtml
> for article
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/docbook-epub.css
> for article
> 00:52:29.292: Generating EPUB package files.
> 00:52:29.292: Generating image list ...
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/package.opf
> for article
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/../META-INF/container.xml
> for article
> 00:52:29.292: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/../mimetype
> for article
> 00:52:29.293: Generating NCX file ...
> 00:52:29.293: Writing
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ/OEBPS/toc.ncx
> for article
> 00:52:29.397: Generating ePub with the following parameters:
> 00:52:29.397:
> /Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py
> 00:52:29.397: None
> 00:52:29.397: None
> 00:52:29.397: xsltproc
> 00:52:29.397: None
> 00:52:29.397: Intro.xml
> 00:52:29.398: Intro.epub
> 00:52:29.398: Temporary output directory:
> /var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ
> 00:52:29.398: XSLT style sheet to use:
> 00:52:29.398:
> /Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/../docbook/epub3/chunk.xsl
> 00:52:29.398: Command to execute:
> 00:52:29.398: "xsltproc" -stringparam base.dir
> "/var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ"
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/../docbook/epub3/chunk.xsl"
> "In
> 00:52:29.399: tro.xml"
> 00:52:29.399: Generated ePub contents.
> 00:52:29.399: Traceback (most recent call last):
> 00:52:29.399:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 180, in <module>
> 00:52:29.399:     DocBookToEpub(sys.argv).transform()
> 00:52:29.399:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 175, in transform
> 00:52:29.399:     self.copy_images()
> 00:52:29.400:   File
> "/Users/stephan/git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/scripts/docbook2epub.py",
> line 161, in copy_images
> 00:52:29.400:     shutil.copyfile(old, self.output_dir + '/OEBPS/' + new)
> 00:52:29.400:   File
> "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py",
> line 96, in copyfile
> 00:52:29.400:     with open(src, 'rb') as fsrc:
> 00:52:29.400: IOError: [Errno 2] No such file or directory:
> u'../../../git/lyx-build/LyX-2.4.0dev.app/Contents/Resources/doc/de/clipart/Fussnote.png’
>
> Here I’m clueless.
>

That one is trickier… Just to be sure: you tried to convert the German
introduction, is that right? I can get an ePub with Fussnote.png on
Windows, so there must be something platform-dependent.

In your temporary folder
(/var/folders/y8/l_k5f2ms4rngwbwvt9jp53hw0000gt/T/tmpxYSbzQ in your
example), what does OEBPS/package.opf look like *before it is rewritten *by
docbook2epub.py? You may want to comment out self.copy_images() in line
175. What is the path to Fussnote.png there?
Also: what is the actual path to Fussnote.png?

I suppose this is due to the fact I assume that, originally, in
package.opf, the paths are absolute.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lyx.org/pipermail/lyx-devel/attachments/20210208/6ae1e257/attachment-0001.html>


More information about the lyx-devel mailing list