mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-07-16 02:02:53 -07:00
Fix gh_api
This commit is contained in:
parent
3b289ba8e8
commit
c9c16c230d
1 changed files with 11 additions and 21 deletions
|
@ -1,7 +1,6 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from six import iteritems
|
|
||||||
|
|
||||||
|
|
||||||
class GitHub(object):
|
class GitHub(object):
|
||||||
|
@ -19,20 +18,9 @@ class GitHub(object):
|
||||||
"""
|
"""
|
||||||
Access the API at the path given and with the optional params given.
|
Access the API at the path given and with the optional params given.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
url = 'https://api.github.com/{path}'.format(path='/'.join(path))
|
url = 'https://api.github.com/{path}'.format(path='/'.join(path))
|
||||||
|
data = requests.get(url, params=params, verify=False)
|
||||||
if params and type(params) is dict:
|
return data.json() if data.ok else []
|
||||||
url += '?{params}'.format(params='&'.join(['{key}={value}'.format(key=k, value=v)
|
|
||||||
for k, v in iteritems(params)]))
|
|
||||||
|
|
||||||
data = requests.get(url, verify=False)
|
|
||||||
|
|
||||||
if data.ok:
|
|
||||||
json_data = data.json()
|
|
||||||
return json_data
|
|
||||||
else:
|
|
||||||
return []
|
|
||||||
|
|
||||||
def commits(self):
|
def commits(self):
|
||||||
"""
|
"""
|
||||||
|
@ -44,9 +32,10 @@ class GitHub(object):
|
||||||
|
|
||||||
Returns a deserialized json object containing the commit info. See http://developer.github.com/v3/repos/commits/
|
Returns a deserialized json object containing the commit info. See http://developer.github.com/v3/repos/commits/
|
||||||
"""
|
"""
|
||||||
access_API = self._access_API(['repos', self.github_repo_user, self.github_repo, 'commits'],
|
return self._access_API(
|
||||||
params={'per_page': 100, 'sha': self.branch})
|
['repos', self.github_repo_user, self.github_repo, 'commits'],
|
||||||
return access_API
|
params={'per_page': 100, 'sha': self.branch},
|
||||||
|
)
|
||||||
|
|
||||||
def compare(self, base, head, per_page=1):
|
def compare(self, base, head, per_page=1):
|
||||||
"""
|
"""
|
||||||
|
@ -60,7 +49,8 @@ class GitHub(object):
|
||||||
|
|
||||||
Returns a deserialized json object containing the compare info. See http://developer.github.com/v3/repos/commits/
|
Returns a deserialized json object containing the compare info. See http://developer.github.com/v3/repos/commits/
|
||||||
"""
|
"""
|
||||||
access_API = self._access_API(
|
return self._access_API(
|
||||||
['repos', self.github_repo_user, self.github_repo, 'compare', '{base}...{head}'.format(base=base, head=head)],
|
['repos', self.github_repo_user, self.github_repo, 'compare',
|
||||||
params={'per_page': per_page})
|
'{base}...{head}'.format(base=base, head=head)],
|
||||||
return access_API
|
params={'per_page': per_page},
|
||||||
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue