예제 #1
0
def main(argv):
    if not os.path.isdir('./' + outdir+ '/'):
        os.mkdir('./' + outdir + '/')

    id = common.get_book_id()
    iabook = iarchive.Book(id, '.')
    visualize(iabook)
예제 #2
0
def main(argv):
    #     if len(argv) != 2:
    #         usage()
    #         sys.exit(-1)

    id = common.get_book_id()
    aby_file = gzip.open(id + "_abbyy.gz", "rb")
    scandata = id + ".xml"

    if not showchars:
        del to_keep[ns + "charParams"]
        (fmt_hints, fmt_attrs) = to_keep[ns + "formatting"]
        fmt_hints.append("nonl")

    condense_abbyy(aby_file, scandata)
예제 #3
0
def main(argv):
    epub_out = None
    import getopt
    try:
        opts, args = getopt.getopt(argv,
                                   "dho:",
                                   ["debug", "help", "outfile="])
    except getopt.GetoptError:
        usage()
        sys.exit(-1)
    debug_output = False
    for opt, arg in opts:
        if opt in ('-h', '--help'):
            usage()
            sys.exit()
        elif opt in ('-d', '--debug'):
            debug_output = True
        elif opt in ('-o', '--outfile'):
            epub_out = arg
    if len(args) == 0:
        book_id = common.get_book_id()
        if book_id is None:
            print 'No args given and no book found in current directory'
            usage()
            sys.exit(-1)
        book_path = '.'
    elif len(args) == 1:
        book_id = args[0]
        if not os.path.exists(book_id):
            print 'Only book_id arg given, and no corresponding book dir found'
            usage()
            sys.exit(-1)
        book_path = book_id
    elif len(args) == 2:
        book_id = args[0]
        book_path = args[1]
    elif len(args) == 3:
        if epub_out is not None:
            print 'outfile found as 3rd argument, but outfile is already specified via -o'
            usage()
            sys.exit(-1)
        book_id = args[0]
        book_path = args[1]
        epub_out = args[2]
    else:
        print 'unrecognized extra arguments ' + args[3:]
        usage()
        sys.exit(-1)

    if epub_out is None:
        epub_out = book_id + '.epub'

# probably busted due to getopt
#     if epub_out == '-':
#         epub_out = sys.stdout

    iabook = iarchive.Book(book_id, book_path)
    ebook = epub.Book(epub_out, include_page_map=False)

    process_abbyy.process_book(iabook, ebook)

    meta_info_items = process_abbyy.get_meta_items(iabook)
    ebook.finish(meta_info_items)

    if debug_output:
        epubcheck = os.path.join(sys.path[0], 'epubcheck-1.0.3.jar')
        output = os.popen('java -jar ' + epubcheck + ' ' + epub_out)
        print output.read()