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

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

Issue 56083005: Docserver: Cleanup to remove the APIListDataSource dependency from (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 from operator import itemgetter 5 from operator import itemgetter
6 import os 6 import os
7 7
8 from third_party.json_schema_compiler.json_parse import Parse 8 from third_party.json_schema_compiler.json_parse import Parse
9 import third_party.json_schema_compiler.model as model 9 import third_party.json_schema_compiler.model as model
10 import docs_server_utils as utils 10 import docs_server_utils as utils
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 'extensions': MakeDictForPlatform('extensions') 91 'extensions': MakeDictForPlatform('extensions')
92 } 92 }
93 93
94 def Create(self): 94 def Create(self):
95 return APIListDataSource(self, self._object_store_creator) 95 return APIListDataSource(self, self._object_store_creator)
96 96
97 def __init__(self, factory, object_store_creator): 97 def __init__(self, factory, object_store_creator):
98 self._factory = factory 98 self._factory = factory
99 self._object_store = object_store_creator.Create(APIListDataSource) 99 self._object_store = object_store_creator.Create(APIListDataSource)
100 100
101 def GetAllNames(self):
102 apis = []
103 for platform in ['apps', 'extensions']:
104 for category in ['chrome', 'experimental', 'private']:
105 apis.extend(self.get(platform).get(category))
106 return [api['name'] for api in apis]
107
108 def _GetCachedAPIData(self): 101 def _GetCachedAPIData(self):
109 data = self._object_store.Get('api_data').Get() 102 data = self._object_store.Get('api_data').Get()
110 if data is None: 103 if data is None:
111 data = self._factory._GenerateAPIDict() 104 data = self._factory._GenerateAPIDict()
112 self._object_store.Set('api_data', data) 105 self._object_store.Set('api_data', data)
113 return data 106 return data
114 107
115 def get(self, key): 108 def get(self, key):
116 return self._GetCachedAPIData().get(key) 109 return self._GetCachedAPIData().get(key)
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/api_data_source_test.py ('k') | chrome/common/extensions/docs/server2/app.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698