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

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

Issue 22824042: Docserver: SidenavDataSource refactor, transition to DataSourceRegistry (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 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
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 from data_source import DataSource 5 from data_source import DataSource
6 from third_party.json_schema_compiler.json_parse import Parse 6 from third_party.json_schema_compiler.json_parse import Parse
7 7
8 class StringsDataSource(DataSource): 8 class StringsDataSource(DataSource):
9 '''Provides templates with access to a key to string mapping defined in a 9 '''Provides templates with access to a key to string mapping defined in a
10 JSON configuration file. 10 JSON configuration file.
11 ''' 11 '''
12 def __init__(self, server_instance): 12 def __init__(self, server_instance, _):
13 self._cache = server_instance.compiled_host_fs_factory.Create( 13 self._cache = server_instance.compiled_host_fs_factory.Create(
14 lambda _, strings_json: Parse(strings_json), StringsDataSource) 14 lambda _, strings_json: Parse(strings_json), StringsDataSource)
15 self._strings_json_path = server_instance.strings_json_path 15 self._strings_json_path = server_instance.strings_json_path
16 16
17 def Cron(self): 17 def Cron(self):
18 self._cache.GetFromFile(self._strings_json_path) 18 self._cache.GetFromFile(self._strings_json_path)
19 19
20 def get(self, key): 20 def get(self, key):
21 return self._cache.GetFromFile(self._strings_json_path)[key] 21 return self._cache.GetFromFile(self._strings_json_path)[key]
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698