| 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 hashlib |
| 5 import json | 6 import json |
| 6 import logging | 7 import logging |
| 7 import re | 8 import re |
| 8 | 9 |
| 9 import compiled_file_system as compiled_fs | 10 import compiled_file_system as compiled_fs |
| 10 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater | 11 import third_party.json_schema_compiler.json_comment_eater as json_comment_eater |
| 11 import third_party.json_schema_compiler.model as model | 12 import third_party.json_schema_compiler.model as model |
| 12 import url_constants | 13 import url_constants |
| 13 | 14 |
| 14 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' | 15 DEFAULT_ICON_PATH = '/images/sample-default-icon.png' |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 url = sample_base_path | 131 url = sample_base_path |
| 131 icon_base = sample_base_path | 132 icon_base = sample_base_path |
| 132 download_url = sample_base_path + '.zip' | 133 download_url = sample_base_path + '.zip' |
| 133 | 134 |
| 134 if manifest_data['icon'] is None: | 135 if manifest_data['icon'] is None: |
| 135 icon_path = self._static_path + DEFAULT_ICON_PATH | 136 icon_path = self._static_path + DEFAULT_ICON_PATH |
| 136 else: | 137 else: |
| 137 icon_path = icon_base + '/' + manifest_data['icon'] | 138 icon_path = icon_base + '/' + manifest_data['icon'] |
| 138 manifest_data.update({ | 139 manifest_data.update({ |
| 139 'icon': icon_path, | 140 'icon': icon_path, |
| 141 'id': hashlib.md5(url).hexdigest(), |
| 140 'download_url': download_url, | 142 'download_url': download_url, |
| 141 'url': url, | 143 'url': url, |
| 142 'files': [f.replace(sample_path + '/', '') for f in sample_files], | 144 'files': [f.replace(sample_path + '/', '') for f in sample_files], |
| 143 'api_calls': api_calls | 145 'api_calls': api_calls |
| 144 }) | 146 }) |
| 145 samples_list.append(manifest_data) | 147 samples_list.append(manifest_data) |
| 146 | 148 |
| 147 return samples_list | 149 return samples_list |
| 148 | 150 |
| 149 def __init__(self, extensions_cache, apps_cache, samples_path, request): | 151 def __init__(self, extensions_cache, apps_cache, samples_path, request): |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 return return_list | 216 return return_list |
| 215 | 217 |
| 216 def __getitem__(self, key): | 218 def __getitem__(self, key): |
| 217 return self.get(key) | 219 return self.get(key) |
| 218 | 220 |
| 219 def get(self, key): | 221 def get(self, key): |
| 220 return { | 222 return { |
| 221 'apps': lambda: self._CreateSamplesDict('apps'), | 223 'apps': lambda: self._CreateSamplesDict('apps'), |
| 222 'extensions': lambda: self._CreateSamplesDict('extensions') | 224 'extensions': lambda: self._CreateSamplesDict('extensions') |
| 223 }.get(key, lambda: {})() | 225 }.get(key, lambda: {})() |
| OLD | NEW |