aboutsummaryrefslogtreecommitdiffstats
path: root/github3/models/gists.py
diff options
context:
space:
mode:
authorDavid Medina <davidmedina9@gmail.com>2011-11-01 12:30:25 +0100
committerDavid Medina <davidmedina9@gmail.com>2011-11-01 12:30:25 +0100
commitb17dbea56f59aa5403e5722e12878c7183742551 (patch)
treeea02535e78ae2c59d9099850e5ab2d4b1d044f10 /github3/models/gists.py
parentWip on handlers (diff)
downloadpython-github3-b17dbea56f59aa5403e5722e12878c7183742551.tar.xz
python-github3-b17dbea56f59aa5403e5722e12878c7183742551.zip
Decouple Handlers and Models
Handler User complete
Diffstat (limited to 'github3/models/gists.py')
-rw-r--r--github3/models/gists.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/github3/models/gists.py b/github3/models/gists.py
new file mode 100644
index 0000000..5ad61c3
--- /dev/null
+++ b/github3/models/gists.py
@@ -0,0 +1,49 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+#
+# author: David Medina
+
+from .base import BaseResource
+from .user import User
+
+class File(BaseResource):
+ _strs = ['filename', 'raw_url', 'content', 'language', 'type']
+ _ints = ['size']
+
+ def __repr__(self):
+ return '<File gist> %s' % self.filename
+
+class GistFork(BaseResource):
+ _strs = ['url']
+ _dates = ['created_at']
+ _map = {'user': User}
+
+ def __repr__(self):
+ return '<Gist fork> %s>' % self.user.login
+
+class ChangeStatus(BaseResource):
+ _ints = ['deletions', 'additions', 'total']
+
+ def __repr__(self):
+ return '<Gist history> change_status>'
+
+class GistHistory(BaseResource):
+ _strs = ['url', 'version']
+ _map = {'user': User, 'change_status': ChangeStatus}
+ _dates = ['committed_at']
+
+class Gist(BaseResource):
+ _strs = ['url', 'description', 'html_url', 'git_pull_url', 'git_push_url']
+ _ints = ['id', 'comments']
+ _bools = ['public']
+ _dates = ['created_at']
+ _map = {'user': User}
+ _list_map = {'files': File, 'forks': GistFork, 'history': GistHistory}
+
+ @property
+ def ri(self):
+ return ('users', self.user.login, self.id)
+
+ def __repr__(self):
+ return '<gist %s/%s>' % (self.user.login, self.description)
+