OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import os.path | 5 import os.path |
6 import sys | 6 import sys |
7 import optparse | 7 import optparse |
8 import collections | 8 import collections |
9 import functools | 9 import functools |
10 import re | 10 import re |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 try: | 52 try: |
53 cmdline_parser = optparse.OptionParser() | 53 cmdline_parser = optparse.OptionParser() |
54 cmdline_parser.add_option("--output_base") | 54 cmdline_parser.add_option("--output_base") |
55 cmdline_parser.add_option("--jinja_dir") | 55 cmdline_parser.add_option("--jinja_dir") |
56 cmdline_parser.add_option("--config") | 56 cmdline_parser.add_option("--config") |
57 cmdline_parser.add_option("--config_value", action="append", type="strin
g") | 57 cmdline_parser.add_option("--config_value", action="append", type="strin
g") |
58 arg_options, _ = cmdline_parser.parse_args() | 58 arg_options, _ = cmdline_parser.parse_args() |
59 jinja_dir = arg_options.jinja_dir | 59 jinja_dir = arg_options.jinja_dir |
60 if not jinja_dir: | 60 if not jinja_dir: |
61 raise Exception("jinja directory must be specified") | 61 raise Exception("jinja directory must be specified") |
| 62 jinja_dir = jinja_dir.decode('utf8') |
62 output_base = arg_options.output_base | 63 output_base = arg_options.output_base |
63 if not output_base: | 64 if not output_base: |
64 raise Exception("Base output directory must be specified") | 65 raise Exception("Base output directory must be specified") |
| 66 output_base = output_base.decode('utf8') |
65 config_file = arg_options.config | 67 config_file = arg_options.config |
66 if not config_file: | 68 if not config_file: |
67 raise Exception("Config file name must be specified") | 69 raise Exception("Config file name must be specified") |
| 70 config_file = config_file.decode('utf8') |
68 config_base = os.path.dirname(config_file) | 71 config_base = os.path.dirname(config_file) |
69 config_values = arg_options.config_value | 72 config_values = arg_options.config_value |
70 if not config_values: | 73 if not config_values: |
71 config_values = [] | 74 config_values = [] |
72 except Exception: | 75 except Exception: |
73 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h
tml | 76 # Work with python 2 and 3 http://docs.python.org/py3k/howto/pyporting.h
tml |
74 exc = sys.exc_info()[1] | 77 exc = sys.exc_info()[1] |
75 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) | 78 sys.stderr.write("Failed to parse command-line arguments: %s\n\n" % exc) |
76 exit(1) | 79 exit(1) |
77 | 80 |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 if up_to_date: | 596 if up_to_date: |
594 sys.exit() | 597 sys.exit() |
595 | 598 |
596 for file_name, content in outputs.iteritems(): | 599 for file_name, content in outputs.iteritems(): |
597 out_file = open(file_name, "w") | 600 out_file = open(file_name, "w") |
598 out_file.write(content) | 601 out_file.write(content) |
599 out_file.close() | 602 out_file.close() |
600 | 603 |
601 | 604 |
602 main() | 605 main() |
OLD | NEW |