Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: chrome/common/extensions/docs/server2/api_list_data_source.py

Issue 10830252: Extensions Docs Server: Uniform handling of file not found errors (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 6
7 from file_system import FileNotFoundError
7 import third_party.json_schema_compiler.model as model 8 import third_party.json_schema_compiler.model as model
8 from docs_server_utils import SanitizeAPIName 9 from docs_server_utils import SanitizeAPIName
9 10
10 class APIListDataSource(object): 11 class APIListDataSource(object):
11 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs 12 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs
12 that are used in the api_index.html and experimental.html pages. 13 that are used in the api_index.html and experimental.html pages.
13 """ 14 """
14 def __init__(self, cache_builder, file_system, api_path, public_path): 15 def __init__(self, cache_builder, file_system, api_path, public_path):
15 self._cache = cache_builder.build(self._ListAPIs) 16 self._cache = cache_builder.build(self._ListAPIs)
16 self._file_system = file_system 17 self._file_system = file_system
(...skipping 28 matching lines...) Expand all
45 'apps': self._GetAPIsInSubdirectory(api_names, 'apps'), 46 'apps': self._GetAPIsInSubdirectory(api_names, 'apps'),
46 'extensions': self._GetAPIsInSubdirectory(api_names, 'extensions') 47 'extensions': self._GetAPIsInSubdirectory(api_names, 'extensions')
47 } 48 }
48 49
49 def __getitem__(self, key): 50 def __getitem__(self, key):
50 return self.get(key) 51 return self.get(key)
51 52
52 def get(self, key): 53 def get(self, key):
53 try: 54 try:
54 return self._cache.GetFromFileListing(self._api_path)[key] 55 return self._cache.GetFromFileListing(self._api_path)[key]
55 except Exception as e: 56 except FileNotFoundError:
not at google - send to devlin 2012/08/10 06:12:16 log error?
cduvall 2012/08/10 17:25:16 Done.
not at google - send to devlin 2012/08/12 22:22:58 By the same logic as ApiDataSource we shouldn't ca
cduvall 2012/08/13 18:44:05 Used the error as a string plus a more specific me
56 return None 57 return None
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698