aboutsummaryrefslogtreecommitdiffstats
path: root/github3/handlers/gists.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2011-11-30 00:19:50 +0100
committerDavid Medina <davidmedina9@gmail.com>2011-11-30 00:19:50 +0100
commitfbd04697750cefc087611943e0b70be6bed5df3d (patch)
treeb310988b605ed51c1aa224389d96c3fee8379b24 /github3/handlers/gists.py
parentFix mime_header to return None if needed (diff)
downloadpython-github3-fbd04697750cefc087611943e0b70be6bed5df3d.tar.xz
python-github3-fbd04697750cefc087611943e0b70be6bed5df3d.zip
Gist public handler completed
Diffstat (limited to 'github3/handlers/gists.py')
-rw-r--r--github3/handlers/gists.py42
1 files changed, 37 insertions, 5 deletions
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 '<Gist handler>'
+ 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):