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

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

Issue 10838002: Extensions Docs Server: Sort API list (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 os 5 import os
6 6
7 import third_party.json_schema_compiler.model as model 7 import third_party.json_schema_compiler.model as model
8 8
9 class APIListDataSource(object): 9 class APIListDataSource(object):
10 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs 10 """ This class creates a list of chrome.* APIs and chrome.experimental.* APIs
(...skipping 13 matching lines...) Expand all
24 chrome_apis = [] 24 chrome_apis = []
25 for i, template_name in enumerate(template_names): 25 for i, template_name in enumerate(template_names):
26 if model.UnixName(template_name) in api_names: 26 if model.UnixName(template_name) in api_names:
27 if template_name.startswith('experimental'): 27 if template_name.startswith('experimental'):
28 experimental_apis.append({ 'name': template_name.replace('_', '.') }) 28 experimental_apis.append({ 'name': template_name.replace('_', '.') })
29 else: 29 else:
30 chrome_apis.append({ 'name': template_name.replace('_', '.') }) 30 chrome_apis.append({ 'name': template_name.replace('_', '.') })
31 chrome_apis[-1]['last'] = True 31 chrome_apis[-1]['last'] = True
32 experimental_apis[-1]['last'] = True 32 experimental_apis[-1]['last'] = True
33 return { 33 return {
34 'chrome': sorted(chrome_apis), 34 'chrome': sorted(chrome_apis, key=lambda x: x['name']),
35 'experimental': sorted(experimental_apis) 35 'experimental': sorted(experimental_apis, key=lambda x: x['name'])
not at google - send to devlin 2012/07/30 20:22:00 There's an "attrgetter" thing somewhere that does
cduvall 2012/07/30 20:26:29 How about this?
36 } 36 }
37 37
38 def __getitem__(self, key): 38 def __getitem__(self, key):
39 return self.get(key) 39 return self.get(key)
40 40
41 def get(self, key): 41 def get(self, key):
42 try: 42 try:
43 return self._cache.GetFromFile(self._api_path)[key] 43 return self._cache.GetFromFile(self._api_path)[key]
44 except Exception as e: 44 except Exception as e:
45 return None 45 return None
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698