Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(891)

Side by Side Diff: chrome/common/extensions/docs/server2/samples_data_source.py

Issue 10830115: Injection stuff. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: . Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 def _GetAcceptedLanguages(self): 114 def _GetAcceptedLanguages(self):
115 accept_language = self._request.headers.get('Accept-Language', None) 115 accept_language = self._request.headers.get('Accept-Language', None)
116 if accept_language is None: 116 if accept_language is None:
117 return [] 117 return []
118 return [lang_with_q.split(';')[0].strip() 118 return [lang_with_q.split(';')[0].strip()
119 for lang_with_q in accept_language.split(',')] 119 for lang_with_q in accept_language.split(',')]
120 120
121 def __getitem__(self, key): 121 def __getitem__(self, key):
122 return self.get(key) 122 return self.get(key)
123 123
124 def values(self): 124 def GetAll(self):
125 return self.get('') 125 return self.get('')
126 126
127 def get(self, key): 127 def get(self, key):
128 samples_list = self._cache.GetFromFileListing(self._samples_path + '/') 128 samples_list = self._cache.GetFromFileListing(self._samples_path + '/')
129 return_list = [] 129 return_list = []
130 for dict_ in samples_list: 130 for dict_ in samples_list:
131 name = dict_['name'] 131 name = dict_['name']
132 description = dict_['description'] 132 description = dict_['description']
133 if name.startswith('__MSG_') or description.startswith('__MSG_'): 133 if name.startswith('__MSG_') or description.startswith('__MSG_'):
134 try: 134 try:
(...skipping 10 matching lines...) Expand all
145 sample_data['name'] = locale_data[name_key]['message'] 145 sample_data['name'] = locale_data[name_key]['message']
146 sample_data['description'] = locale_data[description_key]['message'] 146 sample_data['description'] = locale_data[description_key]['message']
147 except Exception as e: 147 except Exception as e:
148 logging.error(e) 148 logging.error(e)
149 # Revert the sample to the original dict. 149 # Revert the sample to the original dict.
150 sample_data = dict_ 150 sample_data = dict_
151 return_list.append(sample_data) 151 return_list.append(sample_data)
152 else: 152 else:
153 return_list.append(dict_) 153 return_list.append(dict_)
154 return return_list 154 return return_list
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/handler.py ('k') | chrome/common/extensions/docs/server2/template_data_source.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698