-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodels.py
More file actions
51 lines (39 loc) · 1.27 KB
/
models.py
File metadata and controls
51 lines (39 loc) · 1.27 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
# -*- coding: utf-8 -*-
"""
jira2github.jira_issue
~~~~~~~~~
JiraIssue class
:copyright: ahsky2@gmail.com
:license: GPL V3 license.
"""
import simplejson as json
class CustomEncoder(json.JSONEncoder):
def default(self, o):
if isinstance(o, JiraComment):
return o.__dict__
else:
return json.JSONEncoder.default(o)
class JiraIssue(object):
def __init__(self, key, summary, description, assignee, creator, issue_type, status, created):
self.key = key
self.summary = summary
self.description = description
self.assignee = assignee
self.creator = creator
self.issue_type = issue_type
self.status = status
self.created = created
self.comments = []
def __repr__(self):
return '<JiraIssue {}>'.format(self.key)
def __str__(self):
return json.dumps(self.__dict__, indent=4, separators=(',', ': '), cls=CustomEncoder)
class JiraComment(object):
def __init__(self, author, body, created):
self.author = author
self.body = body
self.created = created
def __repr__(self):
return '<JiraComment>'.format()
def __str__(self):
return json.dumps(self.__dict__, indent=4, separators=(',', ': '))