-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconverter.py
38 lines (32 loc) · 1.57 KB
/
converter.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import logging
from argparse import ArgumentParser
from converter.toc import generate_toc
from converter.loader import load_config_file
from converter.convert import convert, convert_bookdown, convert_rst
from converter.refs import ref_dict
if __name__ == '__main__':
parser = ArgumentParser(description='Process convert to codio guides.')
parser.add_argument('paths', metavar='PATH', type=str, nargs='+', help='path to a book config')
parser.add_argument('--generate', type=str, help='path to a latex book')
parser.add_argument('-l', '--log', action='store', default=None)
parser.add_argument('-y', '--yes', action='store_true')
parser.add_argument('-r', '--ref', action='store_true')
args = parser.parse_args()
logging.basicConfig(filename=args.log, level=logging.DEBUG,
format='[%(asctime)s] %(levelname).5s %(message)s',
datefmt='%Y.%m.%d %H:%M:%S')
logging.getLogger('PIL').setLevel(logging.WARN)
if args.generate:
generate_toc(args.paths[0], args.generate)
elif args.ref:
config, base_path = load_config_file(args.paths[0])
ref_dict(config)
else:
for path in args.paths:
config, base_path = load_config_file(path)
if config.get('workspace', {}).get('tex'):
convert(config, base_path, args.yes)
elif config.get('workspace', {}).get('bookdown'):
convert_bookdown(config, base_path, args.yes)
elif config.get('workspace', {}).get('rst'):
convert_rst(config, base_path, args.yes)