Skip to content

Commit 4b210a7

Browse files
committed
Merge remote-tracking branch 'origin/develop' into split-up-repository
Conflicts: - github3/github.py - github3/users.py - tests/cassettes/GitHub_create_issue.json - tests/cassettes/Issue_events.json - tests/cassettes/Issue_pull_request.json - tests/cassettes/Milestone_labels.json - tests/cassettes/Organization_create_repository.json - tests/cassettes/Organization_repositories.json - tests/cassettes/PullRequest_issue.json - tests/cassettes/Repository_create_issue.json - tests/cassettes/Repository_events.json - tests/cassettes/Repository_issue.json - tests/cassettes/Repository_issue_events.json - tests/cassettes/Repository_issues_ascending.json - tests/cassettes/Repository_issues_state_all.json - tests/cassettes/Repository_network_events.json - tests/cassettes/Team_repositories.json - tests/cassettes/User_events.json - tests/cassettes/User_organization_events.json - tests/integration/test_users.py - tests/unit/json/pull_request_example - tox.ini
2 parents 135a994 + 0657d44 commit 4b210a7

File tree

133 files changed

+2007
-810
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+2007
-810
lines changed

.travis.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ matrix:
1717
include:
1818
- python: 2.7
1919
env: TOXENV=py27 REQUESTS_VERSION="===2.0.1"
20-
- python: 3.3
21-
env: TOXENV=py33 REQUESTS_VERSION="===2.0.1"
2220
- python: 3.4
2321
env: TOXENV=py34 REQUESTS_VERSION="===2.0.1"
2422
- python: 3.5
@@ -27,8 +25,6 @@ matrix:
2725
env: TOXENV=pypy REQUESTS_VERSION="===2.0.1"
2826
- python: 2.7
2927
env: TOXENV=py27 REQUESTS_VERSION=""
30-
- python: 3.3
31-
env: TOXENV=py33 REQUESTS_VERSION=""
3228
- python: 3.4
3329
env: TOXENV=py34 REQUESTS_VERSION=""
3430
- python: 3.5

AUTHORS.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,3 +146,11 @@ Contributors
146146
- Björn Kautler (@Vampire)
147147

148148
- David Prothero (@dprothero)
149+
150+
- Jesse Keating (@omgjlk)
151+
152+
- @rco-ableton
153+
154+
- Mark Troyer (@discogestalt)
155+
156+
- Becca James (@beccasjames)

appveyor.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ environment:
88
TOXENV: py27
99
- PYTHON: "C:\\Python27-x64"
1010
TOXENV: py27
11-
- PYTHON: "C:\\Python33"
12-
TOXENV: py33
13-
- PYTHON: "C:\\Python33-x64"
14-
TOXENV: py33
1511
- PYTHON: "C:\\Python34"
1612
TOXENV: py34
1713
- PYTHON: "C:\\Python34-x64"

dev-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.
22
#coverage==3.5.2
33
mock==1.0.1
4-
pytest>=2.3.5
4+
pytest>=2.3.5,<3.3.0
55
wheel==0.21.0
66
betamax>=0.5.0
77
betamax_matchers>=0.2.0

docs/examples/git.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Creating a Blob Object
99
----------------------
1010

1111
One of the really cool (and under used, it seems) parts of the GitHub API
12-
involves the ability to create commit and blob objects.
12+
involves the ability to create blob objects.
1313

1414
.. code-block:: python
1515

docs/examples/github.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ Creating a new repository
121121
if r:
122122
print("Created {0} successfully.".format(r.name))
123123

124+
Create a commit to change an existing file
125+
------------------------------------------
126+
127+
::
128+
129+
repo.contents('/README.md').update('commit message', 'file content'.encode('utf-8'))
130+
124131
Follow another user on GitHub
125132
-----------------------------
126133

