MCPcopy
hub / github.com/donnemartin/gitsome / refresh

Method refresh

gitsome/lib/github3/models.py:240–276  ·  view source on GitHub ↗

Re-retrieve the information for this object. The reasoning for the return value is the following example: :: repos = [r.refresh() for r in g.repositories_by('kennethreitz')] Without the return value, that would be an array of ``None``'s and you would otherwise

(self, conditional=False)

Source from the content-addressed store, hash-verified

238 return self._remaining
239
240 def refresh(self, conditional=False):
241 """Re-retrieve the information for this object.
242
243 The reasoning for the return value is the following example: ::
244
245 repos = [r.refresh() for r in g.repositories_by('kennethreitz')]
246
247 Without the return value, that would be an array of ``None``'s and you
248 would otherwise have to do: ::
249
250 repos = [r for i in g.repositories_by('kennethreitz')]
251 [r.refresh() for r in repos]
252
253 Which is really an anti-pattern.
254
255 .. versionchanged:: 0.5
256
257 .. _Conditional Requests:
258 http://developer.github.com/v3/#conditional-requests
259
260 :param bool conditional: If True, then we will search for a stored
261 header ('Last-Modified', or 'ETag') on the object and send that
262 as described in the `Conditional Requests`_ section of the docs
263 :returns: self
264 """
265 headers = {}
266 if conditional:
267 if self.last_modified:
268 headers['If-Modified-Since'] = self.last_modified
269 elif self.etag:
270 headers['If-None-Match'] = self.etag
271
272 headers = headers or None
273 json = self._json(self._get(self._api, headers=headers), 200)
274 if json is not None:
275 self._update_attributes(json)
276 return self
277
278
279class BaseComment(GitHubCore):

Callers

nothing calls this directly

Calls 3

_jsonMethod · 0.95
_getMethod · 0.95
_update_attributesMethod · 0.95

Tested by

no test coverage detected