Chromium Code Reviews| 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..99a317924bf74de8f7855b7482c361296f77e69b 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 |
|
Jeffrey Yasskin
2013/10/08 17:46:05
Do you want basestring or str here? How are you ha
not at google - send to devlin
2013/10/08 18:27:37
Does unicode need to be handled any differently? I
Jeffrey Yasskin
2013/10/08 20:49:39
Unicode probably needs to be encoded before you ma
not at google - send to devlin
2013/10/08 21:29:36
I'm not sure what encoding we specify on fetches.
|
| + 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 |
| @@ -176,8 +184,8 @@ class BranchUtility(object): |
| None, |
|
Jeffrey Yasskin
2013/10/08 17:46:05
Wow, this is terrible style. sorted() wants keywor
not at google - send to devlin
2013/10/08 18:27:37
Heh.
|
| operator.itemgetter(1), |
| True) |
| - object_store.Set(channel_name, int(sorted_numbers[0][0])) |
| - return int(sorted_numbers[0][0]) |
| + 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 +203,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) |