Compare commits
2 Commits
8a9200e627
...
47e2bda181
Author | SHA1 | Date | |
---|---|---|---|
47e2bda181 | |||
7503a8effe |
@ -18,6 +18,10 @@ class GitHubApi:
|
|||||||
if proxy:
|
if proxy:
|
||||||
self.session.proxies.update(proxy)
|
self.session.proxies.update(proxy)
|
||||||
|
|
||||||
|
# Rate limits
|
||||||
|
self.rate_reset = None
|
||||||
|
self.rate_remaining = None
|
||||||
|
|
||||||
def __get(self, endpoint, params=None):
|
def __get(self, endpoint, params=None):
|
||||||
"""GET an HTTP resource and return JSON."""
|
"""GET an HTTP resource and return JSON."""
|
||||||
url = self.base_url + endpoint
|
url = self.base_url + endpoint
|
||||||
@ -33,7 +37,8 @@ class GitHubApi:
|
|||||||
|
|
||||||
def __parse_headers(self, headers):
|
def __parse_headers(self, headers):
|
||||||
"""Parse headers to update rate limits."""
|
"""Parse headers to update rate limits."""
|
||||||
pass
|
self.rate_reset = int(headers['x-ratelimit-reset'])
|
||||||
|
self.rate_remaining = int(headers['x-ratelimit-remaining'])
|
||||||
|
|
||||||
def get_events(self, page=None):
|
def get_events(self, page=None):
|
||||||
"""Fetch GitHub events."""
|
"""Fetch GitHub events."""
|
||||||
|
10
main.py
10
main.py
@ -2,6 +2,14 @@
|
|||||||
from gitmon.api import GitHubApi
|
from gitmon.api import GitHubApi
|
||||||
|
|
||||||
|
|
||||||
|
def print_event(event):
|
||||||
|
event_type = event.get('type')
|
||||||
|
repo = event.get('repo')
|
||||||
|
actor = event.get('actor')
|
||||||
|
|
||||||
|
print(f'{event_type}:\t{repo["name"]}, {actor["login"]}')
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry point."""
|
"""Main entry point."""
|
||||||
|
|
||||||
@ -9,7 +17,7 @@ def main():
|
|||||||
|
|
||||||
events = api.get_events()
|
events = api.get_events()
|
||||||
for event in events:
|
for event in events:
|
||||||
print(event['type'])
|
print_event(event)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user