aboutsummaryrefslogtreecommitdiffstats
path: root/github3/core.py
diff options
context:
space:
mode:
Diffstat (limited to 'github3/core.py')
-rw-r--r--github3/core.py32
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