Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/github/Milestone.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 datetime | |
29 | |
30 import github.GithubObject | |
31 import github.PaginatedList | |
32 | |
33 import github.NamedUser | |
34 import github.Label | |
35 | |
36 | |
37 class Milestone(github.GithubObject.CompletableGithubObject): | |
38 """ | |
39 This class represents Milestones. The reference can be found here http://developer.github.com/v3/issues/milestones/ | |
40 """ | |
41 | |
42 @property | |
43 def closed_issues(self): | |
44 """ | |
45 :type: integer | |
46 """ | |
47 self._completeIfNotSet(self._closed_issues) | |
48 return self._closed_issues.value | |
49 | |
50 @property | |
51 def created_at(self): | |
52 """ | |
53 :type: datetime.datetime | |
54 """ | |
55 self._completeIfNotSet(self._created_at) | |
56 return self._created_at.value | |
57 | |
58 @property | |
59 def creator(self): | |
60 """ | |
61 :type: :class:`github.NamedUser.NamedUser` | |
62 """ | |
63 self._completeIfNotSet(self._creator) | |
64 return self._creator.value | |
65 | |
66 @property | |
67 def description(self): | |
68 """ | |
69 :type: string | |
70 """ | |
71 self._completeIfNotSet(self._description) | |
72 return self._description.value | |
73 | |
74 @property | |
75 def due_on(self): | |
76 """ | |
77 :type: datetime.datetime | |
78 """ | |
79 self._completeIfNotSet(self._due_on) | |
80 return self._due_on.value | |
81 | |
82 @property | |
83 def id(self): | |
84 """ | |
85 :type: integer | |
86 """ | |
87 self._completeIfNotSet(self._id) | |
88 return self._id.value | |
89 | |
90 @property | |
91 def labels_url(self): | |
92 """ | |
93 :type: string | |
94 """ | |
95 self._completeIfNotSet(self._labels_url) | |
96 return self._labels_url.value | |
97 | |
98 @property | |
99 def number(self): | |
100 """ | |
101 :type: integer | |
102 """ | |
103 self._completeIfNotSet(self._number) | |
104 return self._number.value | |
105 | |
106 @property | |
107 def open_issues(self): | |
108 """ | |
109 :type: integer | |
110 """ | |
111 self._completeIfNotSet(self._open_issues) | |
112 return self._open_issues.value | |
113 | |
114 @property | |
115 def state(self): | |
116 """ | |
117 :type: string | |
118 """ | |
119 self._completeIfNotSet(self._state) | |
120 return self._state.value | |
121 | |
122 @property | |
123 def title(self): | |
124 """ | |
125 :type: string | |
126 """ | |
127 self._completeIfNotSet(self._title) | |
128 return self._title.value | |
129 | |
130 @property | |
131 def updated_at(self): | |
132 """ | |
133 :type: datetime.datetime | |
134 """ | |
135 self._completeIfNotSet(self._updated_at) | |
136 return self._updated_at.value | |
137 | |
138 @property | |
139 def url(self): | |
140 """ | |
141 :type: string | |
142 """ | |
143 self._completeIfNotSet(self._url) | |
144 return self._url.value | |
145 | |
146 def delete(self): | |
147 """ | |
148 :calls: `DELETE /repos/:owner/:repo/milestones/:number <http://developer.github.com/v3/issues/milestones>`_ | |
149 :rtype: None | |
150 """ | |
151 headers, data = self._requester.requestJsonAndCheck( | |
152 "DELETE", | |
153 self.url | |
154 ) | |
155 | |
156 def edit(self, title, state=github.GithubObject.NotSet, description=github.GithubObject.NotSet, due_on=github.GithubObject.NotSet): | |
157 """ | |
158 :calls: `PATCH /repos/:owner/:repo/milestones/:number <http://developer.github.com/v3/issues/milestones>`_ | |
159 :param title: string | |
160 :param state: string | |
161 :param description: string | |
162 :param due_on: date | |
163 :rtype: None | |
164 """ | |
165 assert isinstance(title, (str, unicode)), title | |
166 assert state is github.GithubObject.NotSet or isinstance(state, (str, unicode)), state | |
167 assert description is github.GithubObject.NotSet or isinstance(description, (str, unicode)), description | |
168 assert due_on is github.GithubObject.NotSet or isinstance(due_on, datetime.date), due_on | |
169 post_parameters = { | |
170 "title": title, | |
171 } | |
172 if state is not github.GithubObject.NotSet: | |
173 post_parameters["state"] = state | |
174 if description is not github.GithubObject.NotSet: | |
175 post_parameters["description"] = description | |
176 if due_on is not github.GithubObject.NotSet: | |
177 post_parameters["due_on"] = due_on.strftime("%Y-%m-%d") | |
178 headers, data = self._requester.requestJsonAndCheck( | |
179 "PATCH", | |
180 self.url, | |
181 input=post_parameters | |
182 ) | |
183 self._useAttributes(data) | |
184 | |
185 def get_labels(self): | |
186 """ | |
187 :calls: `GET /repos/:owner/:repo/milestones/:number/labels <http://developer.github.com/v3/issues/labels>`_ | |
188 :rtype: :class:`github.PaginatedList.PaginatedList` of :class:`github.Label.Label` | |
189 """ | |
190 return github.PaginatedList.PaginatedList( | |
191 github.Label.Label, | |
192 self._requester, | |
193 self.url + "/labels", | |
194 None | |
195 ) | |
196 | |
197 @property | |
198 def _identity(self): | |
199 return self.number | |
200 | |
201 def _initAttributes(self): | |
202 self._closed_issues = github.GithubObject.NotSet | |
203 self._created_at = github.GithubObject.NotSet | |
204 self._creator = github.GithubObject.NotSet | |
205 self._description = github.GithubObject.NotSet | |
206 self._due_on = github.GithubObject.NotSet | |
207 self._id = github.GithubObject.NotSet | |
208 self._labels_url = github.GithubObject.NotSet | |
209 self._number = github.GithubObject.NotSet | |
210 self._open_issues = github.GithubObject.NotSet | |
211 self._state = github.GithubObject.NotSet | |
212 self._title = github.GithubObject.NotSet | |
213 self._updated_at = github.GithubObject.NotSet | |
214 self._url = github.GithubObject.NotSet | |
215 | |
216 def _useAttributes(self, attributes): | |
217 if "closed_issues" in attributes: # pragma no branch | |
218 self._closed_issues = self._makeIntAttribute(attributes["closed_issues"]) | |
219 if "created_at" in attributes: # pragma no branch | |
220 self._created_at = self._makeDatetimeAttribute(attributes["created_at"]) | |
221 if "creator" in attributes: # pragma no branch | |
222 self._creator = self._makeClassAttribute(github.NamedUser.NamedUser, attributes["creator"]) | |
223 if "description" in attributes: # pragma no branch | |
224 self._description = self._makeStringAttribute(attributes["description"]) | |
225 if "due_on" in attributes: # pragma no branch | |
226 self._due_on = self._makeDatetimeAttribute(attributes["due_on"]) | |
227 if "id" in attributes: # pragma no branch | |
228 self._id = self._makeIntAttribute(attributes["id"]) | |
229 if "labels_url" in attributes: # pragma no branch | |
230 self._labels_url = self._makeStringAttribute(attributes["labels_url"]) | |
231 if "number" in attributes: # pragma no branch | |
232 self._number = self._makeIntAttribute(attributes["number"]) | |
233 if "open_issues" in attributes: # pragma no branch | |
234 self._open_issues = self._makeIntAttribute(attributes["open_issues"]) | |
235 if "state" in attributes: # pragma no branch | |
236 self._state = self._makeStringAttribute(attributes["state"]) | |
237 if "title" in attributes: # pragma no branch | |
238 self._title = self._makeStringAttribute(attributes["title"]) | |
239 if "updated_at" in attributes: # pragma no branch | |
240 self._updated_at = self._makeDatetimeAttribute(attributes["updated_at"]) | |
241 if "url" in attributes: # pragma no branch | |
242 self._url = self._makeStringAttribute(attributes["url"]) |