Completed
Push — master ( 8c3d23...8de117 )
by Daisuke
9s
created

main()   A

Complexity

Conditions 2

Size

Total Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
c 1
b 0
f 1
dl 0
loc 21
rs 9.3142
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
from AbstractGenerator import AbstractGenerator
5
from optparse import OptionParser
6
import getopt, sys
7
8
def main():
9
    usage = 'Usage: %prog [options] input.xlsx output.docx'
10
    version = '%prog 20161121'
11
    parser = OptionParser(usage=usage, version=version)
12
    parser.add_option('-i', '--imagedir', metavar='IMAGE_DIR',
13
                      dest='image_dir', default='image',
14
                      help='image directory (default image)')
15
    parser.add_option('-t', '--template', metavar='TEMPLATE_TYPE',
16
                      dest='template_type', default='aini2016',
17
                      help='template type: \'aini2016\' or \'jscpb2016\' (default aini2016)')
18
    (options, args) = parser.parse_args()
19
    if len(args) != 2:
20
        parser.error('incorrect number of arguments')
21
    input_xlsx = args[0]
22
    output_docx = args[1]
23
    template_docx = 'template-' + options.template_type + '.docx'
24
25
    abgen = AbstractGenerator(options.image_dir, options.template_type)
26
    abgen.read_xlsx(input_xlsx)
27
    abgen.write_docx(output_docx, template_docx)
28
    sys.exit()
29
30
if __name__ == '__main__':
31
    main()
32