Repository navigation
Expand file tree
/
Copy pathMilestone.py
More file actions
175 lines (150 loc) · 7.31 KB
/
Copy pathMilestone.py
File metadata and controls
175 lines (150 loc) · 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
# WARNING: this file is generated automaticaly.
# Do not modify it manually, your work would be lost.
# Copyright 2012 Vincent Jacques
# vincent@vincent-jacques.net
# This file is part of PyGithub. http://vincent-jacques.net/PyGithub
# PyGithub is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
# PyGithub is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public License along with PyGithub. If not, see <http://www.gnu.org/licenses/>.
import datetime
import GithubObject
import PaginatedList
import NamedUser
import Label
class Milestone( GithubObject.GithubObject ):
@property
def closed_issues( self ):
self._completeIfNotSet( self._closed_issues )
return self._NoneIfNotSet( self._closed_issues )
@property
def created_at( self ):
self._completeIfNotSet( self._created_at )
return self._NoneIfNotSet( self._created_at )
@property
def creator( self ):
self._completeIfNotSet( self._creator )
return self._NoneIfNotSet( self._creator )
@property
def description( self ):
self._completeIfNotSet( self._description )
return self._NoneIfNotSet( self._description )
@property
def due_on( self ):
self._completeIfNotSet( self._due_on )
return self._NoneIfNotSet( self._due_on )
@property
def id( self ):
self._completeIfNotSet( self._id )
return self._NoneIfNotSet( self._id )
@property
def number( self ):
self._completeIfNotSet( self._number )
return self._NoneIfNotSet( self._number )
@property
def open_issues( self ):
self._completeIfNotSet( self._open_issues )
return self._NoneIfNotSet( self._open_issues )
@property
def state( self ):
self._completeIfNotSet( self._state )
return self._NoneIfNotSet( self._state )
@property
def title( self ):
self._completeIfNotSet( self._title )
return self._NoneIfNotSet( self._title )
@property
def url( self ):
self._completeIfNotSet( self._url )
return self._NoneIfNotSet( self._url )
def delete( self ):
headers, data = self._requester.requestAndCheck(
"DELETE",
self.url,
None,
None
)
def edit( self, title, state = GithubObject.NotSet, description = GithubObject.NotSet, due_on = GithubObject.NotSet ):
assert isinstance( title, ( str, unicode ) ), title
assert state is GithubObject.NotSet or isinstance( state, ( str, unicode ) ), state
assert description is GithubObject.NotSet or isinstance( description, ( str, unicode ) ), description
assert due_on is GithubObject.NotSet or isinstance( due_on, datetime.date ), due_on
post_parameters = {
"title": title,
}
if state is not GithubObject.NotSet:
post_parameters[ "state" ] = state
if description is not GithubObject.NotSet:
post_parameters[ "description" ] = description
if due_on is not GithubObject.NotSet:
post_parameters[ "due_on" ] = due_on.strftime( "%Y-%m-%d" )
headers, data = self._requester.requestAndCheck(
"PATCH",
self.url,
None,
post_parameters
)
self._useAttributes( data )
def get_labels( self ):
headers, data = self._requester.requestAndCheck(
"GET",
self.url + "/labels",
None,
None
)
return PaginatedList.PaginatedList(
Label.Label,
self._requester,
headers,
data
)
@property
def _identity( self ):
return self.number
def _initAttributes( self ):
self._closed_issues = GithubObject.NotSet
self._created_at = GithubObject.NotSet
self._creator = GithubObject.NotSet
self._description = GithubObject.NotSet
self._due_on = GithubObject.NotSet
self._id = GithubObject.NotSet
self._number = GithubObject.NotSet
self._open_issues = GithubObject.NotSet
self._state = GithubObject.NotSet
self._title = GithubObject.NotSet
self._url = GithubObject.NotSet
def _useAttributes( self, attributes ):
if "closed_issues" in attributes: # pragma no branch
assert attributes[ "closed_issues" ] is None or isinstance( attributes[ "closed_issues" ], int ), attributes[ "closed_issues" ]
self._closed_issues = attributes[ "closed_issues" ]
if "created_at" in attributes: # pragma no branch
assert attributes[ "created_at" ] is None or isinstance( attributes[ "created_at" ], ( str, unicode ) ), attributes[ "created_at" ]
self._created_at = self._parseDatetime( attributes[ "created_at" ] )
if "creator" in attributes: # pragma no branch
assert attributes[ "creator" ] is None or isinstance( attributes[ "creator" ], dict ), attributes[ "creator" ]
self._creator = None if attributes[ "creator" ] is None else NamedUser.NamedUser( self._requester, attributes[ "creator" ], completed = False )
if "description" in attributes: # pragma no branch
assert attributes[ "description" ] is None or isinstance( attributes[ "description" ], ( str, unicode ) ), attributes[ "description" ]
self._description = attributes[ "description" ]
if "due_on" in attributes: # pragma no branch
assert attributes[ "due_on" ] is None or isinstance( attributes[ "due_on" ], ( str, unicode ) ), attributes[ "due_on" ]
self._due_on = self._parseDatetime( attributes[ "due_on" ] )
if "id" in attributes: # pragma no branch
assert attributes[ "id" ] is None or isinstance( attributes[ "id" ], int ), attributes[ "id" ]
self._id = attributes[ "id" ]
if "number" in attributes: # pragma no branch
assert attributes[ "number" ] is None or isinstance( attributes[ "number" ], int ), attributes[ "number" ]
self._number = attributes[ "number" ]
if "open_issues" in attributes: # pragma no branch
assert attributes[ "open_issues" ] is None or isinstance( attributes[ "open_issues" ], int ), attributes[ "open_issues" ]
self._open_issues = attributes[ "open_issues" ]
if "state" in attributes: # pragma no branch
assert attributes[ "state" ] is None or isinstance( attributes[ "state" ], ( str, unicode ) ), attributes[ "state" ]
self._state = attributes[ "state" ]
if "title" in attributes: # pragma no branch
assert attributes[ "title" ] is None or isinstance( attributes[ "title" ], ( str, unicode ) ), attributes[ "title" ]
self._title = attributes[ "title" ]
if "url" in attributes: # pragma no branch
assert attributes[ "url" ] is None or isinstance( attributes[ "url" ], ( str, unicode ) ), attributes[ "url" ]
self._url = attributes[ "url" ]