mirror of
https://github.com/kennethreitz/python-github3.git
synced 2026-06-05 23:10:17 +00:00
grmmm
This commit is contained in:
+27
-5
@@ -9,21 +9,43 @@ This module contains the core GitHub 3 interface.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
from .api import API_URL
|
from .api import API_URL, get
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GitHub(object):
|
class GitHub(object):
|
||||||
"""Central GitHub object."""
|
"""Central GitHub object."""
|
||||||
|
|
||||||
ratelimit = None
|
rate_limit = None
|
||||||
= None
|
rate_left = None
|
||||||
|
per_page = 30
|
||||||
|
|
||||||
def __init__(self, apiurl=API_URL):
|
def __init__(self, apiurl=API_URL):
|
||||||
|
self.__basic_auth = None
|
||||||
|
return self.logged_in()
|
||||||
|
|
||||||
|
def _get(self, *path):
|
||||||
|
r = get(*path, auth=self.__basic_auth)
|
||||||
|
|
||||||
|
rate_limit = r.headers.get('x-ratelimit-remaining', None)
|
||||||
|
rate_left = r.headers.get('x-ratelimit-limit', None)
|
||||||
|
|
||||||
|
if (rate_limit is not None) or (rate_left is not None):
|
||||||
|
self.rate_limit = rate_limit
|
||||||
|
self.rate_left = rate_left
|
||||||
|
|
||||||
|
return r
|
||||||
|
|
||||||
|
def auth(self, username, password):
|
||||||
|
self.__basic_auth = (username, password)
|
||||||
|
|
||||||
|
def oauth(self):
|
||||||
|
# TODO: oAuth
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def login(self):
|
def logged_in(self):
|
||||||
pass
|
print self._get('').headers
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Default instance
|
# Default instance
|
||||||
|
|||||||
Reference in New Issue
Block a user