Eelco Deuling <mailto:[email protected]>
August 9, 2012 1:29
Hello Maarten,
Thank you for "cleaning up" my script, and thank you for pointing out
to http://code.google.com/p/python-epub-builder/
<http://code.google.com/p/python-epub-builder/>.
I did find this myself before, but I staggered mentally when I read
the introduction in the Wiki to "create a epub in five minutes", as I
hardly understand a word in it (and this is just using the "simple API").
The problem is I cannot find a solution that does /just/ what I want
it to do and /nothing more/. I have tried all the WYSIWYG epub editors
and generators, and they all fail me some way or another: they mess up
my CSS, refuse to work with my media or generate a non valid epub.
Most solutions posted here (like the python-epub-builder, Bookbind by
Watts Martin, etc.) are good to generate epub's from text documents,
converting those on-the-fly from Markdown or a similar markup
language. Unfortunately they will not work for me, as they tend to use
more or less /generic/ CSS and not the /custom/ HTML and CSS I want to
use (as a designer I want to make not only readable books but they
should look great as well and every book should have it's own CSS).
With regards,
Eelco
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
Maarten Sneep <mailto:[email protected]>
August 8, 2012 12:31
Hi,
On 8 aug. 2012, at 14:03, Eelco Deuling<[email protected]> wrote:
I have finished "part one": make a directory structure and all the necessary
files for an epub.
As this is my first-ever python script there should be some things wrong, but
it works:
Let me help you out. The script is not too shabby, but could use some cleanup.
#!/usr/bin/env python
#>> This uses the system python. Slightly more flexible.
####################################################################
# call the operating system (?)
#>> Load the 'os' module in python.
#>> This contains a lot of functionality for interaction with the os
####################################################################
import os
####################################################################
# create the directory structure
####################################################################
My_Epub = "epub"
if not os.path.exists(My_Epub):
os.mkdir(My_Epub)
root_path = "./epub/"
folders = ["META-INF", "OEBPS", "OEBPS/texts", "OEBPS/css", "OEBPS/media",
"OEBPS/fonts"]
for folder in folders:
os.mkdir(os.path.join(root_path,folder))
####################################################################
# create the mimetype file
#>> Use os.path.join() here too
#>> Your version didn't close the file (explicitly).
#>> It was implicitly closed on script-end.
####################################################################
with open(os.path.join(My_Epub, "mimetype"), "w") as fp:
fp.write("application/epub+zip")
####################################################################
# create the container xml file
####################################################################
My_Container_xml = """<?xml version="1.0" ?>
<container version="1.0"
xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"
/>
</rootfiles>
</container>
"""
with open(os.path.join(My_Epub, "META-INF", "container.xml"),"w") as fp:
fp.write(My_Container_xml)
####################################################################
# create empty toc.ncx and empty content.opf
####################################################################
with open(os.path.join(My_Epub, "OEBPS", "toc.ncx"), "w") as fp:
fp.write("")
with open(os.path.join(My_Epub, "OEBPS", "content.opf"), "w") as fp:
fp.write("")
----
This gives me the chance to copy all html files, my css, images, fonts and
movie files to the right directories.
Now I will have to fill the empty toc.ncx and content.opf files with the right
content: maybe with os.listdirā¦
This will be continued (hopefully!).
All help would be welcome!
There is an epub python package. No need to reinvent the wheel.
http://code.google.com/p/python-epub-builder/
(I've never used this code, no idea how good this is).
Best,
Maarten
Eelco Deuling <mailto:[email protected]>
August 8, 2012 5:03
Hello,
I have finished "part one": make a directory structure and all the
necessary files for an epub.
As this is my first-ever python script there should be some things
wrong, but it works:
----
#!/usr/bin/python
####################################################################
# call the operating system (?)
####################################################################
import os
####################################################################
# create the directory structure
####################################################################
My_Epub = "epub"
if not os.path.isdir("./" + My_Epub + "/"):
os.mkdir("./" + My_Epub + "/")
root_path = "./epub/"
folders = ["META-INF", "OEBPS", "OEBPS/texts", "OEBPS/css",
"OEBPS/media", "OEBPS/fonts"]
for folder in folders:
os.mkdir(os.path.join(root_path,folder))
####################################################################
# create the mimetype file
####################################################################
open(My_Epub + "/mimetype", "w").write("application/epub+zip")
####################################################################
# create the container xml file
####################################################################
My_Container_xml = """<?xml version="1.0" ?>
<container version="1.0"
xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/content.opf"
media-type="application/oebps-package+xml" />
</rootfiles>
</container>
"""
open(My_Epub + "/META-INF/container.xml","w").write(My_Container_xml)
####################################################################
# create empty toc.ncx and empty content.opf
####################################################################
open(My_Epub + "/OEBPS/toc.ncx", "w").write("")
open(My_Epub + "/OEBPS/content.opf", "w").write("")
----
This gives me the chance to copy all html files, my css, images, fonts
and movie files to the right directories.
Now I will have to fill the empty toc.ncx and content.opf files with
the right content: maybe with os.listdirā¦
This will be continued (hopefully!).
All help would be welcome!
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>
Eelco Deuling <mailto:[email protected]>
August 6, 2012 12:04
Thank you Watts Martin and Charlie Garrison, the solutions do "more
than I want", but that does not mean I am not happy with them. I think
I have enough "hooks" to copy and paste my own solution together. If
it works I will post an update: will take some time though!
Op zaterdag 4 augustus 2012 11:32:55 UTC+2 schreef Eelco Deuling het
volgende:
--
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>