OLD | NEW |
(Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 import collections |
| 6 |
| 7 |
| 8 class Patch(collections.namedtuple('Patch', ('server', 'issue', 'patchset'))): |
| 9 """A patch in Rietveld.""" |
| 10 # TODO: Support Gerrit. |
| 11 # https://github.com/catapult-project/catapult/issues/3599 |
| 12 |
| 13 def __str__(self): |
| 14 return self.id_string |
| 15 |
| 16 @property |
| 17 def id_string(self): |
| 18 return '%s/%d/%d' % (self.server, self.issue, self.patchset) |
| 19 |
| 20 def AsDict(self): |
| 21 return self._asdict() |
| 22 |
| 23 @classmethod |
| 24 def FromDict(cls, data): |
| 25 # TODO: Validate to ensure the patch exists on the server. |
| 26 return cls(data['server'], data['issue'], data['patchset']) |
OLD | NEW |