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

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

Issue 337373004: Docserver: Replace instances of 'Api' with 'API' (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « chrome/common/extensions/docs/server2/compiled_file_system.py ('k') | 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 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 from itertools import groupby 5 from itertools import groupby
6 from operator import itemgetter 6 from operator import itemgetter
7 import posixpath 7 import posixpath
8 8
9 from data_source import DataSource 9 from data_source import DataSource
10 from extensions_paths import JSON_TEMPLATES, PUBLIC_TEMPLATES 10 from extensions_paths import JSON_TEMPLATES, PUBLIC_TEMPLATES
(...skipping 14 matching lines...) Expand all
25 self._api_categorizer = server_instance.api_categorizer 25 self._api_categorizer = server_instance.api_categorizer
26 26
27 def _GenerateChangesListWithVersion(self, platform, whats_new_json): 27 def _GenerateChangesListWithVersion(self, platform, whats_new_json):
28 return [{ 28 return [{
29 'id': change_id, 29 'id': change_id,
30 'type': change['type'], 30 'type': change['type'],
31 'description': change['description'], 31 'description': change['description'],
32 'version': change['version'] 32 'version': change['version']
33 } for change_id, change in whats_new_json.iteritems()] 33 } for change_id, change in whats_new_json.iteritems()]
34 34
35 def _GetApiVersion(self, platform, api_name): 35 def _GetAPIVersion(self, platform, api_name):
36 version = None 36 version = None
37 category = self._api_categorizer.GetCategory(platform, api_name) 37 category = self._api_categorizer.GetCategory(platform, api_name)
38 if category == 'chrome': 38 if category == 'chrome':
39 channel_info = self._availability_finder.GetApiAvailability( 39 channel_info = self._availability_finder.GetAPIAvailability(
40 api_name).channel_info 40 api_name).channel_info
41 channel = channel_info.channel 41 channel = channel_info.channel
42 if channel == 'stable': 42 if channel == 'stable':
43 version = channel_info.version 43 version = channel_info.version
44 return version 44 return version
45 45
46 def _GenerateApiListWithVersion(self, platform): 46 def _GenerateAPIListWithVersion(self, platform):
47 data = [] 47 data = []
48 for api_name, api_model in self._api_models.IterModels(): 48 for api_name, api_model in self._api_models.IterModels():
49 version = self._GetApiVersion(platform, api_name) 49 version = self._GetAPIVersion(platform, api_name)
50 if version: 50 if version:
51 api = { 51 api = {
52 'name': api_name, 52 'name': api_name,
53 'description': api_model.description, 53 'description': api_model.description,
54 'version' : version, 54 'version' : version,
55 'type': 'apis', 55 'type': 'apis',
56 } 56 }
57 data.append(api) 57 data.append(api)
58 data.sort(key=itemgetter('version')) 58 data.sort(key=itemgetter('version'))
59 return data 59 return data
60 60
61 def _GenerateWhatsNewDict(self): 61 def _GenerateWhatsNewDict(self):
62 whats_new_json_future = self._parse_cache.GetFromFile( 62 whats_new_json_future = self._parse_cache.GetFromFile(
63 posixpath.join(JSON_TEMPLATES, 'whats_new.json')) 63 posixpath.join(JSON_TEMPLATES, 'whats_new.json'))
64 def _MakeDictByPlatform(platform): 64 def _MakeDictByPlatform(platform):
65 whats_new_json = whats_new_json_future.Get() 65 whats_new_json = whats_new_json_future.Get()
66 platform_list = [] 66 platform_list = []
67 apis = self._GenerateApiListWithVersion(platform) 67 apis = self._GenerateAPIListWithVersion(platform)
68 apis.extend(self._GenerateChangesListWithVersion(platform, 68 apis.extend(self._GenerateChangesListWithVersion(platform,
69 whats_new_json)) 69 whats_new_json))
70 apis.sort(key=itemgetter('version'), reverse=True) 70 apis.sort(key=itemgetter('version'), reverse=True)
71 for version, group in groupby(apis, key=itemgetter('version')): 71 for version, group in groupby(apis, key=itemgetter('version')):
72 whats_new_by_version = { 72 whats_new_by_version = {
73 'version': version, 73 'version': version,
74 } 74 }
75 for item in group: 75 for item in group:
76 item_type = item['type'] 76 item_type = item['type']
77 if item_type not in whats_new_by_version: 77 if item_type not in whats_new_by_version:
(...skipping 14 matching lines...) Expand all
92 if data is None: 92 if data is None:
93 data = self._GenerateWhatsNewDict().Get() 93 data = self._GenerateWhatsNewDict().Get()
94 self._object_store.Set('whats_new_data', data) 94 self._object_store.Set('whats_new_data', data)
95 return data 95 return data
96 96
97 def get(self, key): 97 def get(self, key):
98 return self._GetCachedWhatsNewData().get(key) 98 return self._GetCachedWhatsNewData().get(key)
99 99
100 def Cron(self): 100 def Cron(self):
101 return self._GenerateWhatsNewDict() 101 return self._GenerateWhatsNewDict()
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/server2/compiled_file_system.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698