Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/RepositoryKey.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
| author | bcclaywell |
|---|---|
| date | Mon, 12 Oct 2015 17:43:33 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:d67268158946 |
|---|---|
| 1 # -*- coding: utf-8 -*- | |
| 2 | |
| 3 # ########################## Copyrights and license ############################ | |
| 4 # # | |
| 5 # Copyright 2012 Vincent Jacques <vincent@vincent-jacques.net> # | |
| 6 # Copyright 2012 Zearin <zearin@gonk.net> # | |
| 7 # Copyright 2013 AKFish <akfish@gmail.com> # | |
| 8 # Copyright 2013 Srijan Choudhary <srijan4@gmail.com> # | |
| 9 # Copyright 2013 Vincent Jacques <vincent@vincent-jacques.net> # | |
| 10 # Copyright 2013 martinqt <m.ki2@laposte.net> # | |
| 11 # # | |
| 12 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | |
| 13 # # | |
| 14 # PyGithub is free software: you can redistribute it and/or modify it under # | |
| 15 # the terms of the GNU Lesser General Public License as published by the Free # | |
| 16 # Software Foundation, either version 3 of the License, or (at your option) # | |
| 17 # any later version. # | |
| 18 # # | |
| 19 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | |
| 20 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | |
| 21 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | |
| 22 # details. # | |
| 23 # # | |
| 24 # You should have received a copy of the GNU Lesser General Public License # | |
| 25 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | |
| 26 # # | |
| 27 # ############################################################################## | |
| 28 | |
| 29 import github.GithubObject | |
| 30 | |
| 31 | |
| 32 class RepositoryKey(github.GithubObject.CompletableGithubObject): | |
| 33 """ | |
| 34 This class represents RepositoryKeys. The reference can be found here http://developer.github.com/v3/repos/keys/ | |
| 35 """ | |
| 36 | |
| 37 def __init__(self, requester, headers, attributes, completed, repoUrl): | |
| 38 github.GithubObject.CompletableGithubObject.__init__(self, requester, headers, attributes, completed) | |
| 39 self.__repoUrl = repoUrl | |
| 40 | |
| 41 @property | |
| 42 def __customUrl(self): | |
| 43 return self.__repoUrl + "/keys/" + str(self.id) | |
| 44 | |
| 45 @property | |
| 46 def id(self): | |
| 47 """ | |
| 48 :type: integer | |
| 49 """ | |
| 50 self._completeIfNotSet(self._id) | |
| 51 return self._id.value | |
| 52 | |
| 53 @property | |
| 54 def key(self): | |
| 55 """ | |
| 56 :type: string | |
| 57 """ | |
| 58 self._completeIfNotSet(self._key) | |
| 59 return self._key.value | |
| 60 | |
| 61 @property | |
| 62 def title(self): | |
| 63 """ | |
| 64 :type: string | |
| 65 """ | |
| 66 self._completeIfNotSet(self._title) | |
| 67 return self._title.value | |
| 68 | |
| 69 @property | |
| 70 def url(self): | |
| 71 """ | |
| 72 :type: string | |
| 73 """ | |
| 74 self._completeIfNotSet(self._url) | |
| 75 return self._url.value | |
| 76 | |
| 77 @property | |
| 78 def verified(self): | |
| 79 """ | |
| 80 :type: bool | |
| 81 """ | |
| 82 self._completeIfNotSet(self._verified) | |
| 83 return self._verified.value | |
| 84 | |
| 85 def delete(self): | |
| 86 """ | |
| 87 :calls: `DELETE /repos/:owner/:repo/keys/:id <http://developer.github.com/v3/repos/keys>`_ | |
| 88 :rtype: None | |
| 89 """ | |
| 90 headers, data = self._requester.requestJsonAndCheck( | |
| 91 "DELETE", | |
| 92 self.__customUrl | |
| 93 ) | |
| 94 | |
| 95 def edit(self, title=github.GithubObject.NotSet, key=github.GithubObject.NotSet): | |
| 96 """ | |
| 97 :calls: `PATCH /repos/:owner/:repo/keys/:id <http://developer.github.com/v3/repos/keys>`_ | |
| 98 :param title: string | |
| 99 :param key: string | |
| 100 :rtype: None | |
| 101 """ | |
| 102 assert title is github.GithubObject.NotSet or isinstance(title, (str, unicode)), title | |
| 103 assert key is github.GithubObject.NotSet or isinstance(key, (str, unicode)), key | |
| 104 post_parameters = dict() | |
| 105 if title is not github.GithubObject.NotSet: | |
| 106 post_parameters["title"] = title | |
| 107 if key is not github.GithubObject.NotSet: | |
| 108 post_parameters["key"] = key | |
| 109 headers, data = self._requester.requestJsonAndCheck( | |
| 110 "PATCH", | |
| 111 self.__customUrl, | |
| 112 input=post_parameters | |
| 113 ) | |
| 114 self._useAttributes(data) | |
| 115 | |
| 116 def _initAttributes(self): | |
| 117 self._id = github.GithubObject.NotSet | |
| 118 self._key = github.GithubObject.NotSet | |
| 119 self._title = github.GithubObject.NotSet | |
| 120 self._url = github.GithubObject.NotSet | |
| 121 self._verified = github.GithubObject.NotSet | |
| 122 | |
| 123 def _useAttributes(self, attributes): | |
| 124 if "id" in attributes: # pragma no branch | |
| 125 self._id = self._makeIntAttribute(attributes["id"]) | |
| 126 if "key" in attributes: # pragma no branch | |
| 127 self._key = self._makeStringAttribute(attributes["key"]) | |
| 128 if "title" in attributes: # pragma no branch | |
| 129 self._title = self._makeStringAttribute(attributes["title"]) | |
| 130 if "url" in attributes: # pragma no branch | |
| 131 self._url = self._makeStringAttribute(attributes["url"]) | |
| 132 if "verified" in attributes: # pragma no branch | |
| 133 self._verified = self._makeBoolAttribute(attributes["verified"]) |
