comparison venv/lib/python2.7/site-packages/github/NamedUser.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 # -*- coding: utf-8 -*-
2
3 # ########################## Copyrights and license ############################
4 # #
5 # Copyright 2012 Steve English <steve.english@navetas.com> #
6 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> #
7 # Copyright 2012 Zearin <zearin@gonk.net> #
8 # Copyright 2013 AKFish <akfish@gmail.com> #
9 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> #
10 # #
11 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ #
12 # #
13 # PyGithub is free software: you can redistribute it and/or modify it under #
14 # the terms of the GNU Lesser General Public License as published by the Free #
15 # Software Foundation, either version 3 of the License, or (at your option) #
16 # any later version. #
17 # #
18 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY #
19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
20 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more #
21 # details. #
22 # #
23 # You should have received a copy of the GNU Lesser General Public License #
24 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. #
25 # #
26 # ##############################################################################
27
28 import github.GithubObject
29 import github.PaginatedList
30
31 import github.Gist
32 import github.Repository
33 import github.NamedUser
34 import github.Plan
35 import github.Organization
36 import github.Event
37
38
39 class NamedUser(github.GithubObject.CompletableGithubObject):
40 """
41 This class represents NamedUsers as returned for example by http://developer.github.com/v3/todo
42 """
43
44 @property
45 def avatar_url(self):
46 """
47 :type: string
48 """
49 self._completeIfNotSet(self._avatar_url)
50 return self._avatar_url.value
51
52 @property
53 def bio(self):
54 """
55 :type: string
56 """
57 self._completeIfNotSet(self._bio)
58 return self._bio.value
59
60 @property
61 def blog(self):
62 """
63 :type: string
64 """
65 self._completeIfNotSet(self._blog)
66 return self._blog.value
67
68 @property
69 def collaborators(self):
70 """
71 :type: integer
72 """
73 self._completeIfNotSet(self._collaborators)
74 return self._collaborators.value
75
76 @property
77 def company(self):
78 """
79 :type: string
80 """
81 self._completeIfNotSet(self._company)
82 return self._company.value
83
84 @property
85 def contributions(self):
86 """
87 :type: integer
88 """
89 self._completeIfNotSet(self._contributions)
90 return self._contributions.value
91
92 @property
93 def created_at(self):
94 """
95 :type: datetime.datetime
96 """
97 self._completeIfNotSet(self._created_at)
98 return self._created_at.value
99
100 @property
101 def disk_usage(self):
102 """
103 :type: integer
104 """
105 self._completeIfNotSet(self._disk_usage)
106 return self._disk_usage.value
107
108 @property
109 def email(self):
110 """
111 :type: string
112 """
113 self._completeIfNotSet(self._email)
114 return self._email.value
115
116 @property
117 def events_url(self):
118 """
119 :type: string
120 """
121 self._completeIfNotSet(self._events_url)
122 return self._events_url.value
123
124 @property
125 def followers(self):
126 """
127 :type: integer
128 """
129 self._completeIfNotSet(self._followers)
130 return self._followers.value
131
132 @property
133 def followers_url(self):
134 """
135 :type: string
136 """
137 self._completeIfNotSet(self._followers_url)
138 return self._followers_url.value
139
140 @property
141 def following(self):
142 """
143 :type: integer
144 """
145 self._completeIfNotSet(self._following)
146 return self._following.value
147
148 @property
149 def following_url(self):
150 """
151 :type: string
152 """
153 self._completeIfNotSet(self._following_url)
154 return self._following_url.value
155
156 @property
157 def gists_url(self):
158 """
159 :type: string
160 """
161 self._completeIfNotSet(self._gists_url)
162 return self._gists_url.value
163
164 @property
165 def gravatar_id(self):
166 """
167 :type: string
168 """
169 self._completeIfNotSet(self._gravatar_id)
170 return self._gravatar_id.value
171
172 @property
173 def hireable(self):
174 """
175 :type: bool
176 """
177 self._completeIfNotSet(self._hireable)
178 return self._hireable.value
179
180 @property
181 def html_url(self):
182 """
183 :type: string
184 """
185 self._completeIfNotSet(self._html_url)
186 return self._html_url.value
187
188 @property
189 def id(self):
190 """
191 :type: integer
192 """
193 self._completeIfNotSet(self._id)
194 return self._id.value
195
196 @property
197 def location(self):
198 """
199 :type: string
200 """
201 self._completeIfNotSet(self._location)
202 return self._location.value
203
204 @property
205 def login(self):
206 """
207 :type: string
208 """
209 self._completeIfNotSet(self._login)
210 return self._login.value
211
212 @property
213 def name(self):
214 """
215 :type: string
216 """
217 self._completeIfNotSet(self._name)
218 return self._name.value
219
220 @property
221 def organizations_url(self):
222 """
223 :type: string
224 """
225 self._completeIfNotSet(self._organizations_url)
226 return self._organizations_url.value
227
228 @property
229 def owned_private_repos(self):
230 """
231 :type: integer
232 """
233 self._completeIfNotSet(self._owned_private_repos)
234 return self._owned_private_repos.value
235
236 @property
237 def plan(self):
238 """
239 :type: :class:`github.Plan.Plan`
240 """
241 self._completeIfNotSet(self._plan)
242 return self._plan.value
243
244 @property
245 def private_gists(self):
246 """
247 :type: integer
248 """
249 self._completeIfNotSet(self._private_gists)
250 return self._private_gists.value
251
252 @property
253 def public_gists(self):
254 """
255 :type: integer
256 """
257 self._completeIfNotSet(self._public_gists)
258 return self._public_gists.value
259
260 @property
261 def public_repos(self):
262 """
263 :type: integer
264 """
265 self._completeIfNotSet(self._public_repos)
266 return self._public_repos.value
267
268 @property
269 def received_events_url(self):
270 """
271 :type: string
272 """
273 self._completeIfNotSet(self._received_events_url)
274 return self._received_events_url.value
275
276 @property
277 def repos_url(self):
278 """
279 :type: string
280 """
281 self._completeIfNotSet(self._repos_url)
282 return self._repos_url.value
283
284 @property
285 def starred_url(self):
286 """
287 :type: string
288 """
289 self._completeIfNotSet(self._starred_url)
290 return self._starred_url.value
291
292 @property
293 def subscriptions_url(self):
294 """
295 :type: string
296 """
297 self._completeIfNotSet(self._subscriptions_url)
298 return self._subscriptions_url.value
299
300 @property
301 def total_private_repos(self):
302 """
303 :type: integer
304 """
305 self._completeIfNotSet(self._total_private_repos)
306 return self._total_private_repos.value
307
308 @property
309 def type(self):
310 """
311 :type: string
312 """
313 self._completeIfNotSet(self._type)
314 return self._type.value
315
316 @property
317 def updated_at(self):
318 """
319 :type: datetime.datetime
320 """
321 self._completeIfNotSet(self._updated_at)
322 return self._updated_at.value
323
324 @property
325 def url(self):
326 """
327 :type: string
328 """
329 self._completeIfNotSet(self._url)
330 return self._url.value
331
332 def get_events(self):
333 """
334 :calls: `GET /users/:user/events <http://developer.github.com/v3/activity/events>`_
335 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event`
336 """
337 return github.PaginatedList.PaginatedList(
338 github.Event.Event,
339 self._requester,
340 self.url + "/events",
341 None
342 )
343
344 def get_followers(self):
345 """
346 :calls: `GET /users/:user/followers <http://developer.github.com/v3/users/followers>`_
347 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
348 """
349 return github.PaginatedList.PaginatedList(
350 NamedUser,
351 self._requester,
352 self.url + "/followers",
353 None
354 )
355
356 def get_following(self):
357 """
358 :calls: `GET /users/:user/following <http://developer.github.com/v3/users/followers>`_
359 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser`
360 """
361 return github.PaginatedList.PaginatedList(
362 NamedUser,
363 self._requester,
364 self.url + "/following",
365 None
366 )
367
368 def get_gists(self):
369 """
370 :calls: `GET /users/:user/gists <http://developer.github.com/v3/gists>`_
371 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist`
372 """
373 return github.PaginatedList.PaginatedList(
374 github.Gist.Gist,
375 self._requester,
376 self.url + "/gists",
377 None
378 )
379
380 def get_keys(self):
381 """
382 :calls: `GET /users/:user/keys <http://developer.github.com/v3/users/keys>`_
383 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.UserKey.UserKey`
384 """
385 return github.PaginatedList.PaginatedList(
386 github.UserKey.UserKey,
387 self._requester,
388 self.url + "/keys",
389 None
390 )
391
392 def get_orgs(self):
393 """
394 :calls: `GET /users/:user/orgs <http://developer.github.com/v3/orgs>`_
395 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Organization.Organization`
396 """
397 return github.PaginatedList.PaginatedList(
398 github.Organization.Organization,
399 self._requester,
400 self.url + "/orgs",
401 None
402 )
403
404 def get_public_events(self):
405 """
406 :calls: `GET /users/:user/events/public <http://developer.github.com/v3/activity/events>`_
407 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event`
408 """
409 return github.PaginatedList.PaginatedList(
410 github.Event.Event,
411 self._requester,
412 self.url + "/events/public",
413 None
414 )
415
416 def get_public_received_events(self):
417 """
418 :calls: `GET /users/:user/received_events/public <http://developer.github.com/v3/activity/events>`_
419 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event`
420 """
421 return github.PaginatedList.PaginatedList(
422 github.Event.Event,
423 self._requester,
424 self.url + "/received_events/public",
425 None
426 )
427
428 def get_received_events(self):
429 """
430 :calls: `GET /users/:user/received_events <http://developer.github.com/v3/activity/events>`_
431 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Event.Event`
432 """
433 return github.PaginatedList.PaginatedList(
434 github.Event.Event,
435 self._requester,
436 self.url + "/received_events",
437 None
438 )
439
440 def get_repo(self, name):
441 """
442 :calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_
443 :param name: string
444 :rtype: :class:`github.Repository.Repository`
445 """
446 assert isinstance(name, (str, unicode)), name
447 headers, data = self._requester.requestJsonAndCheck(
448 "GET",
449 "/repos/" + self.login + "/" + name
450 )
451 return github.Repository.Repository(self._requester, headers, data, completed=True)
452
453 def get_repos(self, type=github.GithubObject.NotSet):
454 """
455 :calls: `GET /users/:user/repos <http://developer.github.com/v3/repos>`_
456 :param type: string
457 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
458 """
459 assert type is github.GithubObject.NotSet or isinstance(type, (str, unicode)), type
460 url_parameters = dict()
461 if type is not github.GithubObject.NotSet:
462 url_parameters["type"] = type
463 return github.PaginatedList.PaginatedList(
464 github.Repository.Repository,
465 self._requester,
466 self.url + "/repos",
467 url_parameters
468 )
469
470 def get_starred(self):
471 """
472 :calls: `GET /users/:user/starred <http://developer.github.com/v3/activity/starring>`_
473 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
474 """
475 return github.PaginatedList.PaginatedList(
476 github.Repository.Repository,
477 self._requester,
478 self.url + "/starred",
479 None
480 )
481
482 def get_subscriptions(self):
483 """
484 :calls: `GET /users/:user/subscriptions <http://developer.github.com/v3/activity/watching>`_
485 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
486 """
487 return github.PaginatedList.PaginatedList(
488 github.Repository.Repository,
489 self._requester,
490 self.url + "/subscriptions",
491 None
492 )
493
494 def get_watched(self):
495 """
496 :calls: `GET /users/:user/watched <http://developer.github.com/v3/activity/starring>`_
497 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository`
498 """
499 return github.PaginatedList.PaginatedList(
500 github.Repository.Repository,
501 self._requester,
502 self.url + "/watched",
503 None
504 )
505
506 def has_in_following(self, following):
507 """
508 :calls: `GET /users/:user/following/:target_user <http://developer.github.com/v3/users/followers/#check-if-one-user-follows-another>`_
509 :param following: :class:`github.NamedUser.NamedUser`
510 :rtype: bool
511 """
512 assert isinstance(following, github.NamedUser.NamedUser), following
513 status, headers, data = self._requester.requestJson(
514 "GET",
515 self.url + "/following/" + following._identity
516 )
517 return status == 204
518
519 @property
520 def _identity(self):
521 return self.login
522
523 def _initAttributes(self):
524 self._avatar_url = github.GithubObject.NotSet
525 self._bio = github.GithubObject.NotSet
526 self._blog = github.GithubObject.NotSet
527 self._collaborators = github.GithubObject.NotSet
528 self._company = github.GithubObject.NotSet
529 self._contributions = github.GithubObject.NotSet
530 self._created_at = github.GithubObject.NotSet
531 self._disk_usage = github.GithubObject.NotSet
532 self._email = github.GithubObject.NotSet
533 self._events_url = github.GithubObject.NotSet
534 self._followers = github.GithubObject.NotSet
535 self._followers_url = github.GithubObject.NotSet
536 self._following = github.GithubObject.NotSet
537 self._following_url = github.GithubObject.NotSet
538 self._gists_url = github.GithubObject.NotSet
539 self._gravatar_id = github.GithubObject.NotSet
540 self._hireable = github.GithubObject.NotSet
541 self._html_url = github.GithubObject.NotSet
542 self._id = github.GithubObject.NotSet
543 self._location = github.GithubObject.NotSet
544 self._login = github.GithubObject.NotSet
545 self._name = github.GithubObject.NotSet
546 self._organizations_url = github.GithubObject.NotSet
547 self._owned_private_repos = github.GithubObject.NotSet
548 self._plan = github.GithubObject.NotSet
549 self._private_gists = github.GithubObject.NotSet
550 self._public_gists = github.GithubObject.NotSet
551 self._public_repos = github.GithubObject.NotSet
552 self._received_events_url = github.GithubObject.NotSet
553 self._repos_url = github.GithubObject.NotSet
554 self._starred_url = github.GithubObject.NotSet
555 self._subscriptions_url = github.GithubObject.NotSet
556 self._total_private_repos = github.GithubObject.NotSet
557 self._type = github.GithubObject.NotSet
558 self._updated_at = github.GithubObject.NotSet
559 self._url = github.GithubObject.NotSet
560
561 def _useAttributes(self, attributes):
562 if "avatar_url" in attributes: # pragma no branch
563 self._avatar_url = self._makeStringAttribute(attributes["avatar_url"])
564 if "bio" in attributes: # pragma no branch
565 self._bio = self._makeStringAttribute(attributes["bio"])
566 if "blog" in attributes: # pragma no branch
567 self._blog = self._makeStringAttribute(attributes["blog"])
568 if "collaborators" in attributes: # pragma no branch
569 self._collaborators = self._makeIntAttribute(attributes["collaborators"])
570 if "company" in attributes: # pragma no branch
571 self._company = self._makeStringAttribute(attributes["company"])
572 if "contributions" in attributes: # pragma no branch
573 self._contributions = self._makeIntAttribute(attributes["contributions"])
574 if "created_at" in attributes: # pragma no branch
575 self._created_at = self._makeDatetimeAttribute(attributes["created_at"])
576 if "disk_usage" in attributes: # pragma no branch
577 self._disk_usage = self._makeIntAttribute(attributes["disk_usage"])
578 if "email" in attributes: # pragma no branch
579 self._email = self._makeStringAttribute(attributes["email"])
580 if "events_url" in attributes: # pragma no branch
581 self._events_url = self._makeStringAttribute(attributes["events_url"])
582 if "followers" in attributes: # pragma no branch
583 self._followers = self._makeIntAttribute(attributes["followers"])
584 if "followers_url" in attributes: # pragma no branch
585 self._followers_url = self._makeStringAttribute(attributes["followers_url"])
586 if "following" in attributes: # pragma no branch
587 self._following = self._makeIntAttribute(attributes["following"])
588 if "following_url" in attributes: # pragma no branch
589 self._following_url = self._makeStringAttribute(attributes["following_url"])
590 if "gists_url" in attributes: # pragma no branch
591 self._gists_url = self._makeStringAttribute(attributes["gists_url"])
592 if "gravatar_id" in attributes: # pragma no branch
593 self._gravatar_id = self._makeStringAttribute(attributes["gravatar_id"])
594 if "hireable" in attributes: # pragma no branch
595 self._hireable = self._makeBoolAttribute(attributes["hireable"])
596 if "html_url" in attributes: # pragma no branch
597 self._html_url = self._makeStringAttribute(attributes["html_url"])
598 if "id" in attributes: # pragma no branch
599 self._id = self._makeIntAttribute(attributes["id"])
600 if "location" in attributes: # pragma no branch
601 self._location = self._makeStringAttribute(attributes["location"])
602 if "login" in attributes: # pragma no branch
603 self._login = self._makeStringAttribute(attributes["login"])
604 if "name" in attributes: # pragma no branch
605 self._name = self._makeStringAttribute(attributes["name"])
606 if "organizations_url" in attributes: # pragma no branch
607 self._organizations_url = self._makeStringAttribute(attributes["organizations_url"])
608 if "owned_private_repos" in attributes: # pragma no branch
609 self._owned_private_repos = self._makeIntAttribute(attributes["owned_private_repos"])
610 if "plan" in attributes: # pragma no branch
611 self._plan = self._makeClassAttribute(github.Plan.Plan, attributes["plan"])
612 if "private_gists" in attributes: # pragma no branch
613 self._private_gists = self._makeIntAttribute(attributes["private_gists"])
614 if "public_gists" in attributes: # pragma no branch
615 self._public_gists = self._makeIntAttribute(attributes["public_gists"])
616 if "public_repos" in attributes: # pragma no branch
617 self._public_repos = self._makeIntAttribute(attributes["public_repos"])
618 if "received_events_url" in attributes: # pragma no branch
619 self._received_events_url = self._makeStringAttribute(attributes["received_events_url"])
620 if "repos_url" in attributes: # pragma no branch
621 self._repos_url = self._makeStringAttribute(attributes["repos_url"])
622 if "starred_url" in attributes: # pragma no branch
623 self._starred_url = self._makeStringAttribute(attributes["starred_url"])
624 if "subscriptions_url" in attributes: # pragma no branch
625 self._subscriptions_url = self._makeStringAttribute(attributes["subscriptions_url"])
626 if "total_private_repos" in attributes: # pragma no branch
627 self._total_private_repos = self._makeIntAttribute(attributes["total_private_repos"])
628 if "type" in attributes: # pragma no branch
629 self._type = self._makeStringAttribute(attributes["type"])
630 if "updated_at" in attributes: # pragma no branch
631 self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"])
632 if "url" in attributes: # pragma no branch
633 self._url = self._makeStringAttribute(attributes["url"])