OLD | NEW |
---|---|
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 logging | 5 import logging |
6 import os | 6 import os |
7 import posixpath | 7 import posixpath |
8 | 8 |
9 from compiled_file_system import SingleFile | 9 from compiled_file_system import SingleFile |
10 from file_system import FileNotFoundError | 10 from file_system import FileNotFoundError |
11 from future import Gettable, Future | 11 from future import Gettable, Future |
12 from schema_util import ProcessSchema | 12 from schema_util import ProcessSchema |
13 from svn_constants import API_PATH | 13 from svn_constants import API_PATH |
14 from third_party.json_schema_compiler.model import Namespace, UnixName | 14 from third_party.json_schema_compiler.model import Namespace, UnixName |
15 | 15 |
16 | 16 |
17 @SingleFile | 17 @SingleFile |
18 def _CreateAPIModel(path, data): | 18 def _CreateAPIModel(path, data): |
19 schema = ProcessSchema(path, data) | 19 schema = ProcessSchema(path, data) |
20 if os.path.splitext(path)[1] == '.json': | 20 if os.path.splitext(path)[1] == '.json': |
21 schema = schema[0] | 21 schema = schema[0] |
22 if not schema: return None | |
not at google - send to devlin
2013/11/10 01:39:57
Ok. Please reference crbug.com/317197 here.
hukun
2013/11/11 10:23:03
Done
| |
22 return Namespace(schema, schema['namespace']) | 23 return Namespace(schema, schema['namespace']) |
23 | 24 |
24 | 25 |
25 class APIModels(object): | 26 class APIModels(object): |
26 '''Tracks APIs and their Models. | 27 '''Tracks APIs and their Models. |
27 ''' | 28 ''' |
28 | 29 |
29 def __init__(self, features_bundle, compiled_fs_factory, file_system): | 30 def __init__(self, features_bundle, compiled_fs_factory, file_system): |
30 self._features_bundle = features_bundle | 31 self._features_bundle = features_bundle |
31 self._model_cache = compiled_fs_factory.Create( | 32 self._model_cache = compiled_fs_factory.Create( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
66 (API_PATH, file_name, ext)) | 67 (API_PATH, file_name, ext)) |
67 for ext in ('json', 'idl')] | 68 for ext in ('json', 'idl')] |
68 def resolve(): | 69 def resolve(): |
69 for future in futures: | 70 for future in futures: |
70 try: | 71 try: |
71 return future.Get() | 72 return future.Get() |
72 except FileNotFoundError: pass | 73 except FileNotFoundError: pass |
73 # Propagate the first FileNotFoundError if neither were found. | 74 # Propagate the first FileNotFoundError if neither were found. |
74 futures[0].Get() | 75 futures[0].Get() |
75 return Future(delegate=Gettable(resolve)) | 76 return Future(delegate=Gettable(resolve)) |
OLD | NEW |