mirror of
https://github.com/kennethreitz/python-github3.git
synced 2026-06-05 23:10:17 +00:00
cleanups
This commit is contained in:
+46
-21
@@ -17,6 +17,7 @@ class BaseResource(object):
|
|||||||
_bools = []
|
_bools = []
|
||||||
_map = {}
|
_map = {}
|
||||||
_writeable = []
|
_writeable = []
|
||||||
|
_modified = []
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -47,10 +48,11 @@ class BaseResource(object):
|
|||||||
|
|
||||||
return to_python(
|
return to_python(
|
||||||
obj=cls(), in_dict=d,
|
obj=cls(), in_dict=d,
|
||||||
str_keys = cls._strings,
|
str_keys = cls._strs,
|
||||||
int_keys = cls._ints,
|
int_keys = cls._ints,
|
||||||
date_keys = cls._datetimes,
|
date_keys = cls._dates,
|
||||||
bool_keys = cls._booleans,
|
bool_keys = cls._bools,
|
||||||
|
object_map = cls._map,
|
||||||
_gh = gh
|
_gh = gh
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -61,6 +63,17 @@ class BaseResource(object):
|
|||||||
# TODO: when writable key changed,
|
# TODO: when writable key changed,
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
class Plan(BaseResource):
|
||||||
|
"""Github Plan object model."""
|
||||||
|
|
||||||
|
_strs = ['name']
|
||||||
|
_ints = ['space', 'collaborators', 'private_repos']
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<plan {0}>'.format(str(self.name))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class User(BaseResource):
|
class User(BaseResource):
|
||||||
"""Github User object model."""
|
"""Github User object model."""
|
||||||
|
|
||||||
@@ -69,31 +82,43 @@ class User(BaseResource):
|
|||||||
'email', 'bio', 'html_url']
|
'email', 'bio', 'html_url']
|
||||||
|
|
||||||
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following']
|
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following']
|
||||||
_datetimes = ['created_at',]
|
_dates = ['created_at',]
|
||||||
_booleans = ['hireable', ]
|
_bools = ['hireable', ]
|
||||||
_map = {}
|
_map = {}
|
||||||
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
|
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super(User, self).__init__()
|
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<user {0}>'.format(self.login)
|
return '<user {0}>'.format(self.login)
|
||||||
|
|
||||||
|
|
||||||
def _update(self):
|
class User(BaseResource):
|
||||||
"""Update the User."""
|
"""Github User object model."""
|
||||||
|
|
||||||
args = to_api(
|
_strings = [
|
||||||
dict(
|
'login','gravatar_url', 'url', 'name', 'company', 'blog', 'location',
|
||||||
favorite=self.favorite,
|
'email', 'bio', 'html_url']
|
||||||
archive=self.archive,
|
|
||||||
read_percent=self.read_percent,
|
|
||||||
),
|
|
||||||
int_keys=('favorite', 'archive')
|
|
||||||
)
|
|
||||||
|
|
||||||
r = self._rdd._post_resource(('bookmarks', self.id), **args)
|
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following', 'total_private_repos', 'owned_private_repos', 'private_gists', 'disk_usage', 'collaborators']
|
||||||
|
_dates = ['created_at',]
|
||||||
|
_bools = ['hireable', ]
|
||||||
|
_map = {'plan': Plan}
|
||||||
|
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
|
||||||
|
|
||||||
return r
|
def __repr__(self):
|
||||||
|
return '<user {0}>'.format(self.login)
|
||||||
|
|
||||||
|
# def _update(self):
|
||||||
|
# """Update the User."""
|
||||||
|
|
||||||
|
# args = to_api(
|
||||||
|
# dict(
|
||||||
|
# favorite=self.favorite,
|
||||||
|
# archive=self.archive,
|
||||||
|
# read_percent=self.read_percent,
|
||||||
|
# ),
|
||||||
|
# int_keys=('favorite', 'archive')
|
||||||
|
# )
|
||||||
|
|
||||||
|
# r = self._rdd._post_resource(('bookmarks', self.id), **args)
|
||||||
|
|
||||||
|
# return r
|
||||||
Reference in New Issue
Block a user