@@ -30,12 +30,6 @@ def __init__(self, login='', password=''):
3030def __repr__ (self ):
3131return '<GitHub at 0x{0:x}>' .format (id (self ))
3232
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-
3933def _iter_follow (self ,which ,number ):
4034url = self ._build_url ('user' ,which )
4135return self ._iter (number ,url ,User )
@@ -233,20 +227,6 @@ def follow(self, login):
233227resp = self ._boolean (self ._put (url ),204 ,404 )
234228return resp
235229
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-
250230def gist (self ,id_num ):
251231"""Gets the gist using the specified id number.
252232
@@ -304,10 +284,6 @@ def is_subscribed(self, login, repo):
304284json = self ._boolean (self ._get (url ),204 ,404 )
305285return json
306286
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-
311287def issue (self ,owner ,repository ,number ):
312288"""Fetch issue #:number: from https://github.com/:owner:/:repository:
313289
@@ -324,16 +300,19 @@ def issue(self, owner, repository, number):
324300return repo .issue (number )
325301return None
326302
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.
331306
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>`
333310 """
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
337316
338317@requires_basic_auth
339318def iter_authorizations (self ,number = - 1 ):
@@ -347,16 +326,6 @@ def iter_authorizations(self, number=-1):
347326url = self ._build_url ('authorizations' )
348327return self ._iter (int (number ),url ,Authorization )
349328
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-
360329@requires_auth
361330def iter_emails (self ,number = - 1 ):
362331"""Iterate over email addresses for the authenticated user.
@@ -368,15 +337,6 @@ def iter_emails(self, number=-1):
368337url = self ._build_url ('user' ,'emails' )
369338return self ._iter (int (number ),url ,str )
370339
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-
380340def iter_events (self ,number = - 1 ):
381341"""Iterate over public events.
382342
@@ -387,19 +347,6 @@ def iter_events(self, number=-1):
387347url = self ._build_url ('events' )
388348return self ._iter (int (number ),url ,Event )
389349
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-
403350def iter_followers (self ,login = None ,number = - 1 ):
404351"""If login is provided, iterate over a list of followers of that
405352 login name; otherwise return a list of followers of the
@@ -415,19 +362,6 @@ def iter_followers(self, login=None, number=-1):
415362return self .user (login ).iter_followers ()
416363return self ._iter_follow ('followers' ,int (number ))
417364
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-
431365def iter_following (self ,login = None ,number = - 1 ):
432366"""If login is provided, iterate over a list of users being followed
433367 by login; otherwise return a list of people followed by the
@@ -443,21 +377,6 @@ def iter_following(self, login=None, number=-1):
443377return self .user (login ).iter_following ()
444378return self ._iter_follow ('followers' ,int (number ))
445379
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-
461380def iter_gists (self ,username = None ,number = - 1 ):
462381"""If no username is specified, GET /gists, otherwise GET
463382 /users/:username/gists
@@ -555,61 +474,6 @@ def iter_user_issues(self, filter='', state='', labels='', sort='',
555474params = issue_params (filter ,state ,labels ,sort ,direction ,since )
556475return self ._iter (int (number ),url ,Issue ,params = params )
557476
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-
613477def iter_repo_issues (self ,owner ,repository ,milestone = None ,
614478state = '' ,assignee = '' ,mentioned = '' ,labels = '' ,sort = '' ,direction = '' ,
615479since = '' ,number = - 1 ):
@@ -642,16 +506,6 @@ def iter_repo_issues(self, owner, repository, milestone=None,
642506labels ,sort ,direction ,since ,number )
643507return self ._iter (0 ,'' ,type )
644508
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-
655509@requires_auth
656510def iter_keys (self ,number = - 1 ):
657511"""Iterate over public keys for the authenticated user.
@@ -663,23 +517,6 @@ def iter_keys(self, number=-1):
663517url = self ._build_url ('user' ,'keys' )
664518return self ._iter (int (number ),url ,Key )
665519
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-
683520def iter_orgs (self ,login = None ,number = - 1 ):
684521"""Iterate over public organizations for login if provided; otherwise
685522 iterate over public and private organizations for the authenticated
@@ -698,45 +535,6 @@ def iter_orgs(self, login=None, number=-1):
698535
699536return self ._iter (int (number ),url ,Organization )
700537
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-
740538def iter_repos (self ,login = None ,type = '' ,sort = '' ,direction = '' ,
741539number = - 1 ):
742540"""List public repositories for the specified ``login`` or all
@@ -779,18 +577,6 @@ def iter_repos(self, login=None, type='', sort='', direction='',
779577
780578return self ._iter (int (number ),url ,Repository ,params = params )
781579
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-
794580def iter_starred (self ,login = None ,number = - 1 ):
795581"""Iterate over repositories starred by ``login`` or the authenticated
796582 user.
@@ -805,19 +591,6 @@ def iter_starred(self, login=None, number=-1):
805591url = self ._build_url ('user' ,'starred' )
806592return self ._iter (int (number ),url ,Repository )
807593
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-
821594def iter_subscribed (self ,login = None ,number = - 1 ):
822595"""Iterate over repositories subscribed to by ``login`` or the
823596 authenticated user.
@@ -832,10 +605,6 @@ def iter_subscribed(self, login=None, number=-1):
832605url = self ._build_url ('user' ,'subscriptions' )
833606return self ._iter (int (number ),url ,Repository )
834607
835- def list_watching (self ,login = None ):
836- """DEPRECATED: Use list_starred() instead."""
837- raise DeprecationWarning ('Use list_starred() instead.' )
838-
839608def login (self ,username = None ,password = None ,token = None ):
840609"""Logs the user into GitHub for protected API calls.
841610