Index: chrome/common/extensions/docs/server2/compiled_file_system_source.py |
diff --git a/chrome/common/extensions/docs/server2/compiled_file_system_source.py b/chrome/common/extensions/docs/server2/compiled_file_system_source.py |
new file mode 100644 |
index 0000000000000000000000000000000000000000..aa6128e66f770206f0f4d5799c8db6f43a1b3969 |
--- /dev/null |
+++ b/chrome/common/extensions/docs/server2/compiled_file_system_source.py |
@@ -0,0 +1,21 @@ |
+# Copyright (c) 2012 The Chromium Authors. All rights reserved. |
not at google - send to devlin
2013/04/30 16:21:09
(c) 2012 -> 2013. Check other files too.
jshumway
2013/05/03 03:44:39
Correct in new file.
|
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import os |
+ |
+class CompiledFileSystemSource(object): |
not at google - send to devlin
2013/04/30 16:21:09
Anything more complicated than the Identity functi
jshumway
2013/05/03 03:44:39
I replaced this class with ManifestDataSource. It
not at google - send to devlin
2013/05/03 15:56:24
Any amount of > 0 triviality is worth testing, and
jshumway
2013/05/10 02:08:36
Done.
|
+ """ Exposes a CompiledFileSystem to a template. |
+ """ |
+ def __init__(self, compiled_fs, basepath, transformer): |
+ """ |transformer| is a function that takes one argument, the key a template |
+ is looking up, and returns a new key. |basepath| is then prepended to the |
+ new key and the result is used to lookup a document in |complied_fs|. |
+ """ |
+ self.compiled_fs = compiled_fs |
+ self.basepath = basepath |
+ self.transformer = transformer |
+ |
+ def get(self, key): |
+ return self.compiled_fs.GetFromFile( |
+ os.path.join(self.basepath, self.transformer(key))) |