-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIssue.py
More file actions
47 lines (33 loc) · 1.37 KB
/
Issue.py
File metadata and controls
47 lines (33 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
# -*- coding: utf-8 -*-
import datetime
import json
import requests
class Issue:
TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
def __init__(self, raw_json, user, auth_token):
self.raw_json = raw_json
self.USER = user
self.AUTH_TOKEN = auth_token
def get_author(self):
return self.raw_json['user']['login']
#returns datetime object of the time
def get_creation_time(self):
return datetime.datetime.strptime(self.raw_json['created_at'], Issue.TIME_FORMAT)
def get_updated_time(self):
if self.raw_json['updated_at'] is None:
return None
return datetime.datetime.strptime(self.raw_json['updated_at'], Issue.TIME_FORMAT)
def get_closed_time(self):
if self.raw_json['closed_at'] is None:
return None
return datetime.datetime.strptime(self.raw_json['closed_at'], Issue.TIME_FORMAT)
def get_state(self):
return self.raw_json['state']
def within_six_months(self):
issue_date = datetime.datetime.strptime(self.raw_json['created_at'], Issue.TIME_FORMAT).date()
current_date = datetime.datetime.today().date()
# TODO: This can be done simpler
six_months = (datetime.datetime.today() - datetime.timedelta(6*365/12)).date()
return six_months <= issue_date <= current_date
def get_url(self):
return self.raw_json['url']