This commit is contained in:
Ask Solem
2009-04-18 21:55:51 +02:00
committed by Ask Solem
parent fdc17200cf
commit 7b88d36926
3 changed files with 27 additions and 1 deletions
+2
View File
@@ -2,6 +2,7 @@ from github2.request import GithubRequest
from github2.issues import Issues
from github2.repositories import Repositories
from github2.users import Users
from github2.commits import Commits
class Github(object):
@@ -10,6 +11,7 @@ class Github(object):
self.issues = Issues(self.request)
self.users = Users(self.request)
self.repos = Repositories(self.request)
self.commits = Commits(self.request)
def project_for_user_repo(self, user, repo):
return "/".join([user, repo])
+22
View File
@@ -0,0 +1,22 @@
from github2.core import BaseData, GithubCommand
class Commit(BaseData):
attributes = ("message", "parents", "url", "author", "id",
"committed_date", "authored_date", "tree", "committer",
"added", "removed", "modified")
date_attributes = ("committed_date", "authored_date")
class Commits(GithubCommand):
domain = "commits"
def list(self, project, branch="master", file=None):
return self.get_values("list", project, branch, file,
filter="commits", datatype=Commit)
def show(self, project, sha):
return self.get_value("show", project, sha,
filter="commit", datatype=Commit)
+3 -1
View File
@@ -4,7 +4,7 @@ import simplejson
from urlparse import urlparse
from urllib import urlencode
URL_PREFIX = "https://github.com/api/v2/json"
URL_PREFIX = "http://github.com/api/v2/json"
class GithubError(Exception):
"""An error occured when making a request to the Github API."""
@@ -30,9 +30,11 @@ class GithubRequest(object):
return urlencode(post_data)
def get(self, *path_components):
path_components = filter(None, path_components)
return self.make_request("/".join(path_components))
def post(self, *path_components, **extra_post_data):
path_components = filter(None, path_components)
return self.make_request("/".join(path_components), extra_post_data)
def make_request(self, path, extra_post_data=None):