diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-11-15 16:38:25 +0900 |
---|---|---|
committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2013-11-18 10:13:19 +0900 |
commit | 7eb4019ae88be7d091e21aaee412821d57b93149 (patch) | |
tree | b4e5334d463480852342c6617caaeaadbca38169 | |
parent | 9ed42a4656b246ccc4c6e681de3537a0149b829d (diff) | |
download | pygerrit-7eb4019ae88be7d091e21aaee412821d57b93149.tar.gz |
Add support for CurrentPatchSet
The "currentPatchset" field of the query results includes information
about the review label scores.
Change-Id: I41d54225284e15b2b61b79bfaa309cd5c2b4b86a
-rw-r--r-- | pygerrit/models.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pygerrit/models.py b/pygerrit/models.py index 31f7cca..9b764c1 100644 --- a/pygerrit/models.py +++ b/pygerrit/models.py @@ -67,6 +67,7 @@ class Change(object): self.owner = Account.from_json(json_data, "owner") self.sortkey = from_json(json_data, "sortKey") self.status = from_json(json_data, "status") + self.current_patchset = CurrentPatchset.from_json(json_data) def __repr__(self): return u"<Change %s, %s, %s>" % (self.number, self.project, self.branch) @@ -98,6 +99,35 @@ class Patchset(object): return None +class CurrentPatchset(Patchset): + + """ Gerrit current patch set. """ + + def __init__(self, json_data): + super(CurrentPatchset, self).__init__(json_data) + self.author = Account.from_json(json_data, "author") + self.approvals = [] + if "approvals" in json_data: + for approval in json_data["approvals"]: + self.approvals.append(Approval(approval)) + + def __repr__(self): + return u"<CurrentPatchset %s, %s>" % (self.number, self.revision) + + @staticmethod + def from_json(json_data): + r""" Create a CurrentPatchset instance. + + Return an instance of CurrentPatchset initialised with values from + "currentPatchSet" in `json_data`, or None if `json_data` does not + contain "currentPatchSet". + + """ + if "currentPatchSet" in json_data: + return CurrentPatchset(json_data["currentPatchSet"]) + return None + + class Approval(object): """ Gerrit approval (verified, code review, etc). """ |