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

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

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: epic rebase Created 7 years, 5 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
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 operator 7 import operator
8 8
9 from appengine_url_fetcher import AppEngineUrlFetcher 9 from appengine_url_fetcher import AppEngineUrlFetcher
10 import url_constants 10 import url_constants
11 11
12 class ChannelInfo(object): 12 class ChannelInfo(object):
13 def __init__(self, channel, branch, version): 13 def __init__(self, channel, branch, version):
14 self.channel = channel 14 self.channel = channel
15 self.branch = branch 15 self.branch = branch
16 self.version = version 16 self.version = version
17 17
18 class BranchUtility(object): 18 class BranchUtility(object):
19 def __init__(self, fetch_url, history_url, fetcher, object_store_creator): 19 def __init__(self, fetch_url, history_url, fetcher, object_store_creator):
20 self._fetcher = fetcher 20 self._fetcher = fetcher
21 # BranchUtility is obviously cross-channel, so set the channel to None. 21 def create_object_store(category):
22 self._branch_object_store = object_store_creator.Create(BranchUtility, 22 return object_store_creator.Create(BranchUtility, category=category)
23 category='branch', 23 self._branch_object_store = create_object_store('branch')
24 channel=None) 24 self._version_object_store = create_object_store('version')
25 self._version_object_store = object_store_creator.Create(BranchUtility,
26 category='version',
27 channel=None)
28 self._fetch_result = self._fetcher.FetchAsync(fetch_url) 25 self._fetch_result = self._fetcher.FetchAsync(fetch_url)
29 self._history_result = self._fetcher.FetchAsync(history_url) 26 self._history_result = self._fetcher.FetchAsync(history_url)
30 27
31 @staticmethod 28 @staticmethod
32 def GetAllChannelNames(): 29 def GetAllChannelNames():
33 return ('stable', 'beta', 'dev', 'trunk') 30 return ('stable', 'beta', 'dev', 'trunk')
34 31
35 @staticmethod 32 @staticmethod
36 def NewestChannel(channels): 33 def NewestChannel(channels):
37 for channel in reversed(BranchUtility.GetAllChannelNames()): 34 for channel in reversed(BranchUtility.GetAllChannelNames()):
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 version_json = json.loads(self._history_result.Get().content) 163 version_json = json.loads(self._history_result.Get().content)
167 latest_version = 0 164 latest_version = 0
168 for entry in version_json['events']: 165 for entry in version_json['events']:
169 version_title = entry['title'].split(' - ')[1].split('.') 166 version_title = entry['title'].split(' - ')[1].split('.')
170 version = int(version_title[0]) 167 version = int(version_title[0])
171 if version > latest_version: 168 if version > latest_version:
172 latest_version = version 169 latest_version = version
173 170
174 self._version_object_store.Set('latest', latest_version) 171 self._version_object_store.Set('latest', latest_version)
175 return latest_version 172 return latest_version
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698