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

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

Issue 14267024: Devserver: have a separate ObjectStore namespace (both memcache and datastore) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove _CheckVersions Created 7 years, 8 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 copy 5 import copy
6 import logging 6 import logging
7 import os 7 import os
8 8
9 import third_party.json_schema_compiler.json_parse as json_parse 9 import third_party.json_schema_compiler.json_parse as json_parse
10 import third_party.json_schema_compiler.model as model 10 import third_party.json_schema_compiler.model as model
11 import third_party.json_schema_compiler.idl_schema as idl_schema 11 import third_party.json_schema_compiler.idl_schema as idl_schema
12 import third_party.json_schema_compiler.idl_parser as idl_parser 12 import third_party.json_schema_compiler.idl_parser as idl_parser
13 13
14 # Increment this if the data model changes for APIDataSource.
15 # This would include changes to model.py in json_schema_compiler!
16 _VERSION = 17
17
18 def _RemoveNoDocs(item): 14 def _RemoveNoDocs(item):
19 if json_parse.IsDict(item): 15 if json_parse.IsDict(item):
20 if item.get('nodoc', False): 16 if item.get('nodoc', False):
21 return True 17 return True
22 for key, value in item.items(): 18 for key, value in item.items():
23 if _RemoveNoDocs(value): 19 if _RemoveNoDocs(value):
24 del item[key] 20 del item[key]
25 elif type(item) == list: 21 elif type(item) == list:
26 to_remove = [] 22 to_remove = []
27 for i in item: 23 for i in item:
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 def get(self, key): 255 def get(self, key):
260 return self._samples.FilterSamples(key, self._api_name) 256 return self._samples.FilterSamples(key, self._api_name)
261 257
262 class APIDataSource(object): 258 class APIDataSource(object):
263 """This class fetches and loads JSON APIs from the FileSystem passed in with 259 """This class fetches and loads JSON APIs from the FileSystem passed in with
264 |compiled_fs_factory|, so the APIs can be plugged into templates. 260 |compiled_fs_factory|, so the APIs can be plugged into templates.
265 """ 261 """
266 class Factory(object): 262 class Factory(object):
267 def __init__(self, compiled_fs_factory, base_path): 263 def __init__(self, compiled_fs_factory, base_path):
268 def create_compiled_fs(fn, category): 264 def create_compiled_fs(fn, category):
269 return compiled_fs_factory.Create( 265 return compiled_fs_factory.Create(fn, APIDataSource, category=category)
270 fn, APIDataSource, category=category, version=_VERSION)
271 266
272 self._permissions_cache = create_compiled_fs(self._LoadPermissions, 267 self._permissions_cache = create_compiled_fs(self._LoadPermissions,
273 'permissions') 268 'permissions')
274 269
275 self._json_cache = create_compiled_fs( 270 self._json_cache = create_compiled_fs(
276 lambda api_name, api: self._LoadJsonAPI(api, False), 271 lambda api_name, api: self._LoadJsonAPI(api, False),
277 'json') 272 'json')
278 self._idl_cache = create_compiled_fs( 273 self._idl_cache = create_compiled_fs(
279 lambda api_name, api: self._LoadIdlAPI(api, False), 274 lambda api_name, api: self._LoadIdlAPI(api, False),
280 'idl') 275 'idl')
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if self._disable_refs: 436 if self._disable_refs:
442 cache, ext = ( 437 cache, ext = (
443 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else 438 (self._idl_cache_no_refs, '.idl') if (unix_name in idl_names) else
444 (self._json_cache_no_refs, '.json')) 439 (self._json_cache_no_refs, '.json'))
445 else: 440 else:
446 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else 441 cache, ext = ((self._idl_cache, '.idl') if (unix_name in idl_names) else
447 (self._json_cache, '.json')) 442 (self._json_cache, '.json'))
448 return self._GenerateHandlebarContext( 443 return self._GenerateHandlebarContext(
449 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)), 444 cache.GetFromFile('%s/%s%s' % (self._base_path, unix_name, ext)),
450 path) 445 path)
OLDNEW
« no previous file with comments | « chrome/common/extensions/PRESUBMIT.py ('k') | chrome/common/extensions/docs/server2/api_data_source_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698