| 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 logging | 5 import logging |
| 6 | 6 |
| 7 from path_utils import FormatKey | 7 from path_utils import FormatKey |
| 8 from third_party.handlebar import Handlebar | 8 from third_party.handlebar import Handlebar |
| 9 | 9 |
| 10 EXTENSIONS_URL = '/chrome/extensions' | 10 EXTENSIONS_URL = '/chrome/extensions' |
| 11 | 11 |
| 12 def _MakeBranchDict(branch): | 12 def _MakeBranchDict(branch): |
| 13 return { | 13 return { |
| 14 'showWarning': branch != 'stable', | 14 'showWarning': branch != 'stable', |
| 15 'branches': [ | 15 'branches': [ |
| 16 { 'name': 'Stable', 'path': EXTENSIONS_URL + '/stable' }, | 16 { 'name': 'Stable', 'path': 'stable' }, |
| 17 { 'name': 'Dev', 'path': EXTENSIONS_URL + '/dev' }, | 17 { 'name': 'Dev', 'path': 'dev' }, |
| 18 { 'name': 'Beta', 'path': EXTENSIONS_URL + '/beta' }, | 18 { 'name': 'Beta', 'path': 'beta' }, |
| 19 { 'name': 'Trunk', 'path': EXTENSIONS_URL + '/trunk' } | 19 { 'name': 'Trunk', 'path': 'trunk' } |
| 20 ], | 20 ], |
| 21 'current': branch | 21 'current': branch |
| 22 } | 22 } |
| 23 | 23 |
| 24 class TemplateDataSource(object): | 24 class TemplateDataSource(object): |
| 25 """Renders Handlebar templates, providing them with the context in which to | 25 """Renders Handlebar templates, providing them with the context in which to |
| 26 render. | 26 render. |
| 27 | 27 |
| 28 Also acts as a data source itself, providing partial Handlebar templates to | 28 Also acts as a data source itself, providing partial Handlebar templates to |
| 29 those it renders. | 29 those it renders. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 def get(self, key): | 118 def get(self, key): |
| 119 return self.GetTemplate(self._private_template_path, key) | 119 return self.GetTemplate(self._private_template_path, key) |
| 120 | 120 |
| 121 def GetTemplate(self, base_path, template_name): | 121 def GetTemplate(self, base_path, template_name): |
| 122 real_path = FormatKey(template_name) | 122 real_path = FormatKey(template_name) |
| 123 try: | 123 try: |
| 124 return self._cache.GetFromFile(base_path + '/' + real_path) | 124 return self._cache.GetFromFile(base_path + '/' + real_path) |
| 125 except Exception as e: | 125 except Exception as e: |
| 126 logging.warn(e) | 126 logging.warn(e) |
| 127 return None | 127 return None |
| OLD | NEW |