| OLD | NEW |
| 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 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 '''A CompiledFileSystem specifically for parsing JSON configuration data. | 99 '''A CompiledFileSystem specifically for parsing JSON configuration data. |
| 100 These are memoized over file systems tied to different branches. | 100 These are memoized over file systems tied to different branches. |
| 101 ''' | 101 ''' |
| 102 return self.Create(file_system, | 102 return self.Create(file_system, |
| 103 SingleFile(lambda _, data: | 103 SingleFile(lambda _, data: |
| 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 ForAPISchema(self, file_system): | |
| 110 '''Creates a CompiledFileSystem for parsing raw JSON or IDL API schema | |
| 111 data and formatting it so that it can be used by other classes, such | |
| 112 as Model and APISchemaGraph. | |
| 113 ''' | |
| 114 return self.Create(file_system, | |
| 115 SingleFile(Unicode(schema_util.ProcessSchema)), | |
| 116 CompiledFileSystem, | |
| 117 category='api-schema') | |
| 118 | |
| 119 @memoize | |
| 120 def ForTemplates(self, file_system): | 109 def ForTemplates(self, file_system): |
| 121 '''Creates a CompiledFileSystem for parsing templates. | 110 '''Creates a CompiledFileSystem for parsing templates. |
| 122 ''' | 111 ''' |
| 123 return self.Create( | 112 return self.Create( |
| 124 file_system, | 113 file_system, |
| 125 SingleFile(lambda path, text: Handlebar(ToUnicode(text), name=path)), | 114 SingleFile(lambda path, text: Handlebar(ToUnicode(text), name=path)), |
| 126 CompiledFileSystem) | 115 CompiledFileSystem) |
| 127 | 116 |
| 128 @memoize | 117 @memoize |
| 129 def ForUnicode(self, file_system): | 118 def ForUnicode(self, file_system): |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 cache_entry = self._list_object_store.Get(path).Get() | 247 cache_entry = self._list_object_store.Get(path).Get() |
| 259 if cache_entry is not None: | 248 if cache_entry is not None: |
| 260 return cache_entry.version | 249 return cache_entry.version |
| 261 return self._file_system.Stat(path).version | 250 return self._file_system.Stat(path).version |
| 262 | 251 |
| 263 def FileExists(self, path): | 252 def FileExists(self, path): |
| 264 return self._file_system.Exists(path) | 253 return self._file_system.Exists(path) |
| 265 | 254 |
| 266 def GetIdentity(self): | 255 def GetIdentity(self): |
| 267 return self._file_system.GetIdentity() | 256 return self._file_system.GetIdentity() |
| OLD | NEW |