| 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 logging | 5 import logging |
| 6 import os | 6 import os |
| 7 | 7 |
| 8 from file_system import FileNotFoundError | |
| 9 import third_party.json_schema_compiler.model as model | 8 import third_party.json_schema_compiler.model as model |
| 10 import docs_server_utils as utils | 9 import docs_server_utils as utils |
| 11 | 10 |
| 12 # Increment this if the data model changes for APIDataSource. | 11 # Increment this if the data model changes for APIDataSource. |
| 13 _VERSION = 1 | 12 _VERSION = 1 |
| 14 | 13 |
| 15 # These files are special cases that shouldn't be in the API list. | 14 # These files are special cases that shouldn't be in the API list. |
| 16 IGNORED_FILES = [ | 15 IGNORED_FILES = [ |
| 17 'devtools' | 16 'devtools' |
| 18 ] | 17 ] |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 self._api_path = api_path | 77 self._api_path = api_path |
| 79 | 78 |
| 80 def GetAllNames(self): | 79 def GetAllNames(self): |
| 81 names = [] | 80 names = [] |
| 82 for platform in ['apps', 'extensions']: | 81 for platform in ['apps', 'extensions']: |
| 83 for category in ['chrome', 'experimental']: | 82 for category in ['chrome', 'experimental']: |
| 84 names.extend(self.get(platform).get(category)) | 83 names.extend(self.get(platform).get(category)) |
| 85 return [api_name['name'] for api_name in names] | 84 return [api_name['name'] for api_name in names] |
| 86 | 85 |
| 87 def get(self, key): | 86 def get(self, key): |
| 88 try: | 87 return self._compiled_fs.GetFromFileListing(self._api_path)[key] |
| 89 return self._compiled_fs.GetFromFileListing(self._api_path)[key] | |
| 90 except FileNotFoundError as e: | |
| 91 raise ValueError('%s: Error listing files for "%s".' % (e, key)) | |
| OLD | NEW |