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/requests/git_data/blobs.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 pygithub3/requests/git_data/blobs.py (limited to 'pygithub3/requests/git_data/blobs.py') diff --git a/pygithub3/requests/git_data/blobs.py b/pygithub3/requests/git_data/blobs.py new file mode 100644 index 0000000..4a49c6b --- /dev/null +++ b/pygithub3/requests/git_data/blobs.py @@ -0,0 +1,20 @@ +# -*- encoding: utf-8 -*- + +from pygithub3.requests.base import Request +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 = { + 'schema': ('content', 'encoding'), + 'required': ('content', 'encoding'), #TODO: is enc really required? + } -- 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/requests/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 From 30c1cec25eff0a37ad494f57bfc8fce7dedf5de2 Mon Sep 17 00:00:00 2001 From: Nat Williams Date: Mon, 16 Apr 2012 15:39:27 -0500 Subject: add docs and a few little pep8 tweaks --- docs/git_data.rst | 86 ++++++++++++++++++++++++++++++++++ docs/services.rst | 1 + pygithub3/requests/git_data/blobs.py | 2 +- pygithub3/requests/git_data/tags.py | 1 - pygithub3/resources/gists.py | 1 + pygithub3/resources/git_data.py | 3 +- pygithub3/services/git_data/commits.py | 2 - 7 files changed, 91 insertions(+), 5 deletions(-) create mode 100644 docs/git_data.rst (limited to 'pygithub3/requests/git_data/blobs.py') diff --git a/docs/git_data.rst b/docs/git_data.rst new file mode 100644 index 0000000..549420b --- /dev/null +++ b/docs/git_data.rst @@ -0,0 +1,86 @@ +.. _Git Data service: + +Git Data services +================= + +**Example**:: + + from pygithub3 import Github + + gh = Github(user='someone', repo='some_repo') + + a_blob = gh.git_data.blobs.get('a long sha') + + dev_branch = gh.git_data.references.get('heads/add_a_thing') + + +GitData +------- + +.. autoclass:: pygithub3.services.git_data.GitData + :members: + + .. attribute:: blobs + + :ref:`Blobs service` + + .. attribute:: commits + + :ref:`Commits service` + + .. attribute:: references + + :ref:`References service` + + .. attribute:: tags + + :ref:`Tags service` + + .. attribute:: trees + + :ref:`Trees service` + + +.. _Blobs service: + +Blobs +----- + +.. autoclass:: pygithub3.services.git_data.Blobs + :members: + + +.. _Commits service: + +Commits +------- + +.. autoclass:: pygithub3.services.git_data.Commits + :members: + + +.. _References service: + +References +---------- + +.. autoclass:: pygithub3.services.git_data.References + :members: + + +.. _Tags service: + +Tags +---- + +.. autoclass:: pygithub3.services.git_data.Tags + :members: + + +.. _Trees service: + +Trees +----- + +.. autoclass:: pygithub3.services.git_data.Trees + :members: diff --git a/docs/services.rst b/docs/services.rst index 71fa690..2fbd2ee 100644 --- a/docs/services.rst +++ b/docs/services.rst @@ -72,5 +72,6 @@ List of services users repos gists + git_data .. _mimetypes: http://developer.github.com/v3/mime diff --git a/pygithub3/requests/git_data/blobs.py b/pygithub3/requests/git_data/blobs.py index 9ce500a..a4bddd6 100644 --- a/pygithub3/requests/git_data/blobs.py +++ b/pygithub3/requests/git_data/blobs.py @@ -14,5 +14,5 @@ class Create(Request): resource = Blob body_schema = { 'schema': ('content', 'encoding'), - 'required': ('content', 'encoding'), #TODO: is enc really required? + 'required': ('content', 'encoding'), # TODO: is enc really required? } diff --git a/pygithub3/requests/git_data/tags.py b/pygithub3/requests/git_data/tags.py index 8b37f0e..dbc8da4 100644 --- a/pygithub3/requests/git_data/tags.py +++ b/pygithub3/requests/git_data/tags.py @@ -13,4 +13,3 @@ class Create(Request): 'schema': ('tag', 'message', 'object', 'type', 'tagger'), 'required': ('type',), } - diff --git a/pygithub3/resources/gists.py b/pygithub3/resources/gists.py index 7e9550a..89425bf 100644 --- a/pygithub3/resources/gists.py +++ b/pygithub3/resources/gists.py @@ -15,6 +15,7 @@ class Fork(Resource): _dates = ('created_at', ) _maps = {'user': User} + def __str__(self): return '' diff --git a/pygithub3/resources/git_data.py b/pygithub3/resources/git_data.py index 4adcf5d..4d12e01 100644 --- a/pygithub3/resources/git_data.py +++ b/pygithub3/resources/git_data.py @@ -17,7 +17,8 @@ class Reference(Resource): class Tag(Resource): _maps = {'object': Commit, - 'tagger': Author,} # committer? tagger? + 'tagger': Author} # committer? tagger? + def __str__(self): return '' % getattr(self, 'tag', '') diff --git a/pygithub3/services/git_data/commits.py b/pygithub3/services/git_data/commits.py index 4debd95..25e8775 100644 --- a/pygithub3/services/git_data/commits.py +++ b/pygithub3/services/git_data/commits.py @@ -31,5 +31,3 @@ class Commits(Service): self.make_request('git_data.commits.create', user=user, repo=repo, body=data) ) - - -- cgit v1.2.3-59-g8ed1b