Completed
Pull Request — master (#358)
by
unknown
02:14
created

to_comment_dict()   A

Complexity

Conditions 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 9
rs 9.6667
cc 1
1
__all__ = [
2
    'to_issue_dict',
3
    'to_comment_dict'
4
]
5
6
7
def to_issue_dict(issue):
8
    """
9
    :rtype: ``dict``
10
    """
11
    split = issue.permalink().split(' - ', 1)
12
    url = split[0]
13
14
    if issue.fields.resolution:
15
        resolution = issue.fields.resolution.name
16
    else:
17
        resolution = None
18
19
    if issue.fields.reporter:
20
        reporter = issue.fields.reporter.displayName
21
    else:
22
        reporter = None
23
24
    if issue.fields.assignee:
25
        assignee = issue.fields.assignee.displayName
26
    else:
27
        assignee = None
28
29
    result = {
30
        'id': issue.id,
31
        'key': issue.key,
32
        'url': url,
33
        'summary': issue.fields.summary,
34
        'description': issue.fields.description,
35
        'status': issue.fields.status.name,
36
        'resolution': resolution,
37
        'labels': issue.fields.labels,
38
        'reporter': reporter,
39
        'assignee': assignee,
40
        'created_at': issue.fields.created,
41
        'updated_at': issue.fields.updated,
42
        'resolved_at': issue.fields.resolutiondate
43
    }
44
    return result
45
46
47
def to_comment_dict(comment):
48
    """
49
    :rtype: ``dict``
50
    """
51
    result = {
52
        'id': comment.id,
53
        'body': comment.body
54
    }
55
    return result
56