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.
8 from optparse import OptionParser
9 from librarian import pdf, DirDocProvider, ParseError
11 if __name__ == '__main__':
12 usage = "usage: %prog [options] <input_file> [output_file]"
13 parser = OptionParser(usage)
14 parser.add_option('-v', '--verbose', action='store_true', dest='verbose', default=False,
15 help='make lots of noise and revert to default interaction in LaTeX')
16 parser.add_option('-d', '--make-dir', action='store_true', dest='make_dir', default=False,
17 help='create a directory for author and put the PDF in it')
18 parser.add_option('-t', '--save-tex', dest='save_tex', metavar='FILE',
19 help='path to save the intermediary LaTeX file to')
20 (options, args) = parser.parse_args()
22 if not 1 <= len(args) <= 2:
27 basepath, ext = os.path.splitext(main_input)
28 path, slug = os.path.realpath(basepath).rsplit('/', 1)
29 provider = DirDocProvider(path)
32 pdf.transform(provider, slug, output_file=args[1], verbose=options.verbose, save_tex=options.save_tex)
34 pdf.transform(provider, slug, output_dir=path, make_dir=options.make_dir, verbose=options.verbose, save_tex=options.save_tex)
36 print '%(file)s:%(name)s:%(message)s' % {
38 'name': e.__class__.__name__,