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

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

Issue 26538009: Docserver: make file_system a property of Create (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: niggles Created 7 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 features_utility 5 import features_utility
6 import svn_constants 6 import svn_constants
7 from third_party.json_schema_compiler.json_parse import Parse 7 from third_party.json_schema_compiler.json_parse import Parse
8 8
9 9
10 def _AddPlatformsFromDependencies(feature, features_bundle): 10 def _AddPlatformsFromDependencies(feature, features_bundle):
(...skipping 14 matching lines...) Expand all
25 # so is this feature. 25 # so is this feature.
26 if dependency_feature is None: 26 if dependency_feature is None:
27 return [] 27 return []
28 platforms = platforms.union(dependency_feature['platforms']) 28 platforms = platforms.union(dependency_feature['platforms'])
29 feature['platforms'] = list(platforms) 29 feature['platforms'] = list(platforms)
30 30
31 31
32 class _FeaturesCache(object): 32 class _FeaturesCache(object):
33 def __init__(self, file_system, compiled_fs_factory, *json_paths): 33 def __init__(self, file_system, compiled_fs_factory, *json_paths):
34 self._file_system = file_system 34 self._file_system = file_system
35 self._cache = compiled_fs_factory.Create(self._CreateCache, type(self)) 35 self._cache = compiled_fs_factory.Create(
36 file_system, self._CreateCache, type(self))
36 self._json_path = json_paths[0] 37 self._json_path = json_paths[0]
37 self._extra_paths = json_paths[1:] 38 self._extra_paths = json_paths[1:]
38 39
39 def _CreateCache(self, _, features_json): 40 def _CreateCache(self, _, features_json):
40 features = features_utility.Parse(Parse(features_json)) 41 features = features_utility.Parse(Parse(features_json))
41 for path in self._extra_paths: 42 for path in self._extra_paths:
42 extra_json = self._file_system.ReadSingle(path).Get() 43 extra_json = self._file_system.ReadSingle(path).Get()
43 features = features_utility.MergedWith( 44 features = features_utility.MergedWith(
44 features_utility.Parse(Parse(extra_json)), features) 45 features_utility.Parse(Parse(extra_json)), features)
45 return features 46 return features
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 api_features = self._api_cache.GetFeatures() 83 api_features = self._api_cache.GetFeatures()
83 # TODO(rockot): Handle inter-API dependencies more gracefully. 84 # TODO(rockot): Handle inter-API dependencies more gracefully.
84 # Not yet a problem because there is only one such case (windows -> tabs). 85 # Not yet a problem because there is only one such case (windows -> tabs).
85 # If we don't store this value before annotating platforms, inter-API 86 # If we don't store this value before annotating platforms, inter-API
86 # dependencies will lead to infinite recursion. 87 # dependencies will lead to infinite recursion.
87 self._object_store.Set('api_features', api_features) 88 self._object_store.Set('api_features', api_features)
88 for feature in api_features.itervalues(): 89 for feature in api_features.itervalues():
89 _AddPlatformsFromDependencies(feature, self) 90 _AddPlatformsFromDependencies(feature, self)
90 self._object_store.Set('api_features', api_features) 91 self._object_store.Set('api_features', api_features)
91 return api_features 92 return api_features
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/example_zipper_test.py ('k') | chrome/common/extensions/docs/server2/file_system.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698