3 from .builders import builders
4 from .document import WLDocument
7 def main(*args, **kwargs):
8 parser = argparse.ArgumentParser(description="PARSER DESCRIPTION")
12 choices=builders.keys(),
15 parser.add_argument('input_file')
17 '-o', '--output-file', metavar='FILE',
18 help='specifies the output file'
21 '-O', '--output-dir', metavar='DIR',
22 help='specifies the directory for output'
27 '-b', '--base-url', metavar="URL",
28 help="Base for relative URLs in documents (like image sources)"
35 help='specifies an MP3 file, if needed'
38 args = parser.parse_args()
39 builder = builders[args.builder]
42 output_file_path = args.output_file
44 output_file_path = '.'.join((
45 os.path.splitext(args.input_file)[0],
46 builder.file_extension
49 output_file_path = '/'.join((
51 output_file_path.rsplit('/', 1)[-1]
54 document = WLDocument(filename=args.input_file)
56 builder = builders[args.builder]
61 output = document.build(builder, **kwargs)
62 with open(output_file_path, 'wb') as f:
63 f.write(output.get_bytes())