diff options
| author | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-07-12 13:12:32 +0900 |
|---|---|---|
| committer | David Pursehouse <david.pursehouse@sonymobile.com> | 2012-07-24 14:52:09 +0900 |
| commit | e419c9e14e23c255518d9565ed96ac34228bb3fb (patch) | |
| tree | a6232dc319f01b7453962689d79c640f86c66c78 | |
| parent | 6f97e564d7dbd2e354e51deadef86e4eb5d38ea4 (diff) | |
| download | pygerrit-e419c9e14e23c255518d9565ed96ac34228bb3fb.tar.gz | |
Add support for the `draft-published` event
Add a new class GerritDraftPublishedEvent and include it in the
event handling.
| -rwxr-xr-x | gerrit_stream.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/gerrit_stream.py b/gerrit_stream.py index c4495ad..0f07c97 100755 --- a/gerrit_stream.py +++ b/gerrit_stream.py @@ -10,6 +10,7 @@ import json # Event types CHANGE_MERGED = "change-merged" PATCHSET_CREATED = "patchset-created" +DRAFT_PUBLISHED = "draft-published" COMMENT_ADDED = "comment-added" CHANGE_ABANDONED = "change-abandoned" CHANGE_RESTORED = "change-restored" @@ -132,6 +133,22 @@ class GerritPatchsetCreatedEvent(GerritEvent): raise GerritStreamError("GerritPatchsetCreatedEvent: %s" % e) +class GerritDraftPublishedEvent(GerritEvent): + ''' Representation of the Gerrit "draft-published" event described in + `json_data`. + Raise GerritStreamError if any of the required fields is missing. + ''' + + def __init__(self, json_data): + super(GerritDraftPublishedEvent, self).__init__() + try: + self.change = GerritChange(json_data["change"]) + self.patchset = GerritPatchset(json_data["patchSet"]) + self.uploader = GerritAccount(json_data["uploader"]) + except KeyError, e: + raise GerritStreamError("GerritDraftPublishedEvent: %s" % e) + + class GerritCommentAddedEvent(GerritEvent): ''' Representation of the Gerrit "comment-added" event described in `json_data`. @@ -233,6 +250,7 @@ class GerritStream(object): # Map the event types to class names. _event_dict = {CHANGE_MERGED: "ChangeMerged", PATCHSET_CREATED: "PatchsetCreated", + DRAFT_PUBLISHED: "DraftPublished", COMMENT_ADDED: "CommentAdded", CHANGE_ABANDONED: "ChangeAbandoned", CHANGE_RESTORED: "ChangeRestored", |
