|
1 |
| - |
| 1 | +from __future__ import print_function |
2 | 2 | import sys
|
3 | 3 | import os
|
4 | 4 | import shutil
|
5 |
| -import inspect |
6 | 5 |
|
7 | 6 | import getopt
|
8 | 7 | from collections import defaultdict
|
|
12 | 11 | throot = "/".join(sys.path[0].split("/")[:-2])
|
13 | 12 |
|
14 | 13 | options = defaultdict(bool)
|
15 |
| - options.update(dict([x, y or True] for x, y in getopt.getopt(sys.argv[1:], 'o:', ['rst', 'help', 'nopdf'])[0])) |
| 14 | + output_arg = getopt.getopt(sys.argv[1:], 'o:', ['rst', 'help', 'nopdf'])[0] |
| 15 | + options.update(dict([x, y or True] for x, y in output_arg)) |
16 | 16 | if options['--help']:
|
17 |
| - print 'Usage: %s [OPTIONS]' % sys.argv[0] |
18 |
| - print ' -o <dir>: output the html files in the specified dir' |
19 |
| - print ' --rst: only compile the doc (requires sphinx)' |
20 |
| - print ' --nopdf: do not produce a PDF file from the doc, only HTML' |
21 |
| - print ' --help: this help' |
| 17 | + print('Usage: %s [OPTIONS]' % sys.argv[0]) |
| 18 | + print(' -o <dir>: output the html files in the specified dir') |
| 19 | + print(' --rst: only compile the doc (requires sphinx)') |
| 20 | + print(' --nopdf: do not produce a PDF file from the doc, only HTML') |
| 21 | + print(' --help: this help') |
22 | 22 | sys.exit(0)
|
23 | 23 |
|
24 | 24 | options['--all'] = not bool(options['--rst'])
|
@@ -49,18 +49,15 @@ def mkdir(path):
|
49 | 49 | import tempfile
|
50 | 50 | workdir = tempfile.mkdtemp()
|
51 | 51 | sphinx.main(['', '-E', '-b', 'latex',
|
52 |
| - os.path.join(throot, 'doc'), workdir]) |
| 52 | + os.path.join(throot, 'doc'), workdir]) |
53 | 53 | # Compile to PDF
|
54 | 54 | os.chdir(workdir)
|
55 | 55 | os.system('make')
|
56 | 56 | try:
|
57 | 57 | shutil.copy(os.path.join(workdir, 'deeplearning.pdf'), outdir)
|
58 | 58 | os.chdir(outdir)
|
59 | 59 | shutil.rmtree(workdir)
|
60 |
| - except OSError, e: |
61 |
| - print 'OSError:', e |
62 |
| - except IOError, e: |
63 |
| - print 'IOError:', e |
64 |
| - |
65 |
| - |
66 |
| - |
| 60 | + except OSError as e: |
| 61 | + print('OSError:', e) |
| 62 | + except IOError as e: |
| 63 | + print('IOError:', e) |
0 commit comments