Mercurial > repos > bcclaywell > argo_navis
annotate venv/lib/python2.7/site-packages/github/GithubException.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 2012 Vincent Jacques <vincent@vincent-jacques.net> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 6 # Copyright 2012 Zearin <zearin@gonk.net> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 7 # Copyright 2013 AKFish <akfish@gmail.com> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 8 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 9 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 10 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 11 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 12 # PyGithub is free software: you can redistribute it and/or modify it under # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 13 # the terms of the GNU Lesser General Public License as published by the Free # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 14 # Software Foundation, either version 3 of the License, or (at your option) # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 15 # any later version. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 16 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 17 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 19 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 20 # details. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 21 # # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 22 # You should have received a copy of the GNU Lesser General Public License # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 23 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 24 # # | 
| 
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 class GithubException(Exception): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 29 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 30 Error handling in PyGithub is done with exceptions. This class is the base of all exceptions raised by PyGithub (but :class:`github.GithubException.BadAttributeException`). | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 31 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 32 Some other types of exceptions might be raised by underlying libraries, for example for network-related issues. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 33 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 34 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 35 def __init__(self, status, data): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 36 Exception.__init__(self) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 37 self.__status = status | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 38 self.__data = data | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 39 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 40 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 41 def status(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 42 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 43 The status returned by the Github API | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 44 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 45 return self.__status | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 46 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 47 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 48 def data(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 49 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 50 The (decoded) data returned by the Github API | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 51 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 52 return self.__data | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 53 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 54 def __str__(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 55 return str(self.status) + " " + str(self.data) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 56 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 57 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 58 class BadCredentialsException(GithubException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 59 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 60 Exception raised in case of bad credentials (when Github API replies with a 401 or 403 HTML status) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 61 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 62 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 63 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 64 class UnknownObjectException(GithubException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 65 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 66 Exception raised when a non-existing object is requested (when Github API replies with a 404 HTML status) | 
| 
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 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 70 class BadUserAgentException(GithubException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 71 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 72 Exception raised when request is sent with a bad user agent header (when Github API replies with a 403 bad user agent HTML status) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 73 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 74 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 75 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 76 class RateLimitExceededException(GithubException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 77 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 78 Exception raised when the rate limit is exceeded (when Github API replies with a 403 rate limit exceeded HTML status) | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 79 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 80 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 81 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 82 class BadAttributeException(Exception): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 83 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 84 Exception raised when Github returns an attribute with the wrong type. | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 85 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 86 def __init__(self, actualValue, expectedType, transformationException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 87 self.__actualValue = actualValue | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 88 self.__expectedType = expectedType | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 89 self.__transformationException = transformationException | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 90 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 91 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 92 def actual_value(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 93 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 94 The value returned by Github | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 95 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 96 return self.__actualValue | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 97 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 98 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 99 def expected_type(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 100 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 101 The type PyGithub expected | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 102 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 103 return self.__expectedType | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 104 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 105 @property | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 106 def transformation_exception(self): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 107 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 108 The exception raised when PyGithub tried to parse the value | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 109 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 110 return self.__transformationException | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 111 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 112 | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 113 class TwoFactorException(GithubException): | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 114 """ | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 115 Exception raised when Github requires a onetime password for two-factor authentication | 
| 
d67268158946
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
 bcclaywell parents: diff
changeset | 116 """ | 
