8000 Decouple User object from BaseAccount object · pythonthings/github3.py@b018bf6 · GitHub
[go: up one dir, main page]

Skip to content

Commit b018bf6

Browse files
committed
Decouple User object from BaseAccount object
1 parent b85314c commit b018bf6

File tree

1 file changed

+56
-3
lines changed

1 file changed

+56
-3
lines changed

github3/users.py

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from .decorators import requires_auth
1111
from .events import Event
12-
from .models import BaseAccount, GitHubCore
12+
from .models import GitHubCore
1313

1414

1515
class Key(GitHubCore):
@@ -129,7 +129,7 @@ def __str__(self):
129129
return self.email
130130

131131

132-
class User(BaseAccount):
132+
class User(GitHubCore):
133133
"""The :class:`User <User>` object.
134134
135135
This handles and structures information in the `User section`_.
@@ -149,10 +149,60 @@ class User(BaseAccount):
149149
"""
150150

151151
def _update_attributes(self, user):
152-
super(User, self)._update_attributes(user)
152+
#: Tells you what type of account this is
153+
self.type = self._get_attribute(user, 'type')
153154
if not self.type:
154155
self.type = 'User'
155156

157+
self._api = self._get_attribute(user, 'url')
158+
159+
#: URL of the avatar at gravatar
160+
self.avatar_url = self._get_attribute(user, 'avatar_url')
161+
162+
#: URL of the blog
163+
self.blog = self._get_attribute(user, 'blog')
164+
165+ 10000
#: Name of the company
166+
self.company = self._get_attribute(user, 'company')
167+
168+
#: datetime object representing the date the account was created
169+
self.created_at = self._strptime_attribute(user, 'created_at')
170+
171+
#: E-mail address of the user/org
172+
self.email = self._get_attribute(user, 'email')
173+
174+
# The number of people following this user
175+
#: Number of followers
176+
self.followers_count = self._get_attribute(user, 'followers')
177+
178+
# The number of people this user follows
179+
#: Number of people the user is following
180+
self.following_count = self._get_attribute(user, 'following')
181+
182+
#: Unique ID of the account
183+
self.id = self._get_attribute(user, 'id')
184+
185+
#: Location of the user/org
186+
self.location = self._get_attribute(user, 'location')
187+
188+
#: User name of the user/organization
189+
self.login = self._get_attribute(user, 'login')
190+
191+
# e.g. first_name last_name
192+
#: Real name of the user/org
193+
self.name = self._get_attribute(user, 'name')
194+
195+
# The number of public_repos
196+
#: Number of public repos owned by the user/org
197+
self.public_repos_count = self._get_attribute(user, 'public_repos')
198+
199+
# e.g. https://github.com/self._login
200+
#: URL of the user/org's profile
201+
self.html_url = self._get_attribute(user, 'html_url')
202+
203+
#: Markdown formatted biography
204+
self.bio = self._get_attribute(user, 'bio')
205+
156206
#: ID of the user's image on Gravatar
157207
self.gravatar_id = self._get_attribute(user, 'gravatar_id')
158208
#: True -- for hire, False -- not for hire
@@ -230,6 +280,9 @@ def _update_attributes(self, user):
230280
def __str__(self):
231281
return self.login
232282

283+
def _repr(self):
284+
return '<User [{s.login}:{s.name}]>'.format(s=self)
285+
233286
def is_assignee_on(self, username, repository):
234287
"""Check if this user can be assigned to issues on username/repository.
235288

0 commit comments

Comments
 (0)
0