77"""
88
99from json import dumps
10+ from uritemplate import URITemplate
1011from github3 .events import Event
1112from github3 .models import GitHubObject , GitHubCore , BaseAccount
1213from github3 .decorators import requires_auth
@@ -106,6 +107,7 @@ def is_free(self):
106107
107108
108109class User (BaseAccount ):
110+
109111 """The :class:`User <User>` object. This handles and structures information
110112 in the `User section <http://developer.github.com/v3/users/>`_.
111113
@@ -118,7 +120,9 @@ class User(BaseAccount):
118120
119121 u1.id == u2.id
120122 u1.id != u2.id
123+
121124 """
125+
122126 def __init__ (self , user , session = None ):
123127 super (User , self ).__init__ (user , session )
124128 if not self .type :
@@ -147,6 +151,39 @@ def __init__(self, user, session=None):
147151 #: Which plan this user is on
148152 self .plan = Plan (user .get ('plan' , {}))
149153
154+ #: Events URL Template
155+ self .events_url = None
156+ events_url = user .get ('events_url' , '' )
157+ if events_url :
158+ self .events_url = URITemplate (events_url )
159+
160+ #: Followers URL (not a template)
161+ self .followers_url = user .get ('followers_url' , '' )
162+
163+ #: Gists URL Template
164+ self .gists_url = None
165+ gists_url = user .get ('gists_url' , '' )
166+ if gists_url :
167+ self .gists_url = URITemplate (gists_url )
168+
169+ #: Organizations URL (not a template)
170+ self .organizations_url = user .get ('organizations_url' , '' )
171+
172+ #: Received Events URL (not a template)
173+ self .received_events_url = user .get ('received_events_url' , '' )
174+
175+ #: Repostories URL (not a template)
176+ self .repos_url = user .get ('repos_url' , '' )
177+
178+ #: Starred URL Template
179+ self .starred_url = None
180+ starred_url = user .get ('starred_url' , '' )
181+ if starred_url :
182+ self .starred_url = URITemplate (starred_url )
183+
184+ #: Subscriptions URL (not a template)
185+ self .subscriptions_url = user .get ('subscriptions_url' , '' )
186+
150187 def __str__ (self ):
151188 return self .login
152189
@@ -214,7 +251,7 @@ def is_following(self, login):
214251 :returns: bool
215252
216253 """
217- url = self ._build_url ( 'following' , login , base_url = self . _api )
254+ url = self .following_url . expand ( login )
218255 return self ._boolean (self ._get (url ), 204 , 404 )
219256
220257 def iter_events (self , public = False , number = - 1 , etag = None ):
@@ -328,7 +365,7 @@ def iter_starred(self, sort=None, direction=None, number=-1, etag=None):
328365
329366 params = {'sort' : sort , 'direction' : direction }
330367 self ._remove_none (params )
331- url = self ._build_url ( 'starred' , base_url = self . _api )
368+ url = self .starred_url . expand ( owner = None , repo = None )
332369 return self ._iter (int (number ), url , Repository , params , etag )
333370
334371 def iter_subscriptions (self , number = - 1 , etag = None ):
0 commit comments