forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent.py
More file actions
66 lines (50 loc) · 2.05 KB
/
event.py
File metadata and controls
66 lines (50 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from ..models import GitHubCore
from ..users import User
class IssueEvent(GitHubCore):
"""The :class:`IssueEvent <IssueEvent>` object. This specifically deals
with events described in the
`Issues\>Events <http://developer.github.com/v3/issues/events>`_ section of
the GitHub API.
Two event instances can be checked like so::
e1 == e2
e1 != e2
And is equivalent to::
e1.commit_id == e2.commit_id
e1.commit_id != e2.commit_id
"""
def __init__(self, event, session=None):
super(IssueEvent, self).__init__(event, session)
# The type of event:
# ('closed', 'reopened', 'subscribed', 'merged', 'referenced',
# 'mentioned', 'assigned')
#: The type of event, e.g., closed
self.event = event.get('event')
#: SHA of the commit.
self.commit_id = event.get('commit_id')
self._api = event.get('url', '')
#: :class:`Issue <github3.issues.Issue>` where this comment was made.
self.issue = event.get('issue')
if self.issue:
from .issue import Issue
self.issue = Issue(self.issue, self)
#: :class:`User <github3.users.User>` who caused this event.
self.actor = event.get('actor')
if self.actor:
self.actor = User(self.actor, self)
#: :class:`User <github3.users.User>` that generated the event.
self.actor = event.get('actor')
if self.actor:
self.actor = User(self.actor, self._session)
#: Number of comments
self.comments = event.get('comments', 0)
#: datetime object representing when the event was created.
self.created_at = self._strptime(event.get('created_at'))
#: Dictionary of links for the pull request
self.pull_request = event.get('pull_request', {})
self._uniq = self.commit_id
def __repr__(self):
return '<Issue Event [{0} by {1}]>'.format(
self.event, self.actor
)