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 json | 5 import json |
| 6 import logging |
6 import os | 7 import os |
7 | 8 |
8 from handlebar_dict_generator import HandlebarDictGenerator | 9 from handlebar_dict_generator import HandlebarDictGenerator |
9 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater | 10 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater |
10 import third_party.json_schema_compiler.model as model | 11 import third_party.json_schema_compiler.model as model |
11 import third_party.json_schema_compiler.idl_schema as idl_schema | 12 import third_party.json_schema_compiler.idl_schema as idl_schema |
12 import third_party.json_schema_compiler.idl_parser as idl_parser | 13 import third_party.json_schema_compiler.idl_parser as idl_parser |
13 | 14 |
14 class APIDataSource(object): | 15 class APIDataSource(object): |
15 """This class fetches and loads JSON APIs with the fetcher passed in with | 16 """This class fetches and loads JSON APIs with the fetcher passed in with |
(...skipping 20 matching lines...) Expand all Loading... |
36 def get(self, key): | 37 def get(self, key): |
37 path, ext = os.path.splitext(key) | 38 path, ext = os.path.splitext(key) |
38 unix_name = model.UnixName(path) | 39 unix_name = model.UnixName(path) |
39 json_path = unix_name + '.json' | 40 json_path = unix_name + '.json' |
40 idl_path = unix_name + '.idl' | 41 idl_path = unix_name + '.idl' |
41 try: | 42 try: |
42 return self._json_cache.GetFromFile(self._base_path + '/' + json_path) | 43 return self._json_cache.GetFromFile(self._base_path + '/' + json_path) |
43 except Exception: | 44 except Exception: |
44 try: | 45 try: |
45 return self._idl_cache.GetFromFile(self._base_path + '/' + idl_path) | 46 return self._idl_cache.GetFromFile(self._base_path + '/' + idl_path) |
46 except Exception: | 47 except Exception as e: |
| 48 logging.warn(e) |
47 return None | 49 return None |
OLD | NEW |