diff options
author | 2011-04-13 19:13:16 -0400 | |
---|---|---|
committer | 2011-04-13 19:13:16 -0400 | |
commit | c1e387d83bd5a00d1b2379a5c2a10ebc33a31eb4 (patch) | |
tree | 2305b4cbbaa3a39288fdd910f751084f85ab0bce /github3/core.py | |
parent | basic (diff) | |
download | python-github3-c1e387d83bd5a00d1b2379a5c2a10ebc33a31eb4.tar.xz python-github3-c1e387d83bd5a00d1b2379a5c2a10ebc33a31eb4.zip |
grmmm
Diffstat (limited to 'github3/core.py')
-rw-r--r-- | github3/core.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/github3/core.py b/github3/core.py index 383ab88..6d1ee21 100644 --- a/github3/core.py +++ b/github3/core.py @@ -9,22 +9,44 @@ This module contains the core GitHub 3 interface. """ -from .api import API_URL +from .api import API_URL, get class GitHub(object): """Central GitHub object.""" - ratelimit = None - = None + rate_limit = None + rate_left = None + per_page = 30 def __init__(self, apiurl=API_URL): - pass + 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 - def login(self): + return r + + def auth(self, username, password): + self.__basic_auth = (username, password) + + def oauth(self): + # TODO: oAuth pass + def logged_in(self): + print self._get('').headers + + # Default instance github = GitHub()
\ No newline at end of file |