Exemple #1
0
def test_objavi_epub():
    src = 'tests/booki_books'
    dest = 'tests/generated-epubs'

    from objavi.fmbook import log, ZipBook, make_book_name
    from objavi import config
    config.BOOKI_BOOK_DIR = src

    for zfn in os.listdir(src):
        log('starting %s' % zfn)
        book = ZipBook(config.LOCALHOST, zfn[:-4])
        book.make_epub()
        log( zfn, (book.epubfile, '%s/%s' % (dest, os.path.basename(book.epubfile))))
        #break
        os.rename(book.epubfile, '%s/%s' % (dest, os.path.basename(book.epubfile)))
def make_epub(server, bookid):
    log('making epub for %s %s' % (server, bookid))
    bookname = make_book_name(bookid, server, '.epub')
    book = ZipBook(server, bookid, bookname=bookname, project='FM')
    book.make_epub(use_cache=True)
#-------------------------------------------------------------#

import traceback
from objavi.fmbook import log, ZipBook, make_book_name
from objavi import config
from objavi.twiki_wrapper import get_book_list


def make_epub(server, bookid):
    log('making epub for %s %s' % (server, bookid))
    bookname = make_book_name(bookid, server, '.epub')
    book = ZipBook(server, bookid, bookname=bookname, project='FM')
    book.make_epub(use_cache=True)


for server, settings in config.SERVER_DEFAULTS.items():
    if settings['interface'] == 'Booki':
        continue
    books = get_book_list(server)

    for book in books:
        try:
            make_epub(server, book)
            log('SUCCEEDED: %s %s' % (server, book))
        except Exception, e:
            log('FAILED: %s %s' % (server, book))
            traceback.print_exc()


Exemple #4
0
def make_epub(server, bookid):
    log('making epub for %s %s' % (server, bookid))
    bookname = make_book_name(bookid, server, '.epub')
    book = ZipBook(server, bookid, bookname=bookname, project='FM')
    book.make_epub(use_cache=True)
Exemple #5
0
if 'HTTP_HOST' not in os.environ:
    guess_http_host()

#-------------------------------------------------------------#

import traceback
from objavi.fmbook import log, ZipBook, make_book_name
from objavi import config
from objavi.twiki_wrapper import get_book_list


def make_epub(server, bookid):
    log('making epub for %s %s' % (server, bookid))
    bookname = make_book_name(bookid, server, '.epub')
    book = ZipBook(server, bookid, bookname=bookname, project='FM')
    book.make_epub(use_cache=True)


for server, settings in config.SERVER_DEFAULTS.items():
    if settings['interface'] == 'Booki':
        continue
    books = get_book_list(server)

    for book in books:
        try:
            make_epub(server, book)
            log('SUCCEEDED: %s %s' % (server, book))
        except Exception, e:
            log('FAILED: %s %s' % (server, book))
            traceback.print_exc()
Exemple #6
0
        for a in authors:
            meta_info_items.append({'item': DCNS + 'creator', 'text': a})
        meta_info_items.append({
            'item':
            DCNS + 'rights',
            'text':
            'This book is free. Copyright %s' % (', '.join(authors))
        })

        tree_str = ia_epub.make_opf(meta_info_items, ebook.manifest_items,
                                    ebook.spine_items, ebook.guide_items,
                                    ebook.cover_id)
        ebook.add(ebook.content_dir + 'content.opf', tree_str)

        ebook.z.close()


if __name__ == '__main__':
    try:
        f = open(sys.argv[1])
        zipstring = f.read()
        f.close()
    except (IOError, OSError), e:
        log(e, "USAGE: %s <booki-zip file>" % sys.argv[0])
        sys.exit()

    book = ZipBook(zipstring)
    print book
    book.make_epub()
    shift_file(book.epubfile, PUBLISH_DIR)
Exemple #7
0
        # copyright
        authors = sorted(self.info["copyright"])
        for a in authors:
            meta_info_items.append({"item": DCNS + "creator", "text": a})
        meta_info_items.append(
            {"item": DCNS + "rights", "text": "This book is free. Copyright %s" % (", ".join(authors))}
        )

        tree_str = ia_epub.make_opf(
            meta_info_items, ebook.manifest_items, ebook.spine_items, ebook.guide_items, ebook.cover_id
        )
        ebook.add(ebook.content_dir + "content.opf", tree_str)

        ebook.z.close()


if __name__ == "__main__":
    try:
        f = open(sys.argv[1])
        zipstring = f.read()
        f.close()
    except (IOError, OSError), e:
        log(e, "USAGE: %s <booki-zip file>" % sys.argv[0])
        sys.exit()

    book = ZipBook(zipstring)
    print book
    book.make_epub()
    shift_file(book.epubfile, PUBLISH_DIR)