8000 Merge pull request #337 from sigmavirus24/stable/0.9 · lllama/github3.py@b26841b · GitHub
[go: up one dir, main page]

Skip to content

Commit b26841b

Browse files
committed
Merge pull request sigmavirus24#337 from sigmavirus24/stable/0.9
Merge latest 0.9 into master
2 parents ebdcbbf + 6e97462 commit b26841b

Some content is hidden

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

55 files changed

+606
-242
lines changed

.travis.yml

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,34 @@
11
language: python
2-
python:
3-
- 2.6
4-
- 2.7
5-
- 3.2
6-
- 3.3
7-
- 3.4
8-
- pypy
9-
# command to run tests, e.g. python setup.py test
102
before_script:
11-
- pip install -r dev-requirements.txt
3+
- pip install tox
124
- pip install -U requests"$REQUESTS_VERSION"
135

146
# test script
15-
script: make travis
7+
script: tox -e ${TOX_ENV}
168
notifications:
17-
on_success: change
18-
on_failure: always
9+
on_success: change
10+
on_failure: always
1911

2012
env:
2113
global:
2214
- TRAVIS_GH3="True"
2315
matrix:
24-
- REQUESTS_VERSION="==2.0.1"
25-
- REQUESTS_VERSION="" # Latest
16+
- TOX_ENV=py26 REQUESTS_VERSION="==2.0.1"
17+
- TOX_ENV=py27 REQUESTS_VERSION="==2.0.1"
18+
- TOX_ENV=py32 REQUESTS_VERSION="==2.0.1"
19+
- TOX_ENV=py33 REQUESTS_VERSION="==2.0.1"
20+
- TOX_ENV=py34 REQUESTS_VERSION="==2.0.1"
21+
- TOX_ENV=pypy REQUESTS_VERSION="==2.0.1"
22+
- TOX_ENV=py26 REQUESTS_VERSION=""
23+
- TOX_ENV=py27 REQUESTS_VERSION=""
24+
- TOX_ENV=py32 REQUESTS_VERSION=""
25+
- TOX_ENV=py33 REQUESTS_VERSION=""
26+
- TOX_ENV=py34 REQUESTS_VERSION=""
27+
- TOX_ENV=pypy REQUESTS_VERSION=""
28+
- TOX_ENV=py27-flake8
29+
- TOX_ENV=py34-flake8
30+
31+
matrix:
32+
allow_failures:
33+
- env: TOX_ENV=py27-flake8
34+
- env: TOX_ENV=py34-flake8

AUTHORS.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,17 @@ Contributors
6666
- David Moss (@damoss007)
6767

6868
- John Barbuto (@jbarbuto)
69+
70+
- Nikolay Bryskin (@nikicat)
71+
72+
- Tomi Äijö (@tomiaijo)
73+
74+
- jnothman (@jnothman)
75+
76+
- Cameron Davidson-Pilon (@CamDavidsonPilon)
77+
78+
- Alex Couper (@alexcouper)
79+
80+
- Marc Abramowitz (@msabramo)
81+
82+
- Adrian Moisey (@adrianmoisey)

HISTORY.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,34 @@
11
History/Changelog
22
-----------------
33

4+
0.9.3: 2014-11-04
5+
~~~~~~~~~~~~~~~~~
6+
7+
- Backport of ``PullRequest#create_review_comment`` by Adrian Moisey
8+
9+
- Backport of ``PullRequest#review_comments`` by Adrian Moisey
10+
11+
- Backport of a fix that allows authenticated users to download Release
12+
Assets. Original bug reported by Eugene Fidelin in issue #288.
13+
14+
- Documentation typo fix by Marc Abramowitz
15+
16+
0.9.2: 2014-10-05
17+
~~~~~~~~~~~~~~~~~
18+
19+
- Updates for `new team management`_ API changes
20+
21+
- Add ``Team#invite``, ``Team#membership_for``, and
22+
``Team#revoke_membership``
23+
24+
- Deprecate ``Team#add_member``, ``Team#remove_member``, and
25+
``Organization#add_member``.
26+
27+
- Update payload handler for ``TeamAddEvent``.
28+
29+
.. _new team management:
30+
https://developer.github.com/changes/2014-09-23-one-more-week-before-the-add-team-member-api-breaking-change/
31+
432
0.9.1: 2014-08-10
533
~~~~~~~~~~~~~~~~~
634

github3/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
__author__ = 'Ian Cordasco'
1515
__license__ = 'Modified BSD'
1616
__copyright__ = 'Copyright 2012-2014 Ian Cordasco'
17-
__version__ = '0.9.1'
17+
__version__ = '0.9.3'
1818
__version_info__ = tuple(int(i) for i in __version__.split('.'))
1919

