Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit10d0343

Browse files
authored
Merge pull requestsigmavirus24#790 from sigmavirus24/refresh-updates
Allow .refresh to return the longer object
2 parentsbbb176b +151459c commit10d0343

File tree

14 files changed

+761
-735
lines changed

14 files changed

+761
-735
lines changed

‎github3/gists/file.py‎

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,33 @@ def content(self):
3232
returnNone
3333

3434

35+
classGistFile(_GistFile):
36+
"""This represents the full file object returned by interacting with gists.
37+
38+
The object has all of the attributes as returned by the API for a
39+
ShortGistFile as well as:
40+
41+
.. attribute:: truncated
42+
43+
A boolean attribute that indicates whether :attr:`original_content`
44+
contains all of the file's contents.
45+
46+
.. attribute:: original_content
47+
48+
The contents of the file (potentially truncated) returned by the API.
49+
If the file was truncated use :meth:`content` to retrieve it in its
50+
entirety.
51+
52+
"""
53+
54+
class_name='GistFile'
55+
56+
def_update_attributes(self,gistfile):
57+
super(GistFile,self)._update_attributes(gistfile)
58+
self.original_content=gistfile['content']
59+
self.truncated=gistfile['truncated']
60+
61+
3562
classShortGistFile(_GistFile):
3663
"""This represents the file object returned by interacting with gists.
3764
@@ -60,30 +87,4 @@ class ShortGistFile(_GistFile):
6087
"""
6188

6289
class_name='ShortGistFile'
63-
64-
65-
classGistFile(_GistFile):
66-
"""This represents the full file object returned by interacting with gists.
67-
68-
The object has all of the attributes as returned by the API for a
69-
ShortGistFile as well as:
70-
71-
.. attribute:: truncated
72-
73-
A boolean attribute that indicates whether :attr:`original_content`
74-
contains all of the file's contents.
75-
76-
.. attribute:: original_content
77-
78-
The contents of the file (potentially truncated) returned by the API.
79-
If the file was truncated use :meth:`content` to retrieve it in its
80-
entirety.
81-
82-
"""
83-
84-
class_name='GistFile'
85-
86-
def_update_attributes(self,gistfile):
87-
super(GistFile,self)._update_attributes(gistfile)
88-
self.original_content=gistfile['content']
89-
self.truncated=gistfile['truncated']
90+
_refresh_to=GistFile

‎github3/gists/gist.py‎

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -228,87 +228,6 @@ def unstar(self):
228228
returnself._boolean(self._delete(url),204,404)
229229

230230

231-
classShortGist(_Gist):
232-
"""Short representation of a gist.
233-
234-
GitHub's API returns different amounts of information about gists
235-
based upon how that information is retrieved. This object exists to
236-
represent the full amount of information returned for a specific
237-
gist. For example, you would receive this class when calling
238-
:meth:`~github3.github.GitHub.all_gists`. To provide a clear distinction
239-
between the types of gists, github3.py uses different classes with
240-
different sets of attributes.
241-
242-
This object only has the following attributes:
243-
244-
.. attribute:: url
245-
246-
The GitHub API URL for this repository, e.g.,
247-
``https://api.github.com/gists/6faaaeb956dec3f51a9bd630a3490291``.
248-
249-
.. attribute:: comments_count
250-
251-
Number of comments on this gist
252-
253-
.. attribute:: description
254-
255-
Description of the gist as written by the creator
256-
257-
.. attribute:: html_url
258-
259-
The URL of this gist on GitHub, e.g.,
260-
``https://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291``
261-
262-
.. attribute:: id
263-
264-
The unique identifier for this gist.
265-
266-
.. attribute:: public
267-
268-
This is a boolean attribute describing if the gist is public or
269-
private
270-
271-
.. attribute:: git_pull_url
272-
273-
The git URL to pull this gist, e.g.,
274-
``git://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``
275-
276-
.. attribute:: git_push_url
277-
278-
The git URL to push to gist, e.g.,
279-
``git@gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``
280-
281-
.. attribute:: created_at
282-
283-
This is a datetime object representing when the gist was created.
284-
285-
.. attribute:: updated_at
286-
This is a datetime object representing the last time this gist was
287-
most recently updated.
288-
289-
.. attribute:: owner
290-
291-
This attribute is a :class:`~github3.users.ShortUser` object
292-
representing the creator of the gist.
293-
294-
.. attribute:: files
295-
296-
A dictionary mapping the filename to a
297-
:class:`~github3.gists.gist.GistFile` object.
298-
299-
.. versionchanged:: 1.0.0
300-
301-
Previously this was a list but it has been converted to a
302-
dictionary to preserve the structure of the API.
303-
304-
.. attribute:: comments_url
305-
306-
The URL to retrieve the list of comments on the Gist via the API.
307-
"""
308-
309-
class_name='ShortGist'
310-
311-
312231
classGistFork(models.GitHubCore):
313232
"""This object represents a forked Gist.
314233
@@ -409,3 +328,85 @@ def _update_attributes(self, gist):
409328
self.forks_url=gist['forks_url']
410329
self.history= [history.GistHistory(h,self)forhingist['history']]
411330
self.truncated=gist['truncated']
331+
332+
333+
classShortGist(_Gist):
334+
"""Short representation of a gist.
335+
336+
GitHub's API returns different amounts of information about gists
337+
based upon how that information is retrieved. This object exists to
338+
represent the full amount of information returned for a specific
339+
gist. For example, you would receive this class when calling
340+
:meth:`~github3.github.GitHub.all_gists`. To provide a clear distinction
341+
between the types of gists, github3.py uses different classes with
342+
different sets of attributes.
343+
344+
This object only has the following attributes:
345+
346+
.. attribute:: url
347+
348+
The GitHub API URL for this repository, e.g.,
349+
``https://api.github.com/gists/6faaaeb956dec3f51a9bd630a3490291``.
350+
351+
.. attribute:: comments_count
352+
353+
Number of comments on this gist
354+
355+
.. attribute:: description
356+
357+
Description of the gist as written by the creator
358+
359+
.. attribute:: html_url
360+
361+
The URL of this gist on GitHub, e.g.,
362+
``https://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291``
363+
364+
.. attribute:: id
365+
366+
The unique identifier for this gist.
367+
368+
.. attribute:: public
369+
370+
This is a boolean attribute describing if the gist is public or
371+
private
372+
373+
.. attribute:: git_pull_url
374+
375+
The git URL to pull this gist, e.g.,
376+
``git://gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``
377+
378+
.. attribute:: git_push_url
379+
380+
The git URL to push to gist, e.g.,
381+
``git@gist.github.com/sigmavirus24/6faaaeb956dec3f51a9bd630a3490291.git``
382+
383+
.. attribute:: created_at
384+
385+
This is a datetime object representing when the gist was created.
386+
387+
.. attribute:: updated_at
388+
This is a datetime object representing the last time this gist was
389+
most recently updated.
390+
391+
.. attribute:: owner
392+
393+
This attribute is a :class:`~github3.users.ShortUser` object
394+
representing the creator of the gist.
395+
396+
.. attribute:: files
397+
398+
A dictionary mapping the filename to a
399+
:class:`~github3.gists.gist.GistFile` object.
400+
401+
.. versionchanged:: 1.0.0
402+
403+
Previously this was a list but it has been converted to a
404+
dictionary to preserve the structure of the API.
405+
406+
.. attribute:: comments_url
407+
408+
The URL to retrieve the list of comments on the Gist via the API.
409+
"""
410+
411+
class_name='ShortGist'
412+
_refresh_to=Gist

‎github3/git.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ class ShortCommit(_Commit):
174174
"""
175175

