| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """The frontend for the Mojo bindings system.""" | 6 """The frontend for the Mojo bindings system.""" |
| 7 | 7 |
| 8 | 8 |
| 9 import argparse | 9 import argparse |
| 10 import imp | 10 import imp |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 if rel_filename.path in imported_filename_stack: | 190 if rel_filename.path in imported_filename_stack: |
| 191 print "%s: Error: Circular dependency" % rel_filename.path + \ | 191 print "%s: Error: Circular dependency" % rel_filename.path + \ |
| 192 MakeImportStackMessage(imported_filename_stack + [rel_filename.path]) | 192 MakeImportStackMessage(imported_filename_stack + [rel_filename.path]) |
| 193 sys.exit(1) | 193 sys.exit(1) |
| 194 | 194 |
| 195 try: | 195 try: |
| 196 with open(rel_filename.path) as f: | 196 with open(rel_filename.path) as f: |
| 197 source = f.read() | 197 source = f.read() |
| 198 except IOError as e: | 198 except IOError as e: |
| 199 print "%s: Error: %s" % (e.rel_filename.path, e.strerror) + \ | 199 print "%s: Error: %s" % (rel_filename.path, e.strerror) + \ |
| 200 MakeImportStackMessage(imported_filename_stack + [rel_filename.path]) | 200 MakeImportStackMessage(imported_filename_stack + [rel_filename.path]) |
| 201 sys.exit(1) | 201 sys.exit(1) |
| 202 | 202 |
| 203 try: | 203 try: |
| 204 tree = Parse(source, rel_filename.path) | 204 tree = Parse(source, rel_filename.path) |
| 205 except Error as e: | 205 except Error as e: |
| 206 full_stack = imported_filename_stack + [rel_filename.path] | 206 full_stack = imported_filename_stack + [rel_filename.path] |
| 207 print str(e) + MakeImportStackMessage(full_stack) | 207 print str(e) + MakeImportStackMessage(full_stack) |
| 208 sys.exit(1) | 208 sys.exit(1) |
| 209 | 209 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 "-o", "--output_dir", dest="output_dir", default=".", | 310 "-o", "--output_dir", dest="output_dir", default=".", |
| 311 help="output directory for precompiled templates") | 311 help="output directory for precompiled templates") |
| 312 precompile_parser.set_defaults(func=_Precompile) | 312 precompile_parser.set_defaults(func=_Precompile) |
| 313 | 313 |
| 314 args, remaining_args = parser.parse_known_args() | 314 args, remaining_args = parser.parse_known_args() |
| 315 return args.func(args, remaining_args) | 315 return args.func(args, remaining_args) |
| 316 | 316 |
| 317 | 317 |
| 318 if __name__ == "__main__": | 318 if __name__ == "__main__": |
| 319 sys.exit(main()) | 319 sys.exit(main()) |
| OLD | NEW |