20-
from github3.api import *
21-
from github3.github import GitHub, GitHubEnterprise, GitHubStatus
22-
from github3.models import GitHubError
20+
from .api import *
21+
from .github import GitHub, GitHubEnterprise, GitHubStatus
22+
from .models import GitHubError
2323

2424
# flake8: noqa

github3/auths.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"""
99
from __future__ import unicode_literals
1010

11-
from github3.decorators import requires_basic_auth
12-
from github3.models import GitHubCore
11+
from .decorators import requires_basic_auth
12+
from .models import GitHubCore
1313

1414

1515
class Authorization(GitHubCore):

github3/decorators.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def auth_wrapper(self, *args, **kwargs):
3737
if auth:
3838
return func(self, *args, **kwargs)
3939
else:
40-
from github3.models import GitHubError
40+
from .models import GitHubError
4141
# Mock a 401 response
4242
r = generate_fake_error_response(
4343
'{"message": "Requires authentication"}'
@@ -58,7 +58,7 @@ def auth_wrapper(self, *args, **kwargs):
5858
if hasattr(self, '_session') and self._session.auth:
5959
return func(self, *args, **kwargs)
6060
else:
61-
from github3.models import GitHubError
61+
from .models import GitHubError
6262
# Mock a 401 response
6363
r = generate_fake_error_response(
6464
'{"message": "Requires username/password authentication"}'
@@ -80,7 +80,7 @@ def auth_wrapper(self, *args, **kwargs):
8080
if client_id and client_secret:
8181
return func(self, *args, **kwargs)
8282
else:
83-
from github3.models import GitHubError
83+
from .models import GitHubError
8484
# Mock a 401 response
8585
r = generate_fake_error_response(
8686
'{"message": "Requires username/password authentication"}'

github3/events.py

Lines changed: 58 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
"""
99
from __future__ import unicode_literals
1010

11-
from github3.models import GitHubObject
11+
from .models import GitHubCore
1212

1313

14-
class Event(GitHubObject):
14+
class Event(GitHubCore):
1515

1616
"""The :class:`Event <Event>` object. It structures and handles the data
1717
returned by via the `Events <http://developer.github.com/v3/events>`_
@@ -29,10 +29,10 @@ class Event(GitHubObject):
2929
3030
"""
3131

32-
def __init__(self, event):
33-
super(Event, self).__init__(event)
34-
from github3.users import User
35-
from github3.orgs import Organization
32+
def __init__(self, event, session=None):
33+
super(Event, self).__init__(event, session)
34+
from .users import User
35+
from .orgs import Organization
3636
#: :class:`User <github3.users.User>` object representing the actor.
3737
self.actor = User(event.get('actor')) if event.get('actor') else None
3838
#: datetime object representing when the event was created.
@@ -48,7 +48,7 @@ def __init__(self, event):
4848
handler = _payload_handlers.get(self.type, identity)
4949
#: Dictionary with the payload. Payload structure is defined by type_.
5050
# _type: http://developer.github.com/v3/events/types
51-
self.payload = handler(event.get('payload'))
51+
self.payload = handler(event.get('payload'), self)
5252
#: Return ``tuple(owner, repository_name)``
5353
self.repo = event.get('repo')
5454
if self.repo is not None:
@@ -74,94 +74,102 @@ def is_public(self):
7474
return self.public
7575

7676

77-
def _commitcomment(payload):
78-
from github3.repos.comment import RepoComment
77+
def _commitcomment(payload, session):
78+
from .repos.comment import RepoComment
7979
if payload.get('comment'):
80-
payload['comment'] = RepoComment(payload['comment'], None)
80+
payload['comment'] = RepoComment(payload['comment'], session)
8181
return payload
8282

8383

84-
def _follow(payload):
85-
from github3.users import User
84+
def _follow(payload, session):
85+
from .users import User
8686
if payload.get('target'):
87-
payload['target'] = User(payload['target'], None)
87+
payload['target'] = User(payload['target'], session)
8888
return payload
8989

9090

91-
def _forkev(payload):
92-
from github3.repos import Repository
91+
def _forkev(payload, session):
92+
from .repos import Repository
9393
if payload.get('forkee'):
94-
payload['forkee'] = Repository(payload['forkee'], None)
94+
payload['forkee'] = Repository(payload['forkee'], session)
9595
return payload
9696

9797

98-
def _gist(payload):
99-
from github3.gists import Gist
98+
def _gist(payload, session):
99+
from .gists import Gist
100100
if payload.get('gist'):
101-
payload['gist'] = Gist(payload['gist'], None)
101+
payload['gist'] = Gist(payload['gist'], session)
102102
return payload
103103

104104