github3/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ def issues_on(owner, repository, milestone=None, state=None, assignee=None,
266266
Default: -1 returns all issues
267267
:param str etag: (optional), ETag from a previous request to the same
268268
endpoint
269-
:returns: generator of :class:`Issue <github3.issues.Issue>`\ s
269+
:returns: generator of :class:`ShortIssue <github3.issues.ShortIssue>`\ s
270270
271271
"""
272272
if owner and repository:
@@ -285,7 +285,7 @@ def organizations_with(username, number=-1, etag=None):
285285
:param str etag: (optional), ETag from a previous request to the same
286286
endpoint
287287
:returns: generator of
288-
:class:`Organization <github3.orgs.Organization>`
288+
:class:`ShortOrganization <github3.orgs.ShortOrganization>`
289289
290290
"""
291291
return gh.organizations_with(username, number, etag)

github3/events.py

Lines changed: 61 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,60 @@ def to_user(self):
3232
return self._instance_or_null(users.User, json)
3333

3434

35+
class EventOrganization(GitHubCore):
36+
"""The class that represents the org information returned in Events."""
37+
38+
def _update_attributes(self, org):
39+
self.avatar_url = org['avatar_url']
40+
self.gravatar_id = org['id']
41+
self.id = org['id']
42+
self.login = org['login']
43+
self._api = self.url = org['url']
44+
45+
def to_org(self):
46+
"""Retrieve a full Organization object for this EventOrganization."""
47+
from . import orgs
48+
url = self._build_url('orgs', self.login)
49+
json = self._json(self._get(url), 200)
50+
return self._instance_or_null(orgs.Organization, json)
51+
52+
53+
class EventPullRequest(GitHubCore):
54+
"""The class that represents the pr information returned in Events."""
55+
56+
def _update_attributes(self, pull):
57+
self.id = pull['id']
58+
self.number = pull['number']
59+
self.state = pull['state']
60+
self.title = pull['title']
61+
self.locked = pull['locked']
62+
self._api = self.url = pull['url']
63+
64+
def to_pull(self):
65+
"""Retrieve a full PullRequest object for this EventPullRequest."""
66+
from . import pulls
67+
json = self._json(self._get(self.url), 200)
68+
return self._instance_or_null(pulls.PullRequest, json)
69+
70+
71+
class EventIssue(GitHubCore):
72+
"""The class that represents the issue information returned in Events."""
73+
74+
def _update_attributes(self, issue):
75+
self.id = issue['id']
76+
self.number = issue['number']
77+
self.state = issue['state']
78+
self.title = issue['title']
79+
self.locked = issue['locked']
80+
self._api = self.url = issue['url']
81+
82+
def to_issue(self):
83+
"""Retrieve a full Issue object for this EventIssue."""
84+
from . import issues
85+
json = self._json(self._get(self.url), 200)
86+
return self._instance_or_null(issues.Issue, json)
87+
88+
3589
class Event(GitHubCore):
3690

3791
"""The :class:`Event <Event>` object. It structures and handles the data
@@ -56,7 +110,6 @@ def _update_attributes(self, event):
56110
# not want to do:
57111
event = copy.deepcopy(event)
58112

59-
from .orgs import Organization
60113
#: :class:`User <github3.users.User>` object representing the actor.
61114
self.actor = self._class_attribute(event, 'actor', EventUser)
62115
#: datetime object representing when the event was created.
@@ -66,7 +119,7 @@ def _update_attributes(self, event):
66119
self.id = self._get_attribute(event, 'id')
67120

68121
#: List all possible types of Events
69-
self.org = self._class_attribute(event, 'org', Organization)
122+
self.org = self._class_attribute(event, 'org', EventOrganization)
70123

71124
#: Event type https://developer.github.com/v3/activity/events/types/
72125
self.type = self._get_attribute(event, 'type')
@@ -121,19 +174,17 @@ def _gist(payload, session):
121174

122175

123176
def _issuecomm(payload, session):
124-
from .issues import Issue
125177
from .issues.comment import IssueComment
126178
if payload.get('issue'):
127-
payload['issue'] = Issue(payload['issue'], session)
179+
payload['issue'] = EventIssue(payload['issue'], session)
128180
if payload.get('comment'):
129181
payload['comment'] = IssueComment(payload['comment'], session)
130182
return payload
131183

132184

133185
def _issueevent(payload, session):
134-
from .issues import Issue
135186
if payload.get('issue'):
136-
payload['issue'] = Issue(payload['issue'], session)
187+
payload['issue'] = EventIssue(payload['issue'], session)
137188
return payload
138189

139190

@@ -144,19 +195,18 @@ def _member(payload, session):
144195

145196

146197
def _pullreqev(payload, session):
147-
from .pulls import PullRequest
148198
if payload.get('pull_request'):
149-
payload['pull_request'] = PullRequest(payload['pull_request'],
150-
session)
199+
payload['pull_request'] = EventPullRequest(payload['pull_request'],
200+
session)
151201
return payload
152202

153203

154204
def _pullreqcomm(payload, session):
155-
from .pulls import PullRequest, ReviewComment
205+
from .pulls import ReviewComment
156206
# Transform the Pull Request attribute
157207
pull = payload.get('pull_request')
158208
if pull:
159-
payload['pull_request'] = PullRequest(pull, session)
209+
payload['pull_request'] = EventPullRequest(pull, session)
160210

161211
# Transform the Comment attribute
162212
comment = payload.get('comment')

github3/exceptions.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __init__(self, resp):
1818
#: List of errors provided by GitHub
1919
if error.get('errors'):
2020
self.errors = error.get('errors')
21-
except: # Amazon S3 error
21+
except Exception: # Amazon S3 error
2222
self.msg = resp.content or '[No message]'
2323

2424
def __repr__(self):
@@ -34,6 +34,22 @@ def message(self):
3434
return self.msg
3535

3636

37+
class IncompleteResponse(GitHubError):
38+
"""Exception for a response that doesn't have everything it should."""
39+
40+
def __init__(self, json, exception):
41+
self.response = None
42+
self.code = None
43+
self.json = json
44+
self.errors = []
45+
self.exception = exception
46+
self.msg = (
47+
"The library was expecting more data in the response (%r)."
48+
" Either GitHub modified it's response body, or your token"
49+
" is not properly scoped to retrieve this information."
50+
) % (exception,)
51+
52+
3753
class ResponseError(GitHubError):
3854
"""The base exception for errors stemming from GitHub responses."""
3955
pass
@@ -115,6 +131,16 @@ class NotAcceptable(ResponseError):
115131
pass
116132

117133

134+
class Conflict(ResponseError):
135+
"""Exception class for 409 responses.
136+
137+
Possible reasons:
138+
139+
- Head branch was modified (SHA sums do not match)
140+
"""
141+
pass
142+
143+
118144
class UnprocessableEntity(ResponseError):
119145
"""Exception class for 422 responses."""
120146
pass
@@ -142,6 +168,7 @@ class UnavailableForLegalReasons(ResponseError):
142168
404: NotFoundError,
143169
405: MethodNotAllowed,
144170
406: NotAcceptable,
171+
409: Conflict,
145172
422: UnprocessableEntity,
146173
451: UnavailableForLegalReasons,
147174
}

0 commit comments

Comments
 (0)