Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/Label.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 Vincent Jacques <vincent@vincent-jacques.net> # | |
| 9 # Copyright 2013 martinqt <m.ki2@laposte.net> # | |
| 10 # # | |
| 11 # This file is part of PyGithub. http://jacquev6.github.com/PyGithub/ # | |
| 12 # # | |
| 13 # PyGithub is free software: you can redistribute it and/or modify it under # | |
| 14 # the terms of the GNU Lesser General Public License as published by the Free # | |
| 15 # Software Foundation, either version 3 of the License, or (at your option) # | |
| 16 # any later version. # | |
| 17 # # | |
| 18 # PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY # | |
| 19 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS # | |
| 20 # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more # | |
| 21 # details. # | |
| 22 # # | |
| 23 # You should have received a copy of the GNU Lesser General Public License # | |
| 24 # along with PyGithub. If not, see <http://www.gnu.org/licenses/>. # | |
| 25 # # | |
| 26 # ############################################################################## | |
| 27 | |
| 28 import urllib | |
| 29 | |
| 30 import github.GithubObject | |
| 31 | |
| 32 | |
| 33 class Label(github.GithubObject.CompletableGithubObject): | |
| 34 """ | |
| 35 This class represents Labels. The reference can be found here http://developer.github.com/v3/issues/labels/ | |
| 36 """ | |
| 37 | |
| 38 @property | |
| 39 def color(self): | |
| 40 """ | |
| 41 :type: string | |
| 42 """ | |
| 43 self._completeIfNotSet(self._color) | |
| 44 return self._color.value | |
| 45 | |
| 46 @property | |
| 47 def name(self): | |
| 48 """ | |
| 49 :type: string | |
| 50 """ | |
| 51 self._completeIfNotSet(self._name) | |
| 52 return self._name.value | |
| 53 | |
| 54 @property | |
| 55 def url(self): | |
| 56 """ | |
| 57 :type: string | |
| 58 """ | |
| 59 self._completeIfNotSet(self._url) | |
| 60 return self._url.value | |
| 61 | |
| 62 def delete(self): | |
| 63 """ | |
| 64 :calls: `DELETE /repos/:owner/:repo/labels/:name <http://developer.github.com/v3/issues/labels>`_ | |
| 65 :rtype: None | |
| 66 """ | |
| 67 headers, data = self._requester.requestJsonAndCheck( | |
| 68 "DELETE", | |
| 69 self.url | |
| 70 ) | |
| 71 | |
| 72 def edit(self, name, color): | |
| 73 """ | |
| 74 :calls: `PATCH /repos/:owner/:repo/labels/:name <http://developer.github.com/v3/issues/labels>`_ | |
| 75 :param name: string | |
| 76 :param color: string | |
| 77 :rtype: None | |
| 78 """ | |
| 79 assert isinstance(name, (str, unicode)), name | |
| 80 assert isinstance(color, (str, unicode)), color | |
| 81 post_parameters = { | |
| 82 "name": name, | |
| 83 "color": color, | |
| 84 } | |
| 85 headers, data = self._requester.requestJsonAndCheck( | |
| 86 "PATCH", | |
| 87 self.url, | |
| 88 input=post_parameters | |
| 89 ) | |
| 90 self._useAttributes(data) | |
| 91 | |
| 92 @property | |
| 93 def _identity(self): | |
| 94 return urllib.quote(self.name) | |
| 95 | |
| 96 def _initAttributes(self): | |
| 97 self._color = github.GithubObject.NotSet | |
| 98 self._name = github.GithubObject.NotSet | |
| 99 self._url = github.GithubObject.NotSet | |
| 100 | |
| 101 def _useAttributes(self, attributes): | |
| 102 if "color" in attributes: # pragma no branch | |
| 103 self._color = self._makeStringAttribute(attributes["color"]) | |
| 104 if "name" in attributes: # pragma no branch | |
| 105 self._name = self._makeStringAttribute(attributes["name"]) | |
| 106 if "url" in attributes: # pragma no branch | |
| 107 self._url = self._makeStringAttribute(attributes["url"]) |
