Source

rst2epub / rst2epub / converter.py

Full commit
import os
import sys

from rst import RstDocument
from epub import EpubWriter

from package import Package

def main():
    rst = RstDocument(sys.argv[1])
    title = rst.get_title()
    identifier = "TODO"
    language = "en_TODO"
    writer = EpubWriter(sys.argv[2], title, identifier, language)

    writer.container.add_rootfile(Package.path, Package.media_type)

    writer.package.manifest.add_item("item1", "content/content.xhtml", "application/xhtml+xml")
    writer.package.spine.add_itemref("item1")

    writer.ncx.nav_map.add_nav_point("content", 1, "Content", "content/content.xhtml")

    writer.add_content(rst.to_xhtml())
    writer.write()


if __name__ == "__main__":
    main()