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 json | 5 import json |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 from file_system import FileNotFoundError | 9 from file_system import FileNotFoundError |
10 from handlebar_dict_generator import HandlebarDictGenerator | 10 from handlebar_dict_generator import HandlebarDictGenerator |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 api_perms = perms.get(path, None) | 78 api_perms = perms.get(path, None) |
79 if api_perms is None: | 79 if api_perms is None: |
80 return None | 80 return None |
81 if api_perms['channel'] == 'dev': | 81 if api_perms['channel'] == 'dev': |
82 api_perms['dev'] = True | 82 api_perms['dev'] = True |
83 return api_perms | 83 return api_perms |
84 | 84 |
85 def _GenerateHandlebarContext(self, handlebar, path): | 85 def _GenerateHandlebarContext(self, handlebar, path): |
86 return_dict = { | 86 return_dict = { |
87 'permissions': self._GetFeature(path), | 87 'permissions': self._GetFeature(path), |
88 'samples': _LazySamplesGetter(path, self._samples) | 88 # Disabled to help with performance until we figure out |
| 89 # http://crbug.com/142011. |
| 90 'samples': None # _LazySamplesGetter(path, self._samples) |
89 } | 91 } |
90 return_dict.update(handlebar.Generate()) | 92 return_dict.update(handlebar.Generate()) |
91 return return_dict | 93 return return_dict |
92 | 94 |
93 def __getitem__(self, key): | 95 def __getitem__(self, key): |
94 return self.get(key) | 96 return self.get(key) |
95 | 97 |
96 def get(self, key): | 98 def get(self, key): |
97 path, ext = os.path.splitext(key) | 99 path, ext = os.path.splitext(key) |
98 unix_name = model.UnixName(path) | 100 unix_name = model.UnixName(path) |
99 json_path = unix_name + '.json' | 101 json_path = unix_name + '.json' |
100 idl_path = unix_name + '.idl' | 102 idl_path = unix_name + '.idl' |
101 try: | 103 try: |
102 return self._GenerateHandlebarContext( | 104 return self._GenerateHandlebarContext( |
103 self._json_cache.GetFromFile(self._base_path + '/' + json_path), | 105 self._json_cache.GetFromFile(self._base_path + '/' + json_path), |
104 path) | 106 path) |
105 except FileNotFoundError: | 107 except FileNotFoundError: |
106 try: | 108 try: |
107 return self._GenerateHandlebarContext( | 109 return self._GenerateHandlebarContext( |
108 self._idl_cache.GetFromFile(self._base_path + '/' + idl_path), | 110 self._idl_cache.GetFromFile(self._base_path + '/' + idl_path), |
109 path) | 111 path) |
110 except FileNotFoundError: | 112 except FileNotFoundError: |
111 raise | 113 raise |
OLD | NEW |