Merge branch 'ebroder/anonymous-connections'

This commit is contained in:
Ask Solem
2010-05-18 15:03:52 +02:00
3 changed files with 11 additions and 4 deletions
+4
View File
@@ -44,6 +44,10 @@ Creating a request
>>> from github2.client import Github
>>> github = Github(username="ask", api_token=".......")
Or for an unauthenticated connection
>>> github = Github()
Users
=====
+1 -1
View File
@@ -6,7 +6,7 @@ from github2.commits import Commits
class Github(object):
def __init__(self, username, api_token, debug=False):
def __init__(self, username=None, api_token=None, debug=False):
self.debug = debug
self.request = GithubRequest(username=username, api_token=api_token,
debug=self.debug)
+6 -3
View File
@@ -24,7 +24,7 @@ class GithubRequest(object):
"https": httplib.HTTPSConnection,
}
def __init__(self, username, api_token, url_prefix=None, debug=False):
def __init__(self, username=None, api_token=None, url_prefix=None, debug=False):
self.username = username
self.api_token = api_token
self.url_prefix = url_prefix
@@ -37,8 +37,11 @@ class GithubRequest(object):
}
def encode_authentication_data(self, extra_post_data):
post_data = {"login": self.username,
"token": self.api_token}
if self.username and self.api_token:
post_data = {"login": self.username,
"token": self.api_token}
else:
post_data = {}
post_data.update(extra_post_data)
return urlencode(post_data)