-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub_issue.py
More file actions
99 lines (67 loc) · 2.76 KB
/
Copy pathgithub_issue.py
File metadata and controls
99 lines (67 loc) · 2.76 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
class GitHubIssue(object):
def __init__(self, issue_dict):
if not issue_dict:
return
if 'url' in issue_dict:
self._url = issue_dict['url']
if 'repository_url' in issue_dict:
self._repository_url = issue_dict['repository_url']
if 'labels_url' in issue_dict:
self._labels_url = issue_dict['labels_url']
if 'comments_url' in issue_dict:
self._comments_url = issue_dict['comments_url']
if 'events_url' in issue_dict:
self._events_url = issue_dict['events_url']
if 'html_url' in issue_dict:
self._html_url = issue_dict['html_url']
if 'number' in issue_dict:
self._issue_number = issue_dict['number']
if 'labels' in issue_dict:
self._labels = []
for label in issue_dict['labels']:
self._labels.append(label['name'])
if 'state' in issue_dict:
self._state = issue_dict['state']
if 'assignee' in issue_dict:
self._assignee = issue_dict['assignee']
if 'created_at' in issue_dict:
self._created_date = issue_dict['created_at']
if 'updated_at' in issue_dict:
self._last_updated = issue_dict['updated_at']
if 'title' in issue_dict:
self._issue_title = issue_dict['title']
if 'body' in issue_dict:
self._description = issue_dict['body']
def to_json(self):
"""Returns the GitHub issue as JSON"""
issue_dict = {}
if self._url:
issue_dict['usl'] = self._url
if self._repository_url:
issue_dict['repository_url'] = self._repository_url
if self._labels_url:
issue_dict['labels_url'] = self._labels_url
if self._comments_url:
issue_dict['comments_url'] = self._comments_url
if self._events_url:
issue_dict['events_url'] = self._events_url
if self._html_url:
issue_dict['html_url'] = self._html_url
# if 'labels' in issue_dict:
# self._labels = []
# for label in issue_dict['labels']:
# self._labels.append(label['name'])
if self._state:
issue_dict['state'] = self._state
if self._assignee:
issue_dict['assignee'] = self._assignee
if self._created_date:
issue_dict['created_at'] = self._created_date
if self._last_updated:
issue_dict['updated_at'] = self._last_updated
if self._issue_number:
issue_dict['number'] = self._issue_number
if self._issue_title:
issue_dict['title'] = self._issue_title
if self._description:
issue_dict['body'] = self._description