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

Unified Diff: chrome/common/extensions/docs/server2/branch_utility.py

Issue 26418002: Docserver: Pull knowledge of host file systems into a single (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: jeffrey Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/branch_utility.py
diff --git a/chrome/common/extensions/docs/server2/branch_utility.py b/chrome/common/extensions/docs/server2/branch_utility.py
index 6241750da2d42c744d6443d4db3329218981b914..d36e85e6c8d0505ff61940afb2e37e1dfe4f897f 100644
--- a/chrome/common/extensions/docs/server2/branch_utility.py
+++ b/chrome/common/extensions/docs/server2/branch_utility.py
@@ -20,6 +20,11 @@ class ChannelInfo(object):
'''
def __init__(self, channel, branch, version):
+ assert isinstance(channel, basestring), channel
+ assert isinstance(branch, basestring), branch
+ # TODO(kalman): Assert that this is a string. One day Chromium will probably
+ # be served out of a git repository and the versions will no longer be ints.
+ assert isinstance(version, int) or version == 'trunk', version
self.channel = channel
self.branch = branch
self.version = version
@@ -122,9 +127,12 @@ class BranchUtility(object):
def GetChannelInfo(self, channel):
+ version = self._ExtractFromVersionJson(channel, 'version')
+ if version != 'trunk':
+ version = int(version)
return ChannelInfo(channel,
self._ExtractFromVersionJson(channel, 'branch'),
- self._ExtractFromVersionJson(channel, 'version'))
+ version)
def GetStableChannelInfo(self, version):
'''Given a |version| corresponding to a 'stable' version of Chrome, returns
@@ -172,12 +180,9 @@ class BranchUtility(object):
else:
numbers[number] += 1
- sorted_numbers = sorted(numbers.iteritems(),
- None,
- operator.itemgetter(1),
- True)
- object_store.Set(channel_name, int(sorted_numbers[0][0]))
- return int(sorted_numbers[0][0])
+ sorted_numbers = sorted(numbers.iteritems(), key=operator.itemgetter(1))
Jeffrey Yasskin 2013/10/08 20:49:39 The original call also had reversed=True.
not at google - send to devlin 2013/10/08 21:29:37 mind blown, again, why no tests failed.
+ object_store.Set(channel_name, sorted_numbers[0][0])
+ return sorted_numbers[0][0]
def GetBranchForVersion(self, version):
'''Returns the most recent branch for a given chrome version number using
@@ -195,8 +200,8 @@ class BranchUtility(object):
# Here, entry['title'] looks like: '<title> - <version>.##.<branch>.##'
version_title = entry['title'].split(' - ')[1].split('.')
if version_title[0] == str(version):
- self._branch_object_store.Set(str(version), int(version_title[2]))
- return int(version_title[2])
+ self._branch_object_store.Set(str(version), version_title[2])
+ return version_title[2]
raise ValueError('The branch for %s could not be found.' % version)

Powered by Google App Engine
This is Rietveld 408576698