| OLD | NEW |
| 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 SUBVERSION_URL = 'http://src.chromium.org/viewvc/chrome/' | 5 SUBVERSION_URL = 'http://src.chromium.org/viewvc/chrome/' |
| 6 TRUNK_URL = SUBVERSION_URL + 'trunk/' | 6 TRUNK_URL = SUBVERSION_URL + 'trunk/' |
| 7 BRANCH_URL = SUBVERSION_URL + 'branches/' | 7 BRANCH_URL = SUBVERSION_URL + 'branches/' |
| 8 | 8 |
| 9 class SubversionFetcher(object): | 9 class SubversionFetcher(object): |
| 10 """Class to fetch code from src.chromium.org. | 10 """Class to fetch resources from src.chromium.org. |
| 11 """ | 11 """ |
| 12 def __init__(self, urlfetch): | 12 def __init__(self, base_path, urlfetch): |
| 13 self.base_path = base_path |
| 13 self.urlfetch = urlfetch | 14 self.urlfetch = urlfetch |
| 14 | 15 |
| 15 def _GetURLFromBranch(self, branch): | 16 def _GetURLFromBranch(self, branch): |
| 16 if branch == 'trunk': | 17 if branch == 'trunk': |
| 17 return TRUNK_URL | 18 return TRUNK_URL + 'src/' |
| 18 return BRANCH_URL + branch + '/' | 19 return BRANCH_URL + branch + '/src/' |
| 19 | 20 |
| 20 def FetchResource(self, branch, path): | 21 def FetchResource(self, branch, path): |
| 21 url = self._GetURLFromBranch(branch) + path | 22 url = self._GetURLFromBranch(branch) + self.base_path + path |
| 22 result = self.urlfetch.fetch(url) | 23 result = self.urlfetch.fetch(url) |
| 23 return result | 24 return result |
| OLD | NEW |