Mercurial > repos > bcclaywell > argo_navis
annotate venv/lib/python2.7/site-packages/github/MainClass.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell | 
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 1 # -*- coding: utf-8 -*- | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 2 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 3 # ########################## Copyrights and license ############################ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 4 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 5 # Copyright 2013 AKFish <akfish@gmail.com> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 6 # Copyright 2013 Ed Jackson <ed.jackson@gmail.com> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 7 # Copyright 2013 Jonathan J Hunt <hunt@braincorporation.com> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 8 # Copyright 2013 Peter Golm <golm.peter@gmail.com> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 9 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 10 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 11 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 12 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 13 # PyGithub is free software: you can redistribute it and/or modify it under # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 14 # the terms of the GNU Lesser General Public License as published by the Free # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 15 # Software Foundation, either version 3 of the License, or (at your option) # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 16 # any later version. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 17 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 18 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 20 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 21 # details. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 22 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 23 # You should have received a copy of the GNU Lesser General Public License # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 24 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 25 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 26 # ############################################################################## | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 27 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 28 import urllib | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 29 import pickle | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 30 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 31 from Requester import Requester | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 32 import AuthenticatedUser | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 33 import NamedUser | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 34 import Organization | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 35 import Gist | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 36 import github.PaginatedList | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 37 import Repository | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 38 import Legacy | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 39 import github.GithubObject | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 40 import HookDescription | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 41 import GitignoreTemplate | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 42 import Status | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 43 import StatusMessage | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 44 import RateLimit | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 45 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 46 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 47 DEFAULT_BASE_URL = "https://api.github.com" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 48 DEFAULT_TIMEOUT = 10 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 49 DEFAULT_PER_PAGE = 30 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 50 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 51 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 52 class Github(object): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 53 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 54 This is the main class you instanciate to access the Github API v3. Optional parameters allow different authentication methods. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 55 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 56 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 57 def __init__(self, login_or_token=None, password=None, base_url=DEFAULT_BASE_URL, timeout=DEFAULT_TIMEOUT, client_id=None, client_secret=None, user_agent='PyGithub/Python', per_page=DEFAULT_PER_PAGE): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 58 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 59 :param login_or_token: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 60 :param password: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 61 :param base_url: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 62 :param timeout: integer | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 63 :param client_id: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 64 :param client_secret: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 65 :param user_agent: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 66 :param per_page: int | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 67 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 68 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 69 assert login_or_token is None or isinstance(login_or_token, (str, unicode)), login_or_token | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 70 assert password is None or isinstance(password, (str, unicode)), password | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 71 assert isinstance(base_url, (str, unicode)), base_url | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 72 assert isinstance(timeout, (int, long)), timeout | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 73 assert client_id is None or isinstance(client_id, (str, unicode)), client_id | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 74 assert client_secret is None or isinstance(client_secret, (str, unicode)), client_secret | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 75 assert user_agent is None or isinstance(user_agent, (str, unicode)), user_agent | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 76 self.__requester = Requester(login_or_token, password, base_url, timeout, client_id, client_secret, user_agent, per_page) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 77 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 78 def __get_FIX_REPO_GET_GIT_REF(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 79 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 80 :type: bool | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 81 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 82 return self.__requester.FIX_REPO_GET_GIT_REF | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 83 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 84 def __set_FIX_REPO_GET_GIT_REF(self, value): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 85 self.__requester.FIX_REPO_GET_GIT_REF = value | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 86 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 87 FIX_REPO_GET_GIT_REF = property(__get_FIX_REPO_GET_GIT_REF, __set_FIX_REPO_GET_GIT_REF) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 88 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 89 def __get_per_page(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 90 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 91 :type: int | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 92 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 93 return self.__requester.per_page | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 94 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 95 def __set_per_page(self, value): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 96 self.__requester.per_page = value | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 97 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 98 # v2: Remove this property? Why should it be necessary to read/modify it after construction | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 99 per_page = property(__get_per_page, __set_per_page) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 100 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 101 # v2: Provide a unified way to access values of headers of last response | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 102 # v2: (and add/keep ad hoc properties for specific useful headers like rate limiting, oauth scopes, etc.) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 103 # v2: Return an instance of a class: using a tuple did not allow to add a field "resettime" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 104 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 105 def rate_limiting(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 106 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 107 First value is requests remaining, second value is request limit. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 108 :type: (int, int) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 109 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 110 remaining, limit = self.__requester.rate_limiting | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 111 if limit < 0: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 112 self.get_rate_limit() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 113 return self.__requester.rate_limiting | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 114 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 115 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 116 def rate_limiting_resettime(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 117 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 118 Unix timestamp indicating when rate limiting will reset. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 119 :type: int | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 120 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 121 if self.__requester.rate_limiting_resettime == 0: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 122 self.get_rate_limit() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 123 return self.__requester.rate_limiting_resettime | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 124 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 125 def get_rate_limit(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 126 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 127 Don't forget you can access the rate limit returned in headers of last Github API v3 response, by :attr:`github.MainClass.Github.rate_limiting` and :attr:`github.MainClass.Github.rate_limiting_resettime`. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 128 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 129 :calls: `GET /rate_limit <http://developer.github.com/v3/rate_limit>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 130 :rtype: :class:`github.RateLimit.RateLimit` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 131 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 132 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 133 'GET', | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 134 '/rate_limit' | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 135 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 136 return RateLimit.RateLimit(self.__requester, headers, attributes, True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 137 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 138 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 139 def oauth_scopes(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 140 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 141 :type: list of string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 142 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 143 return self.__requester.oauth_scopes | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 144 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 145 def get_user(self, login=github.GithubObject.NotSet): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 146 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 147 :calls: `GET /users/:user <http://developer.github.com/v3/users>`_ or `GET /user <http://developer.github.com/v3/users>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 148 :param login: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 149 :rtype: :class:`github.NamedUser.NamedUser` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 150 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 151 assert login is github.GithubObject.NotSet or isinstance(login, (str, unicode)), login | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 152 if login is github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 153 return AuthenticatedUser.AuthenticatedUser(self.__requester, {}, {"url": "/user"}, completed=False) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 154 else: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 155 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 156 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 157 "/users/" + login | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 158 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 159 return github.NamedUser.NamedUser(self.__requester, headers, data, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 160 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 161 def get_users(self, since=github.GithubObject.NotSet): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 162 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 163 :calls: `GET /users <http://developer.github.com/v3/users>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 164 :param since: integer | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 165 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 166 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 167 assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 168 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 169 if since is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 170 url_parameters["since"] = since | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 171 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 172 github.NamedUser.NamedUser, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 173 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 174 "/users", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 175 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 176 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 177 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 178 def get_organization(self, login): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 179 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 180 :calls: `GET /orgs/:org <http://developer.github.com/v3/orgs>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 181 :param login: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 182 :rtype: :class:`github.Organization.Organization` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 183 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 184 assert isinstance(login, (str, unicode)), login | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 185 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 186 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 187 "/orgs/" + login | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 188 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 189 return github.Organization.Organization(self.__requester, headers, data, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 190 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 191 def get_repo(self, full_name_or_id): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 192 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 193 :calls: `GET /repos/:owner/:repo <http://developer.github.com/v3/repos>`_ or `GET /repositories/:id <http://developer.github.com/v3/repos>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 194 :rtype: :class:`github.Repository.Repository` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 195 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 196 assert isinstance(full_name_or_id, (str, unicode, int)), full_name_or_id | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 197 url_base = "/repositories/" if isinstance(full_name_or_id, int) else "/repos/" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 198 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 199 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 200 "%s%s" % (url_base, full_name_or_id) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 201 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 202 return Repository.Repository(self.__requester, headers, data, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 203 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 204 def get_repos(self, since=github.GithubObject.NotSet): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 205 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 206 :calls: `GET /repositories <http://developer.github.com/v3/repos/#list-all-public-repositories>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 207 :param since: integer | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 208 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 209 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 210 assert since is github.GithubObject.NotSet or isinstance(since, (int, long)), since | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 211 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 212 if since is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 213 url_parameters["since"] = since | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 214 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 215 github.Repository.Repository, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 216 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 217 "/repositories", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 218 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 219 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 220 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 221 def get_gist(self, id): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 222 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 223 :calls: `GET /gists/:id <http://developer.github.com/v3/gists>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 224 :param id: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 225 :rtype: :class:`github.Gist.Gist` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 226 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 227 assert isinstance(id, (str, unicode)), id | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 228 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 229 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 230 "/gists/" + id | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 231 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 232 return github.Gist.Gist(self.__requester, headers, data, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 233 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 234 def get_gists(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 235 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 236 :calls: `GET /gists/public <http://developer.github.com/v3/gists>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 237 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Gist.Gist` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 238 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 239 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 240 github.Gist.Gist, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 241 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 242 "/gists/public", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 243 None | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 244 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 245 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 246 def legacy_search_repos(self, keyword, language=github.GithubObject.NotSet): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 247 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 248 :calls: `GET /legacy/repos/search/:keyword <http://developer.github.com/v3/search/legacy>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 249 :param keyword: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 250 :param language: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 251 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 252 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 253 assert isinstance(keyword, (str, unicode)), keyword | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 254 assert language is github.GithubObject.NotSet or isinstance(language, (str, unicode)), language | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 255 args = {} if language is github.GithubObject.NotSet else {"language": language} | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 256 return Legacy.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 257 "/legacy/repos/search/" + urllib.quote_plus(keyword, safe='/%:><'), | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 258 args, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 259 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 260 "repositories", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 261 Legacy.convertRepo, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 262 github.Repository.Repository, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 263 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 264 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 265 def legacy_search_users(self, keyword): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 266 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 267 :calls: `GET /legacy/user/search/:keyword <http://developer.github.com/v3/search/legacy>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 268 :param keyword: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 269 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 270 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 271 assert isinstance(keyword, (str, unicode)), keyword | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 272 return Legacy.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 273 "/legacy/user/search/" + urllib.quote_plus(keyword, safe='/%:><'), | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 274 {}, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 275 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 276 "users", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 277 Legacy.convertUser, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 278 github.NamedUser.NamedUser, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 279 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 280 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 281 def legacy_search_user_by_email(self, email): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 282 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 283 :calls: `GET /legacy/user/email/:email <http://developer.github.com/v3/search/legacy>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 284 :param email: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 285 :rtype: :class:`github.NamedUser.NamedUser` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 286 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 287 assert isinstance(email, (str, unicode)), email | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 288 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 289 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 290 "/legacy/user/email/" + email | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 291 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 292 return github.NamedUser.NamedUser(self.__requester, headers, Legacy.convertUser(data["user"]), completed=False) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 293 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 294 def search_repositories(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 295 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 296 :calls: `GET /search/repositories <http://developer.github.com/v3/search>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 297 :param query: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 298 :param sort: string ('stars', 'forks', 'updated') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 299 :param order: string ('asc', 'desc') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 300 :param qualifiers: keyword dict query qualifiers | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 301 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Repository.Repository` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 302 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 303 assert isinstance(query, (str, unicode)), query | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 304 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 305 if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 306 assert sort in ('stars', 'forks', 'updated'), sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 307 url_parameters["sort"] = sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 308 if order is not github.GithubObject.NotSet: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 309 assert order in ('asc', 'desc'), order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 310 url_parameters["order"] = order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 311 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 312 query_chunks = [] | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 313 if query: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 314 query_chunks.append(query) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 315 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 316 for qualifier, value in qualifiers.items(): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 317 query_chunks.append("%s:%s" % (qualifier, value)) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 318 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 319 url_parameters["q"] = ' '.join(query_chunks) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 320 assert url_parameters["q"], "need at least one qualifier" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 321 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 322 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 323 github.Repository.Repository, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 324 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 325 "/search/repositories", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 326 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 327 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 328 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 329 def search_users(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 330 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 331 :calls: `GET /search/users <http://developer.github.com/v3/search>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 332 :param query: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 333 :param sort: string ('followers', 'repositories', 'joined') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 334 :param order: string ('asc', 'desc') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 335 :param qualifiers: keyword dict query qualifiers | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 336 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.NamedUser.NamedUser` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 337 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 338 assert isinstance(query, (str, unicode)), query | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 339 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 340 if sort is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 341 assert sort in ('followers', 'repositories', 'joined'), sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 342 url_parameters["sort"] = sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 343 if order is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 344 assert order in ('asc', 'desc'), order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 345 url_parameters["order"] = order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 346 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 347 query_chunks = [] | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 348 if query: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 349 query_chunks.append(query) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 350 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 351 for qualifier, value in qualifiers.items(): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 352 query_chunks.append("%s:%s" % (qualifier, value)) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 353 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 354 url_parameters["q"] = ' '.join(query_chunks) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 355 assert url_parameters["q"], "need at least one qualifier" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 356 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 357 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 358 github.NamedUser.NamedUser, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 359 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 360 "/search/users", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 361 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 362 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 363 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 364 def search_issues(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 365 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 366 :calls: `GET /search/issues <http://developer.github.com/v3/search>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 367 :param query: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 368 :param sort: string ('comments', 'created', 'updated') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 369 :param order: string ('asc', 'desc') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 370 :param qualifiers: keyword dict query qualifiers | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 371 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Issue.Issue` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 372 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 373 assert isinstance(query, (str, unicode)), query | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 374 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 375 if sort is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 376 assert sort in ('comments', 'created', 'updated'), sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 377 url_parameters["sort"] = sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 378 if order is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 379 assert order in ('asc', 'desc'), order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 380 url_parameters["order"] = order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 381 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 382 query_chunks = [] | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 383 if query: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 384 query_chunks.append(query) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 385 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 386 for qualifier, value in qualifiers.items(): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 387 query_chunks.append("%s:%s" % (qualifier, value)) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 388 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 389 url_parameters["q"] = ' '.join(query_chunks) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 390 assert url_parameters["q"], "need at least one qualifier" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 391 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 392 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 393 github.Issue.Issue, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 394 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 395 "/search/issues", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 396 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 397 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 398 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 399 def search_code(self, query, sort=github.GithubObject.NotSet, order=github.GithubObject.NotSet, **qualifiers): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 400 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 401 :calls: `GET /search/code <http://developer.github.com/v3/search>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 402 :param query: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 403 :param sort: string ('indexed') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 404 :param order: string ('asc', 'desc') | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 405 :param qualifiers: keyword dict query qualifiers | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 406 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.ContentFile.ContentFile` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 407 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 408 assert isinstance(query, (str, unicode)), query | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 409 url_parameters = dict() | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 410 if sort is not github.GithubObject.NotSet: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 411 assert sort in ('indexed',), sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 412 url_parameters["sort"] = sort | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 413 if order is not github.GithubObject.NotSet: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 414 assert order in ('asc', 'desc'), order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 415 url_parameters["order"] = order | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 416 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 417 query_chunks = [] | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 418 if query: # pragma no branch (Should be covered) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 419 query_chunks.append(query) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 420 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 421 for qualifier, value in qualifiers.items(): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 422 query_chunks.append("%s:%s" % (qualifier, value)) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 423 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 424 url_parameters["q"] = ' '.join(query_chunks) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 425 assert url_parameters["q"], "need at least one qualifier" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 426 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 427 return github.PaginatedList.PaginatedList( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 428 github.ContentFile.ContentFile, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 429 self.__requester, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 430 "/search/code", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 431 url_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 432 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 433 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 434 def render_markdown(self, text, context=github.GithubObject.NotSet): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 435 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 436 :calls: `POST /markdown <http://developer.github.com/v3/markdown>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 437 :param text: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 438 :param context: :class:`github.Repository.Repository` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 439 :rtype: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 440 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 441 assert isinstance(text, (str, unicode)), text | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 442 assert context is github.GithubObject.NotSet or isinstance(context, github.Repository.Repository), context | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 443 post_parameters = { | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 444 "text": text | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 445 } | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 446 if context is not github.GithubObject.NotSet: | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 447 post_parameters["mode"] = "gfm" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 448 post_parameters["context"] = context._identity | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 449 status, headers, data = self.__requester.requestJson( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 450 "POST", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 451 "/markdown", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 452 input=post_parameters | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 453 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 454 return data | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 455 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 456 def get_hook(self, name): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 457 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 458 :calls: `GET /hooks/:name <http://developer.github.com/v3/repos/hooks/>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 459 :param name: string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 460 :rtype: :class:`github.HookDescription.HookDescription` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 461 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 462 assert isinstance(name, (str, unicode)), name | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 463 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 464 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 465 "/hooks/" + name | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 466 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 467 return HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 468 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 469 def get_hooks(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 470 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 471 :calls: `GET /hooks <http://developer.github.com/v3/repos/hooks/>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 472 :rtype: list of :class:`github.HookDescription.HookDescription` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 473 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 474 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 475 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 476 "/hooks" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 477 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 478 return [HookDescription.HookDescription(self.__requester, headers, attributes, completed=True) for attributes in data] | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 479 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 480 def get_gitignore_templates(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 481 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 482 :calls: `GET /gitignore/templates <http://developer.github.com/v3/gitignore>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 483 :rtype: list of string | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 484 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 485 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 486 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 487 "/gitignore/templates" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 488 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 489 return data | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 490 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 491 def get_gitignore_template(self, name): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 492 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 493 :calls: `GET /gitignore/templates/:name <http://developer.github.com/v3/gitignore>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 494 :rtype: :class:`github.GitignoreTemplate.GitignoreTemplate` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 495 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 496 assert isinstance(name, (str, unicode)), name | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 497 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 498 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 499 "/gitignore/templates/" + name | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 500 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 501 return GitignoreTemplate.GitignoreTemplate(self.__requester, headers, attributes, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 502 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 503 def get_emojis(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 504 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 505 :calls: `GET /emojis <http://developer.github.com/v3/emojis/>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 506 :rtype: dictionary of type => url for emoji` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 507 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 508 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 509 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 510 "/emojis" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 511 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 512 return attributes | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 513 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 514 def create_from_raw_data(self, klass, raw_data, headers={}): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 515 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 516 Creates an object from raw_data previously obtained by :attr:`github.GithubObject.GithubObject.raw_data`, | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 517 and optionaly headers previously obtained by :attr:`github.GithubObject.GithubObject.raw_headers`. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 518 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 519 :param klass: the class of the object to create | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 520 :param raw_data: dict | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 521 :param headers: dict | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 522 :rtype: instance of class ``klass`` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 523 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 524 return klass(self.__requester, headers, raw_data, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 525 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 526 def dump(self, obj, file, protocol=0): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 527 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 528 Dumps (pickles) a PyGithub object to a file-like object. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 529 Some effort is made to not pickle sensitive informations like the Github credentials used in the :class:`Github` instance. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 530 But NO EFFORT is made to remove sensitive information from the object's attributes. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 531 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 532 :param obj: the object to pickle | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 533 :param file: the file-like object to pickle to | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 534 :param protocol: the `pickling protocol <http://docs.python.org/2.7/library/pickle.html#data-stream-format>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 535 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 536 pickle.dump((obj.__class__, obj.raw_data, obj.raw_headers), file, protocol) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 537 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 538 def load(self, f): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 539 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 540 Loads (unpickles) a PyGithub object from a file-like object. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 541 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 542 :param f: the file-like object to unpickle from | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 543 :return: the unpickled object | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 544 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 545 return self.create_from_raw_data(*pickle.load(f)) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 546 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 547 def get_api_status(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 548 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 549 This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 550 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 551 :calls: `GET /api/status.json <https://status.github.com/api>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 552 :rtype: :class:`github.Status.Status` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 553 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 554 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 555 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 556 "/api/status.json", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 557 cnx="status" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 558 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 559 return Status.Status(self.__requester, headers, attributes, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 560 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 561 def get_last_api_status_message(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 562 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 563 This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 564 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 565 :calls: `GET /api/last-message.json <https://status.github.com/api>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 566 :rtype: :class:`github.StatusMessage.StatusMessage` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 567 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 568 headers, attributes = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 569 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 570 "/api/last-message.json", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 571 cnx="status" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 572 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 573 return StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 574 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 575 def get_api_status_messages(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 576 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 577 This doesn't work with a Github Enterprise installation, because it always targets https://status.github.com. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 578 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 579 :calls: `GET /api/messages.json <https://status.github.com/api>`_ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 580 :rtype: list of :class:`github.StatusMessage.StatusMessage` | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 581 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 582 headers, data = self.__requester.requestJsonAndCheck( | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 583 "GET", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 584 "/api/messages.json", | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 585 cnx="status" | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 586 ) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 587 return [StatusMessage.StatusMessage(self.__requester, headers, attributes, completed=True) for attributes in data] | 
