@@ -30,12 +30,6 @@ def __init__(self, login='', password=''):
30
30
def __repr__ (self ):
31
31
return '<GitHub at 0x{0:x}>' .format (id (self ))
32
32
33
- def _list_follow (self ,which ):
34
- url = self ._build_url ('user' ,which )
35
- resp = self ._get (url )
36
- json = self ._json (resp ,200 )
37
- return [User (f ,self )for f in json ]
38
-
39
33
def _iter_follow (self ,which ,number ):
40
34
url = self ._build_url ('user' ,which )
41
35
return self ._iter (number ,url ,User )
@@ -233,20 +227,6 @@ def follow(self, login):
233
227
resp = self ._boolean (self ._put (url ),204 ,404 )
234
228
return resp
235
229
236
- @requires_auth
237
- def key (self ,id_num ):
238
- """Gets the authenticated user's key specified by id_num.
239
-
240
- :param id_num: (required), unique id of the key
241
- :type id_num: int
242
- :returns: :class:`Key <github3.users.Key>`
243
- """
244
- json = None
245
- if int (id_num )> 0 :
246
- url = self ._build_url ('user' ,'keys' ,str (id_num ))
247
- json = self ._json (self ._get (url ),200 )
248
- return Key (json ,self )if json else None
249
-
250
230
def gist (self ,id_num ):
251
231
"""Gets the gist using the specified id number.
252
232
@@ -304,10 +284,6 @@ def is_subscribed(self, login, repo):
304
284
json = self ._boolean (self ._get (url ),204 ,404 )
305
285
return json
306
286
307
- def is_watching (self ,login ,repo ):
308
- """DEPRECATED: Use is_subscribed/is_starred instead."""
309
- raise DeprecationWarning ('Use is_subscribed/is_starred instead.' )
310
-
311
287
def issue (self ,owner ,repository ,number ):
312
288
"""Fetch issue #:number: from https://github.com/:owner:/:repository:
313
289
@@ -324,16 +300,19 @@ def issue(self, owner, repository, number):
324
300
return repo .issue (number )
325
301
return None
326
302
327
- @requires_basic_auth
328
- def list_authorizations (self ):
329
- """List authorizations for the authenticated user. This will return a
330
- 404 if you are using a token for authentication.
303
+ @requires_auth
304
+ def key (self ,id_num ):
305
+ """Gets the authenticated user's key specified by id_num.
331
306
332
- :returns: list of :class:`Authorization <Authorization>`\ s
307
+ :param id_num: (required), unique id of the key
308
+ :type id_num: int
309
+ :returns: :class:`Key <github3.users.Key>`
333
310
"""
334
- url = self ._build_url ('authorizations' )
335
- json = self ._json (self ._get (url ),200 )
336
- return [Authorization (a ,self )for a in json ]
311
+ json = None
312
+ if int (id_num )> 0 :
313
+ url = self ._build_url ('user' ,'keys' ,str (id_num ))
314
+ json = self ._json (self ._get (url ),200 )
315
+ return Key (json ,self )if json else None
337
316
338
317
@requires_basic_auth
339
318
def iter_authorizations (self ,number = - 1 ):
@@ -347,16 +326,6 @@ def iter_authorizations(self, number=-1):
347
326
url = self ._build_url ('authorizations' )
348
327
return self ._iter (int (number ),url ,Authorization )
349
328
350
- @requires_auth
351
- def list_emails (self ):
352
- """List email addresses for the authenticated user.
353
-
354
- :returns: list of dicts
355
- """
356
- url = self ._build_url ('user' ,'emails' )
357
- req = self ._get (url )
358
- return self ._json (req ,200 )or []
359
-
360
329
@requires_auth
361
330
def iter_emails (self ,number = - 1 ):
362
331
"""Iterate over email addresses for the authenticated user.
@@ -368,15 +337,6 @@ def iter_emails(self, number=-1):
368
337
url = self ._build_url ('user' ,'emails' )
369
338
return self ._iter (int (number ),url ,str )
370
339
371
- def list_events (self ):
372
- """List public events.
373
-
374
- :returns: list of :class:`Event <github3.events.Event>`\ s
375
- """
376
- url = self ._build_url ('events' )
377
- json = self ._json (self ._get (url ),200 )
378
- return [Event (ev ,self )for ev in json ]
379
-
380
340
def iter_events (self ,number = - 1 ):
381
341
"""Iterate over public events.
382
342
@@ -387,19 +347,6 @@ def iter_events(self, number=-1):
387
347
url = self ._build_url ('events' )
388
348
return self ._iter (int (number ),url ,Event )
389
349
390
- def list_followers (self ,login = None ):
391
- """If login is provided, return a list of followers of that
392
- login name; otherwise return a list of followers of the
393
- authenticated user.
394
-
395
- :param login: (optional), login of the user to check
396
- :type login: str
397
- :returns: list of :class:`User <github3.users.User>`\ s
398
- """
399
- if login :
400
- return self .user (login ).list_followers ()
401
- return self ._list_follow ('followers' )
402
-
403
350
def iter_followers (self ,login = None ,number = - 1 ):
404
351
"""If login is provided, iterate over a list of followers of that
405
352
login name; otherwise return a list of followers of the
@@ -415,19 +362,6 @@ def iter_followers(self, login=None, number=-1):
415
362
return self .user (login ).iter_followers ()
416
363
return self ._iter_follow ('followers' ,int (number ))
417
364
418
- def list_following (self ,login = None ):
419
- """If login is provided, return a list of users being followed
420
- by login; otherwise return a list of people followed by the
421
- authenticated user.
422
-
423
- :param login: (optional), login of the user to check
424
- :type login: str
425
- :returns: list of :class:`User <github3.users.User>`\ s
426
- """
427
- if login :
428
- return self .user (login ).iter_following ()
429
- return self ._list_follow ('following' )
430
-
431
365
def iter_following (self ,login = None ,number = - 1 ):
432
366
"""If login is provided, iterate over a list of users being followed
433
367
by login; otherwise return a list of people followed by the
@@ -443,21 +377,6 @@ def iter_following(self, login=None, number=-1):
443
377
return self .user (login ).iter_following ()
444
378
return self ._iter_follow ('followers' ,int (number ))
445
379
446
- def list_gists (self ,username = None ):
447
- """If no username is specified, GET /gists, otherwise GET
448
- /users/:username/gists
449
-
450
- :param login: (optional), login of the user to check
451
- :type login: str
452
- :returns: list of :class:`Gist <github3.gists.Gist>`\ s
453
- """
454
- if username :
455
- url = self ._build_url ('users' ,username ,'gists' )
456
- else :
457
- url = self ._build_url ('gists' )
458
- json = self ._json (self ._get (url ),200 )
459
- return [Gist (gist ,self )for gist in json ]
460
-
461
380
def iter_gists (self ,username = None ,number = - 1 ):
462
381
"""If no username is specified, GET /gists, otherwise GET
463
382
/users/:username/gists
@@ -555,61 +474,6 @@ def iter_user_issues(self, filter='', state='', labels='', sort='',
555
474
params = issue_params (filter ,state ,labels ,sort ,direction ,since )
556
475
return self ._iter (int (number ),url ,Issue ,params = params )
557
476
558
- @requires_auth
559
- def list_issues (self ,filter = '' ,state = '' ,labels = '' ,sort = '' ,
560
- direction = '' ,since = '' ):
561
- """List the authenticated user's issues.
562
-
563
- :param str filter: accepted values:
564
- ('assigned', 'created', 'mentioned', 'subscribed')
565
- api-default: 'assigned'
566
- :param str state: accepted values: ('open', 'closed')
567
- api-default: 'open'
568
- :param str labels: comma-separated list of label names, e.g.,
569
- 'bug,ui,@high'
570
- :param str sort: accepted values: ('created', 'updated', 'comments')
571
- api-default: created
572
- :param str direction: accepted values: ('asc', 'desc')
573
- api-default: desc
574
- :param str since: ISO 8601 formatted timestamp, e.g.,
575
- 2012-05-20T23:10:27Z
576
- """
577
- url = self ._build_url ('issues' )
578
- params = issue_params (filter ,state ,labels ,sort ,direction ,
579
- since )
580
- json = self ._json (self ._get (url ,params = params ),200 )
581
- return [Issue (issue ,self )for issue in json ]
582
-
583
- def list_repo_issues (self ,owner ,repository ,milestone = None ,
584
- state = '' ,assignee = '' ,mentioned = '' ,labels = '' ,sort = '' ,direction = '' ,
585
- since = '' ):
586
- """List issues on owner/repository. Only owner and repository are
587
- required.
588
-
589
- :param str owner: login of the owner of the repository
590
- :param str repository: name of the repository
591
- :param int milestone: None, '*', or ID of milestone
592
- :param str state: accepted values: ('open', 'closed')
593
- api-default: 'open'
594
- :param str assignee: '*' or login of the user
595
- :param str mentioned: login of the user
596
- :param str labels: comma-separated list of label names, e.g.,
597
- 'bug,ui,@high'
598
- :param str sort: accepted values: ('created', 'updated', 'comments')
599
- api-default: created
600
- :param str direction: accepted values: ('asc', 'desc')
601
- api-default: desc
602
- :param str since: ISO 8601 formatted timestamp, e.g.,
603
- 2012-05-20T23:10:27Z
604
- :returns: list of :class:`Issue <github3.issues.Issue>`\ s
605
- """
606
- issues = []
607
- if owner and repository :
608
- repo = self .repository (owner ,repository )
609
- issues = repo .list_issues (milestone ,state ,assignee ,mentioned ,
610
- labels ,sort ,direction ,since )
611
- return issues
612
-
613
477
def iter_repo_issues (self ,owner ,repository ,milestone = None ,
614
478
state = '' ,assignee = '' ,mentioned = '' ,labels = '' ,sort = '' ,direction = '' ,
615
479
since = '' ,number = - 1 ):
@@ -642,16 +506,6 @@ def iter_repo_issues(self, owner, repository, milestone=None,
642
506
labels ,sort ,direction ,since ,number )
643
507
return self ._iter (0 ,'' ,type )
644
508
645
- @requires_auth
646
- def list_keys (self ):
647
- """List public keys for the authenticated user.
648
-
649
- :returns: list of :class:`Key <github3.users.Key>`\ s
650
- """
651
- url = self ._build_url ('user' ,'keys' )
652
- json = self ._json (self ._get (url ),200 )
653
- return [Key (key ,self )for key in json ]
654
-
655
509
@requires_auth
656
510
def iter_keys (self ,number = - 1 ):
657
511
"""Iterate over public keys for the authenticated user.
@@ -663,23 +517,6 @@ def iter_keys(self, number=-1):
663
517
url = self ._build_url ('user' ,'keys' )
664
518
return self ._iter (int (number ),url ,Key )
665
519
666
- def list_orgs (self ,login = None ):
667
- """List public organizations for login if provided; otherwise
668
- list public and private organizations for the authenticated
669
- user.
670
-
671
- :param login: (optional), user whose orgs you wish to list
672
- :type login: str
673
- :returns: list of :class:`Organization <github3.orgs.Organization>`\ s
674
- """
675
- if login :
676
- url = self ._build_url ('users' ,login ,'orgs' )
677
- else :
678
- url = self ._build_url ('user' ,'orgs' )
679
-
680
- json = self ._json (self ._get (url ),200 )
681
- return [Organization (org ,self )for org in json ]
682
-
683
520
def iter_orgs (self ,login = None ,number = - 1 ):
684
521
"""Iterate over public organizations for login if provided; otherwise
685
522
iterate over public and private organizations for the authenticated
@@ -698,45 +535,6 @@ def iter_orgs(self, login=None, number=-1):
698
535
699
536
return self ._iter (int (number ),url ,Organization )
700
537
701
- def list_repos (self ,login = None ,type = '' ,sort = '' ,direction = '' ):
702
- """List public repositories for the specified ``login`` or all
703
- repositories for the authenticated user if ``login`` is not
704
- provided.
705
-
706
- :param login: (optional)
707
- :type login: str
708
- :param type: (optional), accepted values:
709
- ('all', 'owner', 'public', 'private', 'member')
710
- API default: 'all'
711
- :type type: str
712
- :param sort: (optional), accepted values:
713
- ('created', 'updated', 'pushed', 'full_name')
714
- API default: 'created'
715
- :type sort: str
716
- :param direction: (optional), accepted values:
717
- ('asc', 'desc'), API default: 'asc' when using 'full_name',
718
- 'desc' otherwise
719
- :type direction: str
720
- :returns: list of :class:`Repository <github3.repos.Repository>`
721
- objects
722
- """
723
- if login :
724
- url = self ._build_url ('users' ,login ,'repos' )
725
- else :
726
- url = self ._build_url ('user' ,'repos' )
727
-
728
- params = {}
729
- if type in ('all' ,'owner' ,'public' ,'private' ,'member' ):
730
- params .update (type = type )
731
- if not login :
732
- if sort in ('created' ,'updated' ,'pushed' ,'full_name' ):
733
- params .update (sort = sort )
734
- if direction in ('asc' ,'desc' ):
735
- params .update (direction = direction )
736
-
737
- json = self ._json (self ._get (url ,params = params ),200 )
738
- return [Repository (repo ,self )for repo in json ]
739
-
740
538
def iter_repos (self ,login = None ,type = '' ,sort = '' ,direction = '' ,
741
539
number = - 1 ):
742
540
"""List public repositories for the specified ``login`` or all
@@ -779,18 +577,6 @@ def iter_repos(self, login=None, type='', sort='', direction='',
779
577
780
578
return self ._iter (int (number ),url ,Repository ,params = params )
781
579
782
- def list_starred (self ,login = None ):
783
- """List repositories starred by ``login`` or the authenticated user.
784
-
785
- :returns: list of :class:`Repository <github3.repos.Repository>`
786
- """
787
- if login :
788
- return self .user (login ).list_starred ()
789
-
790
- url = self ._build_url ('user' ,'starred' )
791
- json = self ._json (self ._get (url ),200 )
792
- return [Repository (r ,self )for r in json ]
793
-
794
580
def iter_starred (self ,login = None ,number = - 1 ):
795
581
"""Iterate over repositories starred by ``login`` or the authenticated
796
582
user.
@@ -805,19 +591,6 @@ def iter_starred(self, login=None, number=-1):
805
591
url = self ._build_url ('user' ,'starred' )
806
592
return self ._iter (int (number ),url ,Repository )
807
593
808
- def list_subscribed (self ,login = None ):
809
- """List repositories subscribed to by ``login`` or the authenticated
810
- user.
811
-
812
- :returns: list of :class:`Repository <github3.repos.Repository>`
813
- """
814
- if login :
815
- return self .user (login ).list_subscriptions ()
816
-
817
- url = self ._build_url ('user' ,'subscriptions' )
818
- json = self ._json (self ._get (url ),200 )
819
- return [Repository (r ,self )for r in json ]
820
-
821
594
def iter_subscribed (self ,login = None ,number = - 1 ):
822
595
"""Iterate over repositories subscribed to by ``login`` or the
823
596
authenticated user.
@@ -832,10 +605,6 @@ def iter_subscribed(self, login=None, number=-1):
832
605
url = self ._build_url ('user' ,'subscriptions' )
833
606
return self ._iter (int (number ),url ,Repository )
834
607
835
- def list_watching (self ,login = None ):
836
- """DEPRECATED: Use list_starred() instead."""
837
- raise DeprecationWarning ('Use list_starred() instead.' )
838
-
839
608
def login (self ,username = None ,password = None ,token = None ):
840
609
"""Logs the user into GitHub for protected API calls.
841
610