-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgithub.py
More file actions
42 lines (27 loc) · 839 Bytes
/
github.py
File metadata and controls
42 lines (27 loc) · 839 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
# -*- coding: utf-8 -*-
"""
github
This module contains methods for accessing the Github API v3.
https://developer.github.com/v3/
"""
import requests
GITHUB_AUTHORITY = 'api.github.com'
def get_repository(owner, repo):
""" Get respository information.
:param owner: The name of the repository owner.
:param repo: The name of the repository.
:rtype: dict
"""
uri = 'https://{0}/repos/{1}/{2}'.format(GITHUB_AUTHORITY, owner, repo)
response = requests.get(uri)
response.raise_for_status()
return response.json()
def get_user(user):
""" Get user information.
:param user: The name of the GitHub user.
:rtype: dict
"""
uri = 'https://{0}/users/{1}'.format(GITHUB_AUTHORITY, user)
response = requests.get(uri)
response.raise_for_status()
return response.json()