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

Commitfca45b0

Browse files
committed
Update github3.repos.comparison for consistency
1 parent0517bbe commitfca45b0

File tree

1 file changed

+62
-56
lines changed

1 file changed

+62
-56
lines changed

‎github3/repos/comparison.py

Lines changed: 62 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,84 @@
11
# -*- coding: utf-8 -*-
2-
"""
3-
github3.repos.comparison
4-
========================
5-
6-
This module contains the Comparison object for comparing two commits via the
7-
GitHub API.
8-
9-
"""
2+
"""This module contains the Comparison object."""
103
from __future__importunicode_literals
114

125
from .importcommit
6+
from ..importmodels
137

14-
from ..modelsimportGitHubCore
158

9+
classComparison(models.GitHubCore):
10+
"""A representation of a comparison between two or more commit objects.
1611
17-
classComparison(GitHubCore):
18-
"""The :class:`Comparison <Comparison>` object. This encapsulates the
19-
information returned by GitHub comparing two commit objects in a
20-
repository.
12+
See also:
13+
http://developer.github.com/v3/repos/commits/#compare-two-commits
2114
22-
Two comparison instances can be checked like so::
15+
This object has the following attributes::
2316
24-
c1 == c2
25-
c1 != c2
17+
.. attribute:: ahead_by
2618
27-
And is equivalent to::
19+
The number of commits between the head and base commit.
2820
29-
c1.commits == c2.commits
30-
c1.commits != c2.commits
21+
.. attribute:: base_commit
3122
32-
See also:
33-
http://developer.github.com/v3/repos/commits/#compare-two-commits
34-
"""
23+
A :class:`~github3.repos.commit.ShortCommit` representing the base
24+
commit in this comparison.
3525
36-
def_update_attributes(self,compare):
37-
self._api=self._get_attribute(compare,'url')
26+
.. attribute:: behind_by
27+
28+
The number of commits the head commit is behind the base.
29+
30+
.. attribute:: commits
3831
39-
#: URL to view the comparison at GitHub
40-
self.html_url=self._get_attribute(compare,'html_url')
32+
A list of :class:`~github3.repos.commit.ShortCommit` objects
33+
representing the commits in the comparison.
4134
42-
#: Permanent link to this comparison.
43-
self.permalink_url=self._get_attribute(compare,'permalink_url')
35+
.. attribute:: diff_url
4436
45-
#: URL to see the diff between the two commits.
46-
self.diff_url=self._get_attribute(compare,'diff_url')
37+
The URL to retrieve the diff between the head and base commits.
4738
48-
#: Patch URL at GitHub for the comparison.
49-
self.patch_url=self._get_attribute(compare,'patch_url')
39+
.. attribute:: files
5040
51-
#: :class:`RepoCommit <github3.repos.commit.RepoCommit>` object
52-
#: representing the base of comparison.
53-
self.base_commit=self._class_attribute(
54-
compare,'base_commit',commit.ShortCommit,None
55-
)
41+
A list of dictionaries describing each of the modified files in the
42+
comparison.
5643
57-
#: Behind or ahead.
58-
self.status=self._get_attribute(compare,'status')
44+
.. attribute:: html_url
5945
60-
#: Number of commits ahead by.
61-
self.ahead_by=self._get_attribute(compare,'ahead_by')
46+
The URL to view the comparison in a browser.
6247
63-
#: Number of commits behind by.
64-
self.behind_by=self._get_attribute(compare,'behind_by')
48+
.. attribute:: patch_url
6549
66-
#: Number of commits difference in the comparison.
67-
self.total_commits=self._get_attribute(compare,'total_commits')
50+
The URL to retrieve the patch-formatted diff of this comparison.
6851
69-
#: List of :class:`RepoCommit <github3.repos.commit.RepoCommit>`
70-
#: objects.
71-
self.commits=self._get_attribute(compare,'commits', [])
52+
.. attribute:: permalink_url
53+
54+
The permanent URL to retrieve this comparison.
55+
56+
.. attribute:: status
57+
58+
Whether the head commit is ahead or behind of base.
59+
60+
.. attribute:: total_commits
61+
62+
The total number of commits difference.
63+
"""
64+
65+
def_update_attributes(self,compare):
66+
self._api=compare['url']
67+
self.ahead_by=compare['ahead_by']
68+
self.base_commit=commit.ShortCommit(compare['base_commit'],self)
69+
self.behind_by=compare['behind_by']
70+
self.commits=compare['commits']
7271
ifself.commits:
7372
self.commits= [
7473
commit.ShortCommit(com,self)forcominself.commits
7574
]
76-
77-
#: List of dicts describing the files modified.
78-
self.files=self._get_attribute(compare,'files', [])
79-
75+
self.diff_url=compare['diff_url']
76+
self.files=compare['files']
77+
self.html_url=compare['html_url']
78+
self.patch_url=compare['patch_url']
79+
self.permalink_url=compare['permalink_url']
80+
self.status=compare['status']
81+
self.total_commits=compare['total_commits']
8082
self._uniq=self.commits
8183

8284
def_repr(self):
@@ -85,8 +87,10 @@ def _repr(self):
8587
defdiff(self):
8688
"""Retrieve the diff for this comparison.
8789
88-
:returns: the diff as a bytes object
89-
:rtype: bytes
90+
:returns:
91+
the diff as a bytes object
92+
:rtype:
93+
bytes
9094
"""
9195
resp=self._get(self._api,
9296
headers={'Accept':'application/vnd.github.diff'})
@@ -95,8 +99,10 @@ def diff(self):
9599
defpatch(self):
96100
"""Retrieve the patch formatted diff for this commit.
97101
98-
:returns: the patch as a bytes object
99-
:rtype: bytes
102+
:returns:
103+
the patch as a bytes object
104+
:rtype:
105+
bytes
100106
"""
101107
resp=self._get(self._api,
102108
headers={'Accept':'application/vnd.github.patch'})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp