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 re | 7 import re |
8 | 8 |
9 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' | 9 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' |
10 | 10 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 else: | 88 else: |
89 api_calls.append({ | 89 api_calls.append({ |
90 'name': item, | 90 'name': item, |
91 'link': self._MakeApiLink('method', item) | 91 'link': self._MakeApiLink('method', item) |
92 }) | 92 }) |
93 l10n_data = self._GetDataFromManifest(sample_path) | 93 l10n_data = self._GetDataFromManifest(sample_path) |
94 sample_base_path = sample_path.split('/', 1)[1] | 94 sample_base_path = sample_path.split('/', 1)[1] |
95 if l10n_data['icon'] is None: | 95 if l10n_data['icon'] is None: |
96 icon_path = self._static_path + DEFAULT_ICON_PATH | 96 icon_path = self._static_path + DEFAULT_ICON_PATH |
97 else: | 97 else: |
98 icon_path = sample_base_path + '/' + l10n_data['icon'] | 98 icon_path = '/' + sample_base_path + '/' + l10n_data['icon'] |
99 l10n_data.update({ | 99 l10n_data.update({ |
100 'icon': icon_path, | 100 'icon': icon_path, |
101 'path': sample_base_path, | 101 'path': sample_base_path, |
102 'files': [f.replace(sample_path + '/', '') for f in sample_files], | 102 'files': [f.replace(sample_path + '/', '') for f in sample_files], |
103 'api_calls': api_calls | 103 'api_calls': api_calls |
104 }) | 104 }) |
105 samples_list.append(l10n_data) | 105 samples_list.append(l10n_data) |
106 | 106 |
107 return samples_list | 107 return samples_list |
108 | 108 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 sample_data['name'] = locale_data[name_key]['message'] | 151 sample_data['name'] = locale_data[name_key]['message'] |
152 sample_data['description'] = locale_data[description_key]['message'] | 152 sample_data['description'] = locale_data[description_key]['message'] |
153 except Exception as e: | 153 except Exception as e: |
154 logging.error(e) | 154 logging.error(e) |
155 # Revert the sample to the original dict. | 155 # Revert the sample to the original dict. |
156 sample_data = dict_ | 156 sample_data = dict_ |
157 return_list.append(sample_data) | 157 return_list.append(sample_data) |
158 else: | 158 else: |
159 return_list.append(dict_) | 159 return_list.append(dict_) |
160 return return_list | 160 return return_list |
OLD | NEW |