OLD | NEW |
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 json | 5 import json |
6 | 6 |
7 from data_source import DataSource | 7 from data_source import DataSource |
8 import features_utility | 8 import features_utility |
9 from manifest_features import CreateManifestFeatures, ConvertDottedKeysToNested | 9 from manifest_features import CreateManifestFeatures, ConvertDottedKeysToNested |
10 from third_party.json_schema_compiler.json_parse import Parse | 10 from third_party.json_schema_compiler.json_parse import Parse |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 annotate(level, item['children']) | 92 annotate(level, item['children']) |
93 if features: | 93 if features: |
94 features[-1]['is_last'] = True | 94 features[-1]['is_last'] = True |
95 | 95 |
96 annotate('required', features) | 96 annotate('required', features) |
97 return features | 97 return features |
98 | 98 |
99 class ManifestDataSource(DataSource): | 99 class ManifestDataSource(DataSource): |
100 '''Provides access to the properties in manifest features. | 100 '''Provides access to the properties in manifest features. |
101 ''' | 101 ''' |
102 def __init__(self, server_instance): | 102 def __init__(self, server_instance, _): |
103 self._manifest_path = server_instance.manifest_json_path | 103 self._manifest_path = server_instance.manifest_json_path |
104 self._features_path = server_instance.manifest_features_path | 104 self._features_path = server_instance.manifest_features_path |
105 self._file_system = server_instance.host_file_system | 105 self._file_system = server_instance.host_file_system |
106 self._cache = server_instance.compiled_host_fs_factory.Create( | 106 self._cache = server_instance.compiled_host_fs_factory.Create( |
107 self._CreateManifestData, ManifestDataSource) | 107 self._CreateManifestData, ManifestDataSource) |
108 | 108 |
109 def _CreateManifestData(self, _, content): | 109 def _CreateManifestData(self, _, content): |
110 '''Combine the contents of |_manifest_path| and |_features_path| and filter | 110 '''Combine the contents of |_manifest_path| and |_features_path| and filter |
111 the results into lists specific to apps or extensions for templates. Marks | 111 the results into lists specific to apps or extensions for templates. Marks |
112 up features with annotations. | 112 up features with annotations. |
(...skipping 13 matching lines...) Expand all Loading... |
126 'apps': for_templates(manifest_features, 'app'), | 126 'apps': for_templates(manifest_features, 'app'), |
127 'extensions': for_templates(manifest_features, 'extension') | 127 'extensions': for_templates(manifest_features, 'extension') |
128 } | 128 } |
129 | 129 |
130 def Cron(self): | 130 def Cron(self): |
131 self._cache.GetFromFile(self._features_path) | 131 self._cache.GetFromFile(self._features_path) |
132 self._file_system.ReadSingle(self._manifest_path) | 132 self._file_system.ReadSingle(self._manifest_path) |
133 | 133 |
134 def get(self, key): | 134 def get(self, key): |
135 return self._cache.GetFromFile(self._features_path)[key] | 135 return self._cache.GetFromFile(self._features_path)[key] |
OLD | NEW |