1
1
# -*- coding: utf-8 -*-
2
- """
3
- github3.users
4
- =============
5
-
6
- This module contains everything relating to Users.
7
-
8
- """
2
+ """This module contains everything relating to Users."""
9
3
from __future__ import unicode_literals
10
4
11
5
from json import dumps
19
13
20
14
21
15
class Key (GitHubCore ):
22
- """The :class:`Key <Key>` object. Please see GitHub's `Key Documentation
23
- <http://developer.github.com/v3/users/keys/>`_ for more information.
24
-
25
- Two key instances can be checked like so::
16
+ """The :class:`Key <Key>` object.
26
17
27
- k1 == k2
28
- k1 != k2
29
-
30
- And is equivalent to::
18
+ Please see GitHub's `Key Documentation`_ for more information.
31
19
32
- k1.id == k2.id
33
- k1.id != k2.id
20
+ .. _Key Documentation:
21
+ http://developer.github.com/v3/users/keys/
34
22
"""
35
23
36
24
def _update_attributes (self , key , session = None ):
@@ -53,7 +41,7 @@ def __str__(self):
53
41
54
42
@requires_auth
55
43
def delete (self ):
56
- """Delete this Key """
44
+ """Delete this key. """
57
45
return self ._boolean (self ._delete (self ._api ), 204 , 404 )
58
46
59
47
@requires_auth
@@ -80,10 +68,12 @@ def update(self, title, key):
80
68
81
69
82
70
class Plan (GitHubCore ):
83
- """The :class:`Plan <Plan>` object. This makes interacting with the plan
84
- information about a user easier. Please see GitHub's `Authenticated User
85
- <http://developer.github.com/v3/users/#get-the-authenticated-user>`_
86
- documentation for more specifics.
71
+ """The :class:`Plan <Plan>` object.
72
+
73
+ Please see GitHub's `Authenticated User`_ documentation for more details.
74
+
75
+ .. _Authenticated User:
76
+ http://developer.github.com/v3/users/#get-the-authenticated-user
87
77
"""
88
78
89
79
def _update_attributes (self , plan ):
@@ -106,19 +96,20 @@ def __str__(self):
106
96
return self .name
107
97
108
98
def is_free (self ):
109
- """Checks if this is a free plan.
99
+ """Check if this is a free plan.
110
100
111
101
:returns: bool
112
102
"""
113
103
return self .name == 'free' # (No coverage)
114
104
115
105
116
106
class Email (GitHubCore ):
117
-
118
107
"""The :class:`Email` object.
119
108
120
- Please see GitHub's `Emails documentation
121
- <https://developer.github.com/v3/users/emails/>` for more information.
109
+ Please see GitHub's `Emails documentation`_ for more information.
110
+
111
+ .. _Emails documentation:
112
+ https://developer.github.com/v3/users/emails/
122
113
"""
123
114
124
115
def _update_attributes (self , email ):
@@ -139,8 +130,9 @@ def __str__(self):
139
130
140
131
141
132
class User (BaseAccount ):
142
- """The :class:`User <User>` object. This handles and structures information
143
- in the `User section <http://developer.github.com/v3/users/>`_.
133
+ """The :class:`User <User>` object.
134
+
135
+ This handles and structures information in the `User section`_.
144
136
145
137
Two user instances can be checked like so::
146
138
@@ -152,6 +144,8 @@ class User(BaseAccount):
152
144
u1.id == u2.id
153
145
u1.id != u2.id
154
146
147
+ .. _User section:
148
+ http://developer.github.com/v3/users/
155
149
"""
156
150
157
151
def _update_attributes (self , user ):
@@ -249,7 +243,7 @@ def is_assignee_on(self, username, repository):
249
243
return self ._boolean (self ._get (url ), 204 , 404 )
250
244
251
245
def is_following (self , username ):
252
- """Checks if this user is following ``username``.
246
+ """Check if this user is following ``username``.
253
247
254
248
:param str username: (required)
255
249
:returns: bool
@@ -259,7 +253,7 @@ def is_following(self, username):
259
253
return self ._boolean (self ._get (url ), 204 , 404 )
260
254
261
255
def events (self , public = False , number = - 1 , etag = None ):
262
- """Iterate over events performed by this user.
256
+ r """Iterate over events performed by this user.
263
257
264
258
:param bool public: (optional), only list public events for the
265
259
authenticated user
@@ -276,7 +270,7 @@ def events(self, public=False, number=-1, etag=None):
276
270
return self ._iter (int (number ), url , Event , etag = etag )
277
271
278
272
def followers (self , number = - 1 , etag = None ):
279
- """Iterate over the followers of this user.
273
+ r """Iterate over the followers of this user.
280
274
281
275
:param int number: (optional), number of followers to return. Default:
282
276
-1 returns all available
@@ -288,7 +282,7 @@ def followers(self, number=-1, etag=None):
288
282
return self ._iter (int (number ), url , User , etag = etag )
289
283
290
284
def following (self , number = - 1 , etag = None ):
291
- """Iterate over the users being followed by this user.
285
+ r """Iterate over the users being followed by this user.
292
286
293
287
:param int number: (optional), number of users to return. Default: -1
294
288
returns all available users
@@ -300,7 +294,7 @@ def following(self, number=-1, etag=None):
300
294
return self ._iter (int (number ), url , User , etag = etag )
301
295
302
296
def keys (self , number = - 1 , etag = None ):
303
- """Iterate over the public keys of this user.
297
+ r """Iterate over the public keys of this user.
304
298
305
299
.. versionadded:: 0.5
306
300
@@ -315,8 +309,9 @@ def keys(self, number=-1, etag=None):
315
309
316
310
@requires_auth
317
311
def organization_events (self , org , number = - 1 , etag = None ):
318
- """Iterate over events as they appear on the user's organization
319
- dashboard. You must be authenticated to view this.
312
+ r"""Iterate over events from the user's organization dashboard.
313
+
314
+ .. note:: You must be authenticated to view this.
320
315
321
316
:param str org: (required), name of the organization
322
317
:param int number: (optional), number of events to return. Default: -1
@@ -331,9 +326,10 @@ def organization_events(self, org, number=-1, etag=None):
331
326
return self ._iter (int (number ), url , Event , etag = etag )
332
327
333
328
def received_events (self , public = False , number = - 1 , etag = None ):
334
- """Iterate over events that the user has received. If the user is the
335
- authenticated user, you will see private and public events, otherwise
336
- you will only see public events.
329
+ r"""Iterate over events that the user has received.
330
+
331
+ If the user is the authenticated user, you will see private and public
332
+ events, otherwise you will only see public events.
337
333
338
334
:param bool public: (optional), determines if the authenticated user
339
335
sees both private and public or just public
@@ -350,7 +346,7 @@ def received_events(self, public=False, number=-1, etag=None):
350
346
return self ._iter (int (number ), url , Event , etag = etag )
351
347
352
348
def organizations (self , number = - 1 , etag = None ):
353
- """Iterate over organizations the user is member of
349
+ r """Iterate over organizations the user is member of.
354
350
355
351
:param int number: (optional), number of organizations to return.
356
352
Default: -1 returns all available organization
@@ -404,8 +400,12 @@ def subscriptions(self, number=-1, etag=None):
404
400
405
401
@requires_auth
406
402
def rename (self , login ):
407
- """Rename the user. This is only available for administrators of
408
- a GitHub Enterprise instance.
403
+ """Rename the user.
404
+
405
+ .. note::
406
+
407
+ This is only available for administrators of a GitHub Enterprise
408
+ instance.
409
409
410
410
:param str login: (required), new name of the user
411
411
:returns: bool
@@ -506,10 +506,14 @@ def unsuspend(self):
506
506
507
507
@requires_auth
508
508
def delete (self ):
509
- """Delete the user. Per GitHub API documentation, it is often preferable
510
- to suspend the user.
509
+ """Delete the user.
511
510
512
- This is only available for admins of a GitHub Enterprise instance.
511
+ Per GitHub API documentation, it is often preferable to suspend the
512
+ user.
513
+
514
+ .. note::
515
+
516
+ This is only available for admins of a GitHub Enterprise instance.
513
517
514
518
:returns: bool -- True if successful, False otherwise
515
519
"""
0 commit comments