105-
def _issuecomm(payload):
106-
from github3.issues import Issue
107-
from github3.issues.comment import IssueComment
105+
def _issuecomm(payload, session):
106+
from .issues import Issue
107+
from .issues.comment import IssueComment
108108
if payload.get('issue'):
109-
payload['issue'] = Issue(payload['issue'], None)
109+
payload['issue'] = Issue(payload['issue'], session)
110110
if payload.get('comment'):
111-
payload['comment'] = IssueComment(payload['comment'], None)
111+
payload['comment'] = IssueComment(payload['comment'], session)
112112
return payload
113113

114114

115-
def _issueevent(payload):
116-
from github3.issues import Issue
115+
def _issueevent(payload, session):
116+
from .issues import Issue
117117
if payload.get('issue'):
118-
payload['issue'] = Issue(payload['issue'], None)
118+
payload['issue'] = Issue(payload['issue'], session)
119119
return payload
120120

121121

122-
def _member(payload):
123-
from github3.users import User
122+
def _member(payload, session):
123+
from .users import User
124124
if payload.get('member'):
125-
payload['member'] = User(payload['member'], None)
125+
payload['member'] = User(payload['member'], session)
126126
return payload
127127

128128

129-
def _pullreqev(payload):
130-
from github3.pulls import PullRequest
129+
def _pullreqev(payload, session):
130+
from .pulls import PullRequest
131131
if payload.get('pull_request'):
132-
payload['pull_request'] = PullRequest(payload['pull_request'], None)
132+
payload['pull_request'] = PullRequest(payload['pull_request'],
133+
session)
133134
return payload
134135

135136

136-
def _pullreqcomm(payload):
137-
from github3.pulls import ReviewComment
138-
if payload.get('comment'):
139-
payload['comment'] = ReviewComment(payload['comment'], None)
137+
def _pullreqcomm(payload, session):
138+
from .pulls import PullRequest, ReviewComment
139+
# Transform the Pull Request attribute
140+
pull = payload.get('pull_request')
141+
if pull:
142+
payload['pull_request'] = PullRequest(pull, session)
143+
144+
# Transform the Comment attribute
145+
comment = payload.get('comment')
146+
if comment:
147+
payload['comment'] = ReviewComment(comment, session)
140148
return payload
141149

142150

143-
def _release(payload):
144-
from github3.repos.release import Release
151+
def _release(payload, session):
152+
from .repos.release import Release
145153
release = payload.get('release')
146154
if release:
147-
payload['release'] = Release(release)
155+
payload['release'] = Release(release, session)
148156
return payload
149157

150158

151-
def _team(payload):
152-
from github3.orgs import Team
153-
from github3.repos import Repository
154-
from github3.users import User
159+
def _team(payload, session):
160+
from .orgs import Team
161+
from .repos import Repository
162+
from .users import User
155163
if payload.get('team'):
156-
payload['team'] = Team(payload['team'], None)
164+
payload['team'] = Team(payload['team'], session)
157165
if payload.get('repo'):
158-
payload['repo'] = Repository(payload['repo'], None)
159-
if payload.get('user'):
160-
payload['user'] = User(payload['user'], None)
166+
payload['repo'] = Repository(payload['repo'], session)
167+
if payload.get('sender'):
168+
payload['sender'] = User(payload['sender'], session)
161169
return payload
162170

163171

164-
def identity(x):
172+
def identity(x, session):
165173
return x
166174

167175

@@ -177,7 +185,7 @@ def identity(x):
177185
'IssueCommentEvent': _issuecomm,
178186
'IssuesEvent': _issueevent,
179187
'MemberEvent': _member,
180-
'PublicEvent': lambda x: '',
188+
'PublicEvent': identity,
181189
'PullRequestEvent': _pullreqev,
182190
'PullRequestReviewCommentEvent': _pullreqcomm,
183191
'PushEvent': identity,

github3/gists/comment.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
"""
99
from __future__ import unicode_literals
1010

11-
from github3.models import BaseComment
12-
from github3.users import User
11+
from ..models import BaseComment
12+
from ..users import User
1313

1414

1515
class GistComment(BaseComment):

github3/gists/file.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
from __future__ import unicode_literals
99

10-
from github3.models import GitHubObject
10+
from ..models import GitHubObject
1111

1212

1313
class GistFile(GitHubObject):

github3/gists/gist.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
from __future__ import unicode_literals
1010

1111
from json import dumps
12-
from github3.models import GitHubCore
13-
from github3.decorators import requires_auth
14-
from github3.gists.comment import GistComment
15-
from github3.gists.file import GistFile
16-
from github3.gists.history import GistHistory
17-
from github3.users import User
12+
from ..models import GitHubCore
13+
from ..decorators import requires_auth
14+
from .comment import GistComment
15+
from .file import GistFile
16+
from .history import GistHistory
17+
from ..users import User
1818

1919

2020
class Gist(GitHubCore):

0 commit comments

Comments
 (0)
0