From 4ce1a90038b23d931858ad22815dbe29f74d7d98 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Fri, 13 Apr 2012 17:06:09 -0500 Subject: add Git Data API support --- pygithub3/services/git_data/blobs.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 pygithub3/services/git_data/blobs.py (limited to 'pygithub3/services/git_data/blobs.py') diff --git a/pygithub3/services/git_data/blobs.py b/pygithub3/services/git_data/blobs.py new file mode 100644 index 0000000..d5baa2d --- /dev/null +++ b/pygithub3/services/git_data/blobs.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python +# -*- encoding: utf-8 -*- + +from pygithub3.services.base import Service + + +class Blobs(Service): + """Consume `Blobs API `_""" + + def get(self, sha, user=None, repo=None): + """Get a particular blob + + :param str sha: The sha of the blob to get + + """ + request = self.make_request('git_data.blobs.get', sha=sha, + user=user, repo=repo) + return self._get(request) + + def create(self, data, user=None, repo=None): + """Create a blob""" + request = self.make_request('git_data.blobs.create', body=data, + user=user, repo=repo) + return self._post(request) -- cgit v1.2.3-59-g8ed1b From 286cf17b23890b709a7b55ecb21148af88577779 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Mon, 16 Apr 2012 13:48:54 -0500 Subject: add some docs I missed --- pygithub3/requests/git_data/blobs.py | 2 -- pygithub3/requests/git_data/commits.py | 2 -- pygithub3/services/git_data/blobs.py | 10 +++++++++- pygithub3/services/git_data/commits.py | 8 +++++++- pygithub3/services/git_data/references.py | 16 +++++++++++++--- 5 files changed, 29 insertions(+), 9 deletions(-) (limited to 'pygithub3/services/git_data/blobs.py') diff --git a/pygithub3/requests/git_data/blobs.py b/pygithub3/requests/git_data/blobs.py index 4a49c6b..9ce500a 100644 --- a/pygithub3/requests/git_data/blobs.py +++ b/pygithub3/requests/git_data/blobs.py @@ -5,13 +5,11 @@ from pygithub3.resources.git_data import Blob class Get(Request): - uri = 'repos/{user}/{repo}/git/blobs/{sha}' resource = Blob class Create(Request): - uri = 'repos/{user}/{repo}/git/blobs' resource = Blob body_schema = { diff --git a/pygithub3/requests/git_data/commits.py b/pygithub3/requests/git_data/commits.py index 936d3c7..caf1e7d 100644 --- a/pygithub3/requests/git_data/commits.py +++ b/pygithub3/requests/git_data/commits.py @@ -16,5 +16,3 @@ class Create(Request): 'schema': ('message', 'tree', 'parents', 'author', 'committer'), 'required': ('message', 'tree', 'parents'), } - - diff --git a/pygithub3/services/git_data/blobs.py b/pygithub3/services/git_data/blobs.py index d5baa2d..4f1a6e7 100644 --- a/pygithub3/services/git_data/blobs.py +++ b/pygithub3/services/git_data/blobs.py @@ -11,6 +11,8 @@ class Blobs(Service): """Get a particular blob :param str sha: The sha of the blob to get + :param str user: Username + :param str repo: Repository """ request = self.make_request('git_data.blobs.get', sha=sha, @@ -18,7 +20,13 @@ class Blobs(Service): return self._get(request) def create(self, data, user=None, repo=None): - """Create a blob""" + """Create a blob + + :param dict data: Data describing the blob to create + :param str user: Username + :param str repo: Repository + + """ request = self.make_request('git_data.blobs.create', body=data, user=user, repo=repo) return self._post(request) diff --git a/pygithub3/services/git_data/commits.py b/pygithub3/services/git_data/commits.py index cdca300..4debd95 100644 --- a/pygithub3/services/git_data/commits.py +++ b/pygithub3/services/git_data/commits.py @@ -8,7 +8,13 @@ class Commits(Service): """Consume `Commits API `_""" def get(self, sha, user=None, repo=None): - """get a commit from the current repo""" + """get a commit from the current repo + + :param str sha: SHA of the Commit that you want. + :param str user: Username + :param str repo: Repository + + """ request = self.make_request('git_data.commits.get', sha=sha, user=user, repo=repo) return self._get(request) diff --git a/pygithub3/services/git_data/references.py b/pygithub3/services/git_data/references.py index 8ae0865..3a24f90 100644 --- a/pygithub3/services/git_data/references.py +++ b/pygithub3/services/git_data/references.py @@ -13,6 +13,10 @@ class References(Service): .. note:: Remember that branch references look like "heads/" + :param str ref: the name of the reference to get + :param str user: Username + :param str repo: Repository + """ return self._get( self.make_request('git_data.references.get', ref=ref, user=user, @@ -24,6 +28,8 @@ class References(Service): :param str namespace: Limit the request to a particular type of reference. For example, ``heads`` or ``tags``. + :param str user: Username + :param str repo: Repository """ return self._get( @@ -34,8 +40,8 @@ class References(Service): """Create a reference :param dict body: Data describing the reference to create - :param str user: username - :param str repo: repository name + :param str user: Username + :param str repo: Repository """ return self._post( @@ -47,7 +53,9 @@ class References(Service): """Update an existing reference :param str ref: The SHA of the reference to update - :param dict body: data + :param dict body: Data to update the reference with + :param str user: Username + :param str repo: Repository """ return self._patch( @@ -59,6 +67,8 @@ class References(Service): """Delete a reference :param str ref: The SHA of the reference to delete + :param str user: Username + :param str repo: Repository """ return self._delete( -- cgit v1.2.3-59-g8ed1b