176176
class_name='ShortCommit'
177-
refresh_to=Commit
177+
_refresh_to=Commit
178178

179179

180180
classReference(models.GitHubCore):

‎github3/issues/issue.py‎

Lines changed: 43 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,47 @@ def unlock(self):
369369
returnself._boolean(self._delete(url),204,404)
370370

371371

372+
classIssue(_Issue):
373+
"""Object for the full representation of an Issue.
374+
375+
GitHub's API returns different amounts of information about issues based
376+
upon how that information is retrieved. This object exists to represent
377+
the full amount of information returned for a specific issue. For example,
378+
you would receive this class when calling
379+
:meth:`~github3.github.GitHub.issue`. To provide a clear
380+
distinction between the types of issues, github3.py uses different classes
381+
with different sets of attributes.
382+
383+
.. versionchanged:: 1.0.0
384+
385+
This object has all of the same attributes as a
386+
:class:`~github3.issues.issue.ShortIssue` as well as the following:
387+
388+
.. attribute:: body_html
389+
390+
The HTML formatted body of this issue.
391+
392+
.. attribute:: body_text
393+
394+
The plain-text formatted body of this issue.
395+
396+
.. attribute:: closed_by
397+
398+
If the issue is closed, a :class:`~github3.users.ShortUser`
399+
representing the user who closed the issue.
400+
"""
401+
402+
class_name='Issue'
403+
404+
def_update_attributes(self,issue):
405+
super(Issue,self)._update_attributes(issue)
406+
self.body_html=issue['body_html']
407+
self.body_text=issue['body_text']
408+
self.closed_by=issue['closed_by']
409+
ifself.closed_by:
410+
self.closed_by=users.ShortUser(self.closed_by,self)
411+
412+
372413
classShortIssue(_Issue):
373414
"""Object for the shortened representation of an Issue.
374415
@@ -481,43 +522,5 @@ class ShortIssue(_Issue):
481522
this issue.
482523
"""
483524

484-
pass
485-
486-
487-
classIssue(_Issue):
488-
"""Object for the full representation of an Issue.
489-
490-
GitHub's API returns different amounts of information about issues based
491-
upon how that information is retrieved. This object exists to represent
492-
the full amount of information returned for a specific issue. For example,
493-
you would receive this class when calling
494-
:meth:`~github3.github.GitHub.issue`. To provide a clear
495-
distinction between the types of issues, github3.py uses different classes
496-
with different sets of attributes.
497-
498-
.. versionchanged:: 1.0.0
499-
500-
This object has all of the same attributes as a
501-
:class:`~github3.issues.issue.ShortIssue` as well as the following:
502-
503-
.. attribute:: body_html
504-
505-
The HTML formatted body of this issue.
506-
507-
.. attribute:: body_text
508-
509-
The plain-text formatted body of this issue.
510-
511-
.. attribute:: closed_by
512-
513-
If the issue is closed, a :class:`~github3.users.ShortUser`
514-
representing the user who closed the issue.
515-
"""
516-
517-
def_update_attributes(self,issue):
518-
super(Issue,self)._update_attributes(issue)
519-
self.body_html=issue['body_html']
520-
self.body_text=issue['body_text']
521-
self.closed_by=issue['closed_by']
522-
ifself.closed_by:
523-
self.closed_by=users.ShortUser(self.closed_by,self)
525+
class_name='ShortIssue'
526+
_refresh_to=Issue

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp