forked from yvah/OpenSourceDynamics
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.py
More file actions
45 lines (30 loc) · 817 Bytes
/
classes.py
File metadata and controls
45 lines (30 loc) · 817 Bytes
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
from dataclasses import dataclass
@dataclass
class IssueOrPullRequest:
title: str
number: int
state: str
author: str
comments: []
def newIssueOrPullRequest(raw):
title = raw["title"]
number = raw["number"]
state = raw["state"]
author = raw["author"]["login"]
comments = []
for edge in raw["comments"]["edges"]:
comments.append(newComment(edge["node"]))
return IssueOrPullRequest(title,number,state,author,comments)
@dataclass
class Comment:
body: str
author: str
date: str
time: str
def newComment(raw):
body = raw["bodyText"]
author = raw["author"]["login"] # TODO fix NoneType error
date_time = raw["createdAt"]
date = date_time[0:10]
time = date_time[11:19]
return Comment(body, author, date, time)