-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgitNotifications.py
More file actions
51 lines (30 loc) · 1.1 KB
/
Copy pathgitNotifications.py
File metadata and controls
51 lines (30 loc) · 1.1 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
import sys
from github import Github
from RssBuilder import RssBuilderObj
def login(api_token):
return Github(api_token)
def convert_to_rss(notification_list):
rss = RssBuilderObj.RssBuilder("Github notifications")
for notification in notification_list:
rss.add_item(get_notification_item(notification))
return rss.to_xml()
def get_notification_item(notification):
return RssBuilderObj.RssItem(
notification.subject.title,
notification.reason,
remove_api_link(notification.subject.url)
)
def remove_api_link(git_link):
return git_link.replace("api.", "").replace("repos/", "")
def get_notification_thread(g_user, notification_id):
return g_user.get_notification(notification_id)
def get_unread_notifications(g_user):
return g_user.get_notifications()
def get_notification_title(notification):
return notification.subject.title
def main():
g_user = login(sys.argv[1]).get_user()
print(convert_to_rss(get_unread_notifications(g_user)))
if len(sys.argv) < 2:
print("usage: python gitNotification.py <API_TOKEN>")
main()