From fbd04697750cefc087611943e0b70be6bed5df3d Mon Sep 17 00:00:00 2001 From: David Medina Date: Wed, 30 Nov 2011 00:19:50 +0100 Subject: Gist public handler completed --- github3/handlers/gists.py | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) (limited to 'github3/handlers') diff --git a/github3/handlers/gists.py b/github3/handlers/gists.py index 38418ca..37b1c3d 100644 --- a/github3/handlers/gists.py +++ b/github3/handlers/gists.py @@ -1,23 +1,55 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -from .base import Handler -from .. import models +from .base import Handler, MimeTypeMixin +from github3 import models -class Gist(Handler): - """ Gist handler """ +class Gist(Handler, MimeTypeMixin): + """ Gist handler with public access """ prefix = 'gists' def __repr__(self): return '' + def all_gists(self, limit=None): + """ Return all public gists + + NOTE: It returns all gists in github environment. Maybe you + want to use `limit` parameter + """ + + return self._get_resources('', model=models.Gist, limit=limit) + def get(self, gist_id): - """ Return gist """ + """ Return gist + + param `gist_id`: Gist id + """ return self._get_resource(gist_id, model=models.Gist) + def get_comments(self, gist_id, limit=None): + """ Return gist's comments + + param `gist_id`: Gist id + param `limit`: Number of comments + """ + + return self._get_resources('%s/comments' % gist_id, + model=models.GistComment, limit=limit, + headers=self.mime_header()) + + def get_comment(self, comment_id): + """ Return gist's comment + + param `comment_id`: Comment id + """ + + return self._get_resource('comments/%s' % comment_id, + model=models.GistComment, headers=self.mime_header()) + class AuthGist(Gist): -- cgit v1.3-8-gc7d7