diff options
author | 2011-12-03 20:07:07 +0100 | |
---|---|---|
committer | 2011-12-03 20:07:07 +0100 | |
commit | c1dad1ab5856e7e559cc2b2eaa7c8acb231981d1 (patch) | |
tree | f760a889eada0fe0d8cf8cadd8c19fa42c9b783b /github3/models | |
parent | Fix bugs (diff) | |
parent | Complete AuthGist handler (diff) | |
download | python-github3-c1dad1ab5856e7e559cc2b2eaa7c8acb231981d1.tar.xz python-github3-c1dad1ab5856e7e559cc2b2eaa7c8acb231981d1.zip |
Merge branch 'develop'
Diffstat (limited to 'github3/models')
-rw-r--r-- | github3/models/__init__.py | 2 | ||||
-rw-r--r-- | github3/models/base.py | 11 | ||||
-rw-r--r-- | github3/models/gists.py | 29 | ||||
-rw-r--r-- | github3/models/orgs.py | 2 | ||||
-rw-r--r-- | github3/models/repos.py | 2 | ||||
-rw-r--r-- | github3/models/user.py | 24 |
6 files changed, 45 insertions, 25 deletions
diff --git a/github3/models/__init__.py b/github3/models/__init__.py index ff0c28a..0471393 100644 --- a/github3/models/__init__.py +++ b/github3/models/__init__.py @@ -1,4 +1,4 @@ from .user import AuthUser, User, Key from .repos import Repo from .orgs import Org -from .gists import Gist +from .gists import Gist, GistComment diff --git a/github3/models/base.py b/github3/models/base.py index df0c82b..5295d07 100644 --- a/github3/models/base.py +++ b/github3/models/base.py @@ -1,9 +1,5 @@ -""" -github3.models -~~~~~~~~~~~~~~ - -This package provides the Github3 object model. -""" +#!/usr/bin/env python +# -*- encoding: utf-8 -*- class BaseResource(object): """A BaseResource object.""" @@ -14,6 +10,9 @@ class BaseResource(object): setattr(self, attr, value) super(BaseResource, self).__init__() + def __len__(self): + return len(self.__dict__) + @classmethod def idl(self): raise NotImplementedError('Each model need subcass that method') diff --git a/github3/models/gists.py b/github3/models/gists.py index d1b416d..8979dbb 100644 --- a/github3/models/gists.py +++ b/github3/models/gists.py @@ -1,11 +1,26 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -# -# author: David Medina from .base import BaseResource from .user import User + +class GistComment(BaseResource): + """ Gist comment """ + + @classmethod + def idl(self): + return { + 'strs': ['url', 'body', 'body_text', 'body_html'], + 'ints': ['id'], + 'maps': {'user': User}, + 'dates': ['created_at'], + } + + def __repr__(self): + return '<GistComment %s>' % self.user.login + + class File(BaseResource): """ File model """ @@ -19,6 +34,7 @@ class File(BaseResource): def __repr__(self): return '<File gist> %s' % self.filename + class GistFork(BaseResource): """ GistFork model """ @@ -33,6 +49,7 @@ class GistFork(BaseResource): def __repr__(self): return '<Gist fork> %s>' % self.user.login + class ChangeStatus(BaseResource): """ ChangeStatus model """ @@ -45,6 +62,7 @@ class ChangeStatus(BaseResource): def __repr__(self): return '<Gist history> change_status>' + class GistHistory(BaseResource): """ """ @@ -59,18 +77,21 @@ class GistHistory(BaseResource): 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'], + '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}, + 'collection_maps': {'files': File, 'forks': GistFork, + 'history': GistHistory}, } def __repr__(self): diff --git a/github3/models/orgs.py b/github3/models/orgs.py index 5e66c35..b2dacbd 100644 --- a/github3/models/orgs.py +++ b/github3/models/orgs.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -# -# author: David Medina from .base import BaseResource from .user import Plan diff --git a/github3/models/repos.py b/github3/models/repos.py index d1b7b75..882fb37 100644 --- a/github3/models/repos.py +++ b/github3/models/repos.py @@ -1,7 +1,5 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -# -# author: David Medina from .base import BaseResource from .user import User diff --git a/github3/models/user.py b/github3/models/user.py index 7ec7999..aed6f09 100644 --- a/github3/models/user.py +++ b/github3/models/user.py @@ -1,10 +1,9 @@ #!/usr/bin/env python # -*- encoding: utf-8 -*- -# -# author: David Medina from .base import BaseResource + class Plan(BaseResource): """Github Plan object model.""" @@ -18,6 +17,7 @@ class Plan(BaseResource): def __repr__(self): return '<Plan %s>' % self.name + class Key(BaseResource): """Github Key object model.""" @@ -31,35 +31,39 @@ class Key(BaseResource): def __repr__(self): return '<Key %s>' % self.title + class User(BaseResource): """Github User object model.""" @classmethod def idl(self): return { - 'strs': ['login','avatar_url', 'url', 'name', 'company', 'blog', - 'location', 'email', 'bio', 'html_url', 'type'], + 'strs': [ + 'login', 'avatar_url', 'gravatar_id', 'url', 'name', + 'company', 'blog', 'location', 'email', 'bio', 'html_url', + 'type'], 'ints': [ 'id', 'public_repos', 'public_gists', 'followers', 'following', 'total_private_repos', 'owned_private_repos', 'private_gists', 'disk_usage', 'collaborators'], 'maps': {'plan': Plan}, - 'dates': ['created_at',], + 'dates': ['created_at', ], 'bools': ['hireable', ], } def __repr__(self): - return '<User %s>' % self.login + return '<User %s>' % getattr(self, 'login', 'without user') #def handler(self): - # return self._gh.user_handler(self.login, force=True) + # return self._gh.users + class AuthUser(User): """Github Authenticated User object model.""" - #def handler(self): - # return self._gh.user_handler(self.login, force=True, private=True) - def __repr__(self): return '<AuthUser %s>' % self.login + #def handler(self): + # return self._gh.users + |