forked from sigmavirus24/github3.py
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomment.py
More file actions
55 lines (37 loc) · 1.37 KB
/
comment.py
File metadata and controls
55 lines (37 loc) · 1.37 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
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from ..utils import timestamp_parameter
from ..models import BaseComment
from ..users import User
class IssueComment(BaseComment):
"""The :class:`IssueComment <IssueComment>` object. This structures and
handles the comments on issues specifically.
Two comment instances can be checked like so::
c1 == c2
c1 != c2
And is equivalent to::
c1.id == c2.id
c1.id != c2.id
See also: http://developer.github.com/v3/issues/comments/
"""
def _update_attributes(self, comment):
super(IssueComment, self)._update_attributes(comment)
user = comment.get('user')
#: :class:`User <github3.users.User>` who made the comment
self.user = User(user, self) if user else None
#: Issue url (not a template)
self.issue_url = comment.get('issue_url')
#: Html url (not a template)
self.html_url = comment.get('html_url')
def _repr(self):
return '<Issue Comment [{0}]>'.format(self.user.login)
def issue_comment_params(sort, direction, since):
params = {}
if sort in ('created', 'updated'):
params['sort'] = sort
if direction in ('asc', 'desc'):
params['direction'] = direction
since = timestamp_parameter(since)
if since:
params['since'] = since
return params