| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 | 5 import os |
| 6 import sys | 6 import sys |
| 7 | 7 |
| 8 import idl_schema | 8 import idl_schema |
| 9 import json_schema | 9 import json_schema |
| 10 from model import Model | 10 from model import Model |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 def LoadSchema(self, schema): | 39 def LoadSchema(self, schema): |
| 40 schema_filename, schema_extension = os.path.splitext(schema) | 40 schema_filename, schema_extension = os.path.splitext(schema) |
| 41 | 41 |
| 42 if schema_extension == '.json': | 42 if schema_extension == '.json': |
| 43 api_defs = json_schema.Load(schema) | 43 api_defs = json_schema.Load(schema) |
| 44 elif schema_extension == '.idl': | 44 elif schema_extension == '.idl': |
| 45 api_defs = idl_schema.Load(schema) | 45 api_defs = idl_schema.Load(schema) |
| 46 else: | 46 else: |
| 47 sys.exit('Did not recognize file extension %s for schema %s' % | 47 sys.exit('Did not recognize file extension %s for schema %s' % |
| 48 (schema_extension, schema)) | 48 (schema_extension, schema)) |
| 49 if len(api_defs) != 1: | |
| 50 sys.exit('File %s has multiple schemas. Files are only allowed to contain' | |
| 51 'a single schema.' % schema) | |
| 52 | 49 |
| 53 return api_defs | 50 return api_defs |
| OLD | NEW |