| OLD | NEW |
| 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 import json | 5 import json |
| 6 import tarfile | 6 import tarfile |
| 7 from StringIO import StringIO | 7 from StringIO import StringIO |
| 8 | 8 |
| 9 from file_system import FileNotFoundError | 9 from file_system import FileNotFoundError |
| 10 from future import Future | 10 from future import Future |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 'Failed to fetch information for issue %s.' % self._issue) | 45 'Failed to fetch information for issue %s.' % self._issue) |
| 46 | 46 |
| 47 if issue_json.get('closed'): | 47 if issue_json.get('closed'): |
| 48 raise RietveldPatcherError('Issue %s has been closed.' % self._issue) | 48 raise RietveldPatcherError('Issue %s has been closed.' % self._issue) |
| 49 | 49 |
| 50 patchsets = issue_json.get('patchsets') | 50 patchsets = issue_json.get('patchsets') |
| 51 if not isinstance(patchsets, list) or len(patchsets) == 0: | 51 if not isinstance(patchsets, list) or len(patchsets) == 0: |
| 52 raise RietveldPatcherError('Cannot parse issue %s.' % self._issue) | 52 raise RietveldPatcherError('Cannot parse issue %s.' % self._issue) |
| 53 | 53 |
| 54 if not issue_json.get('base_url') in _CHROMIUM_REPO_BASEURLS: | 54 if not issue_json.get('base_url') in _CHROMIUM_REPO_BASEURLS: |
| 55 raise RietveldPatcherError('Issue %s\'s base url is unknown.' % | 55 raise RietveldPatcherError('Issue %s\'s base url "%s" is unknown.' % |
| 56 self._issue) | 56 self._issue, issue_json.get('base_url')) |
| 57 | 57 |
| 58 return str(patchsets[-1]) | 58 return str(patchsets[-1]) |
| 59 | 59 |
| 60 def GetPatchedFiles(self, version=None): | 60 def GetPatchedFiles(self, version=None): |
| 61 if version is None: | 61 if version is None: |
| 62 patchset = self.GetVersion() | 62 patchset = self.GetVersion() |
| 63 else: | 63 else: |
| 64 patchset = version | 64 patchset = version |
| 65 try: | 65 try: |
| 66 patchset_json = json.loads(self._fetcher.Fetch( | 66 patchset_json = json.loads(self._fetcher.Fetch( |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 patched_file.close() | 133 patched_file.close() |
| 134 | 134 |
| 135 value[path] = data | 135 value[path] = data |
| 136 | 136 |
| 137 return value | 137 return value |
| 138 return self._fetcher.FetchAsync('tarball/%s/%s' % (self._issue, | 138 return self._fetcher.FetchAsync('tarball/%s/%s' % (self._issue, |
| 139 version)).Then(apply_) | 139 version)).Then(apply_) |
| 140 | 140 |
| 141 def GetIdentity(self): | 141 def GetIdentity(self): |
| 142 return self._issue | 142 return self._issue |
| OLD | NEW |