mirror of
https://github.com/kennethreitz/python-github3.git
synced 2026-06-05 23:10:17 +00:00
basics for editable datapoints
This commit is contained in:
+31
-3
@@ -16,6 +16,7 @@ class BaseResource(object):
|
||||
_dates = []
|
||||
_bools = []
|
||||
_map = {}
|
||||
_writeable = []
|
||||
|
||||
|
||||
def __init__(self):
|
||||
@@ -53,21 +54,48 @@ class BaseResource(object):
|
||||
_gh = gh
|
||||
)
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
|
||||
def setattr(self, k, v):
|
||||
# TODO: when writable key changed,
|
||||
pass
|
||||
|
||||
class User(BaseResource):
|
||||
"""Github User object model."""
|
||||
|
||||
_strings = ['login', 'gravatar_url', 'url', 'name', 'company',
|
||||
'blog', 'location', 'email', 'bio', 'html_url']
|
||||
_strings = [
|
||||
'login','gravatar_url', 'url', 'name', 'company', 'blog', 'location',
|
||||
'email', 'bio', 'html_url']
|
||||
|
||||
_ints = ['id', 'public_repos', 'public_gists', 'followers', 'following']
|
||||
_datetimes = ['created_at',]
|
||||
_booleans = ['hireable', ]
|
||||
_map = {}
|
||||
_writeable = ['name', 'email', 'blog', 'company', 'location', 'hireable', 'bio']
|
||||
|
||||
|
||||
def __init__(self):
|
||||
super(User, self).__init__()
|
||||
|
||||
def __repr__(self):
|
||||
return '<user {0}>'.format(self.login)
|
||||
return '<user {0}>'.format(self.login)
|
||||
|
||||
|
||||
def _update(self):
|
||||
"""Update the authenticated user."""
|
||||
|
||||
# TODO: check that user is authenticated
|
||||
|
||||
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