aboutsummaryrefslogtreecommitdiffstats
path: root/github3/api.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2011-11-10 23:20:30 +0100
committerDavid Medina <davidmedina9@gmail.com>2011-11-10 23:42:46 +0100
commiteb6b5e45f461c4967e25c64c904f0d3b2051a854 (patch)
tree33da1a5bdcea481242e11675ae1f24804e3be25b /github3/api.py
parentSome details (diff)
downloadpython-github3-eb6b5e45f461c4967e25c64c904f0d3b2051a854.tar.xz
python-github3-eb6b5e45f461c4967e25c64c904f0d3b2051a854.zip
Init test enviroment
Also rename user handler module to 'users'
Diffstat (limited to 'github3/api.py')
-rw-r--r--github3/api.py29
1 files changed, 28 insertions, 1 deletions
diff --git a/github3/api.py b/github3/api.py
index b7435ff..e9eebb5 100644
--- a/github3/api.py
+++ b/github3/api.py
@@ -6,6 +6,7 @@
import requests
import json
from errors import GithubError
+from handlers import users, gists
RESOURCES_PER_PAGE = 100
@@ -126,4 +127,30 @@ class GithubCore(object):
return response
class Github(GithubCore):
- pass
+ """ Library enter """
+
+ def __init__(self, *args):
+ super(Github, self).__init__()
+ self.authenticated = False
+ auth = len(args)
+ if auth == 2: # Basic auth
+ self.session.auth = tuple(map(str,args))
+ self.authenticated = True
+ elif auth == 1: # Token oauth
+ raise NotImplementedError
+ elif auth > 2:
+ raise TypeError("user, password or token")
+
+ @property
+ def users(self):
+ if self.authenticated:
+ return users.AuthUser(self)
+ else:
+ return users.User(self)
+
+ @property
+ def gists(self):
+ if self.authenticated:
+ return gists.AuthGist(self)
+ else:
+ return gists.Gist(self)