from shutil import rmtree
from librarian import RDFNS, WLNS, NCXNS, OPFNS, XHTMLNS, OutputFile
+from librarian.cover import WLCover
from librarian import functions, get_resource
""" produces a EPUB file
sample=n: generate sample e-book (with at least n paragraphs)
- cover: a cover.Cover object
- flags: less-advertising, without-fonts
+ cover: a cover.Cover object or True for default
+ flags: less-advertising, without-fonts, working-copy
"""
def transform_file(wldoc, chunk_counter=1, first=True, sample=None):
style = get_resource('epub/style.css')
zip.write(style, os.path.join('OPS', 'style.css'))
-
if cover:
+ if cover is True:
+ cover = WLCover
+ if cover.uses_dc_cover:
+ if document.book_info.cover_by:
+ document.edoc.getroot().set('data-cover-by', document.book_info.cover_by)
+ if document.book_info.cover_source:
+ document.edoc.getroot().set('data-cover-source', document.book_info.cover_source)
+
cover_file = StringIO()
- c = cover(document.book_info.author.readable(), document.book_info.title)
+ c = cover(document.book_info)
c.save(cover_file)
c_name = 'cover.%s' % c.ext()
zip.writestr(os.path.join('OPS', c_name), cover_file.getvalue())