aboutsummaryrefslogtreecommitdiffstats
path: root/github3/models/gists.py
diff options
context:
space:
mode:
authorAntti Kaihola <akaihol+github@ambitone.com>2011-11-09 13:04:48 +0200
committerAntti Kaihola <akaihol+github@ambitone.com>2011-11-09 13:04:48 +0200
commitf1a03e9fc8ce87ca1beeae5a92082bb32d342df3 (patch)
tree6bca689287379b249aff19fbae075182dc22f95a /github3/models/gists.py
parentAdded create_gist() example to readme (diff)
parentFixing bugs. Crazy night :S (diff)
downloadpython-github3-f1a03e9fc8ce87ca1beeae5a92082bb32d342df3.tar.xz
python-github3-f1a03e9fc8ce87ca1beeae5a92082bb32d342df3.zip
Merged create_gist() into current HEAD of copitux/develop
Diffstat (limited to 'github3/models/gists.py')
-rw-r--r--github3/models/gists.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/github3/models/gists.py b/github3/models/gists.py
new file mode 100644
index 0000000..d1b416d
--- /dev/null
+++ b/github3/models/gists.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+#
+# author: David Medina
+
+from .base import BaseResource
+from .user import User
+
+class File(BaseResource):
+ """ File model """
+
+ @classmethod
+ def idl(self):
+ return {
+ 'strs': ['filename', 'raw_url', 'content', 'language', 'type'],
+ 'ints': ['size'],
+ }
+
+ def __repr__(self):
+ return '<File gist> %s' % self.filename
+
+class GistFork(BaseResource):
+ """ GistFork model """
+
+ @classmethod
+ def idl(self):
+ return {
+ 'strs': ['url'],
+ 'dates': ['created_at'],
+ 'maps': {'user': User}
+ }
+
+ def __repr__(self):
+ return '<Gist fork> %s>' % self.user.login
+
+class ChangeStatus(BaseResource):
+ """ ChangeStatus model """
+
+ @classmethod
+ def idl(self):
+ return {
+ 'ints': ['deletions', 'additions', 'total'],
+ }
+
+ def __repr__(self):
+ return '<Gist history> change_status>'
+
+class GistHistory(BaseResource):
+ """ """
+
+ @classmethod
+ def idl(self):
+ return {
+ 'strs': ['url', 'version'],
+ 'maps': {'user': User, 'change_status': ChangeStatus},
+ 'dates': ['committed_at'],
+ }
+
+ def __repr__(self):
+ return '<GistHistory %s/%s>' % (self.user, self.committed_at)
+
+class Gist(BaseResource):
+ """ """
+
+ @classmethod
+ def idl(self):
+ return {
+ 'strs': ['url', 'description', 'html_url', 'git_pull_url', 'git_push_url'],
+ 'ints': ['id', 'comments'],
+ 'bools': ['public'],
+ 'dates': ['created_at'],
+ 'maps': {'user': User},
+ 'collection_maps': {'files': File, 'forks': GistFork, 'history': GistHistory},
+ }
+
+ def __repr__(self):
+ return '<Gist %s/%s>' % (self.user, self.description)