2 # -*- coding: utf-8 -*-
4 # This file is part of Librarian, licensed under GNU Affero GPLv3 or later.
5 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
10 from librarian import epub, DirDocProvider
13 if __name__ == '__main__':
14 # Parse commandline arguments
15 usage = """Usage: %prog [options] SOURCE
16 Convert SOURCE file to EPUB format."""
18 parser = optparse.OptionParser(usage=usage)
20 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False,
21 help='print status messages to stdout')
22 parser.add_option('-d', '--make-dir', action='store_true', dest='make_dir', default=False,
23 help='create a directory for author and put the PDF in it')
25 options, input_filenames = parser.parse_args()
27 if len(input_filenames) != 1:
32 main_input = input_filenames[0]
35 basepath, ext = os.path.splitext(main_input)
36 path, slug = os.path.realpath(basepath).rsplit('/', 1)
37 provider = DirDocProvider(path)
38 epub.transform(provider, slug, output_dir=path, make_dir=options.make_dir)