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