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

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

Issue 498813002: Rename the docserver third_party dependency "handlebar" to "motemplate", as part (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: imports Created 6 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 (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 sys 5 import sys
6 6
7 import schema_util 7 import schema_util
8 from docs_server_utils import ToUnicode 8 from docs_server_utils import ToUnicode
9 from file_system import FileNotFoundError 9 from file_system import FileNotFoundError
10 from future import Future 10 from future import Future
11 from path_util import AssertIsDirectory, AssertIsFile, ToDirectory 11 from path_util import AssertIsDirectory, AssertIsFile, ToDirectory
12 from third_party.handlebar import Handlebar
13 from third_party.json_schema_compiler import json_parse 12 from third_party.json_schema_compiler import json_parse
14 from third_party.json_schema_compiler.memoize import memoize 13 from third_party.json_schema_compiler.memoize import memoize
14 from third_party.motemplate import Motemplate
15 15
16 16
17 _SINGLE_FILE_FUNCTIONS = set() 17 _SINGLE_FILE_FUNCTIONS = set()
18 18
19 19
20 def SingleFile(fn): 20 def SingleFile(fn):
21 '''A decorator which can be optionally applied to the compilation function 21 '''A decorator which can be optionally applied to the compilation function
22 passed to CompiledFileSystem.Create, indicating that the function only 22 passed to CompiledFileSystem.Create, indicating that the function only
23 needs access to the file which is given in the function's callback. When 23 needs access to the file which is given in the function's callback. When
24 this is the case some optimisations can be done. 24 this is the case some optimisations can be done.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 json_parse.Parse(ToUnicode(data))), 104 json_parse.Parse(ToUnicode(data))),
105 CompiledFileSystem, 105 CompiledFileSystem,
106 category='json') 106 category='json')
107 107
108 @memoize 108 @memoize
109 def ForTemplates(self, file_system): 109 def ForTemplates(self, file_system):
110 '''Creates a CompiledFileSystem for parsing templates. 110 '''Creates a CompiledFileSystem for parsing templates.
111 ''' 111 '''
112 return self.Create( 112 return self.Create(
113 file_system, 113 file_system,
114 SingleFile(lambda path, text: Handlebar(ToUnicode(text), name=path)), 114 SingleFile(lambda path, text: Motemplate(ToUnicode(text), name=path)),
115 CompiledFileSystem) 115 CompiledFileSystem)
116 116
117 @memoize 117 @memoize
118 def ForUnicode(self, file_system): 118 def ForUnicode(self, file_system):
119 '''Creates a CompiledFileSystem for Unicode text processing. 119 '''Creates a CompiledFileSystem for Unicode text processing.
120 ''' 120 '''
121 return self.Create( 121 return self.Create(
122 file_system, 122 file_system,
123 SingleFile(lambda _, text: ToUnicode(text)), 123 SingleFile(lambda _, text: ToUnicode(text)),
124 CompiledFileSystem, 124 CompiledFileSystem,
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 cache_entry = self._list_object_store.Get(path).Get() 240 cache_entry = self._list_object_store.Get(path).Get()
241 if cache_entry is not None: 241 if cache_entry is not None:
242 return cache_entry.version 242 return cache_entry.version
243 return self._file_system.Stat(path).version 243 return self._file_system.Stat(path).version
244 244
245 def FileExists(self, path): 245 def FileExists(self, path):
246 return self._file_system.Exists(path) 246 return self._file_system.Exists(path)
247 247
248 def GetIdentity(self): 248 def GetIdentity(self):
249 return self._file_system.GetIdentity() 249 return self._file_system.GetIdentity()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/build_server.py ('k') | chrome/common/extensions/docs/server2/content_provider.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698