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

Commitf8487f7

Browse files
authored
Merge pull requestsigmavirus24#774 from omgjlk/send-the-session-771
Ensure a session is passed through to GitHubCore
2 parents6e110c5 +c8e256c commitf8487f7

22 files changed

+59
-51
lines changed

‎github3/events.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,15 @@ def _update_attributes(self, event):
119119
event=copy.deepcopy(event)
120120

121121
#: :class:`User <github3.users.User>` object representing the actor.
122-
self.actor=self._class_attribute(event,'actor',EventUser)
122+
self.actor=self._class_attribute(event,'actor',EventUser,self)
123123
#: datetime object representing when the event was created.
124124
self.created_at=self._strptime_attribute(event,'created_at')
125125

126126
#: Unique id of the event
127127
self.id=self._get_attribute(event,'id')
128128

129129
#: List all possible types of Events
130-
self.org=self._class_attribute(event,'org',EventOrganization)
130+
self.org=self._class_attribute(event,'org',EventOrganization,self)
131131

132132
#: Event type https://developer.github.com/v3/activity/events/types/
133133
self.type=self._get_attribute(event,'type')

‎github3/gists/gist.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class GistFork(GitHubCore):
314314
def_update_attributes(self,fork):
315315
self.created_at=self._strptime(fork['created_at'])
316316
self.id=fork['id']
317-
self.owner=users.ShortUser(fork['user'])
317+
self.owner=users.ShortUser(fork['user'],self)
318318
self.updated_at=self._strptime(fork['updated_at'])
319319
self.url=self._api=fork['url']
320320

‎github3/git.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _update_attributes(self, ref):
108108
self.ref=self._get_attribute(ref,'ref')
109109

110110
#: :class:`GitObject <GitObject>` the reference points to
111-
self.object=self._class_attribute(ref,'object',GitObject)
111+
self.object=self._class_attribute(ref,'object',GitObject,self)
112112

113113
def_repr(self):
114114
return'<Reference [{0}]>'.format(self.ref)
@@ -173,7 +173,7 @@ def _update_attributes(self, tag):
173173
self.tagger=self._get_attribute(tag,'tagger')
174174

175175
#: :class:`GitObject <GitObject>` for the tag
176-
self.object=self._class_attribute(tag,'object',GitObject)
176+
self.object=self._class_attribute(tag,'object',GitObject,self)
177177

178178
def_repr(self):
179179
return'<Tag [{0}]>'.format(self.tag)
@@ -193,7 +193,7 @@ def _update_attributes(self, tree):
193193
#: list of :class:`Hash <Hash>` objects
194194
self.tree=self._get_attribute(tree,'tree', [])
195195
ifself.tree:
196-
self.tree= [Hash(t)fortinself.tree]
196+
self.tree= [Hash(t,self)fortinself.tree]
197197

198198
def_repr(self):
199199
return'<Tree [{0}]>'.format(self.sha)

‎github3/github.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class GitHub(GitHubCore):
5757
"""
5858

5959
def__init__(self,username='',password='',token=''):
60-
super(GitHub,self).__init__({})
60+
super(GitHub,self).__init__({},self.new_session())
6161
iftoken:
6262
self.login(username,token=token)
6363
elifusernameandpassword:
@@ -80,7 +80,7 @@ def add_email_addresses(self, addresses=[]):
8080
ifaddresses:
8181
url=self._build_url('user','emails')
8282
json=self._json(self._post(url,data=addresses),201)
83-
return [users.Email(email)foremailinjson]ifjsonelse []
83+
return [users.Email(email,self)foremailinjson]ifjsonelse []
8484

8585
defall_events(self,number=-1,etag=None):
8686
"""Iterate over public events.
@@ -1795,7 +1795,7 @@ class GitHubStatus(GitHubCore):
17951795
return the JSON objects returned by the API.
17961796
"""
17971797
def__init__(self):
1798-
super(GitHubStatus,self).__init__({})
1798+
super(GitHubStatus,self).__init__({},self.new_session())
17991799
self.session.base_url='https://status.github.com'
18001800

18011801
def_repr(self):

‎github3/issues/issue.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ def _update_attributes(self, issue):
3434
#: was assigned to.
3535
self.assignee=issue['assignee']
3636
ifself.assignee:
37-
self.assignee=users.ShortUser(self.assignee)
37+
self.assignee=users.ShortUser(self.assignee,self)
3838
self.assignees=issue['assignees']
3939
ifself.assignees:
4040
self.assignees= [
41-
users.ShortUser(assignee)forassigneeinself.assignees
41+
users.ShortUser(assignee,self)forassigneeinself.assignees
4242
]
4343

4444
#: Body (description) of the issue.
@@ -107,7 +107,7 @@ def _update_attributes(self, issue):
107107
self.updated_at=self._strptime_attribute(issue,'updated_at')
108108

109109
#: :class:`User <github3.users.User>` who opened the issue.
110-
self.user=users.ShortUser(issue['user'])
110+
self.user=users.ShortUser(issue['user'],self)
111111

112112
def_repr(self):
113113
return'<Issue [{r[0]}/{r[1]} #{n}]>'.format(r=self.repository,
@@ -389,4 +389,4 @@ def _update_attributes(self, issue):
389389
#: :class:`User <github3.users.User>` who closed the issue.
390390
self.closed_by=issue['closed_by']
391391
ifself.closed_by:
392-
self.closed_by=users.ShortUser(self.closed_by)
392+
self.closed_by=users.ShortUser(self.closed_by,self)

‎github3/models.py‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,10 @@ class GitHubCore(object):
3333
"""
3434
_ratelimit_resource='core'
3535

36-
def__init__(self,json,session=None):
36+
def__init__(self,json,session):
3737
ifhasattr(session,'session'):
3838
# i.e. session is actually a GitHubCore instance
3939
session=session.session
40-
elifsessionisNone:
41-
session=GitHubSession()
4240
self.session=session
4341

4442
# set a sane default
@@ -166,14 +164,14 @@ def __repr__(self):
166164
returnrepr_string
167165

168166
@classmethod
169-
deffrom_dict(cls,json_dict):
167+
deffrom_dict(cls,json_dict,session):
170168
"""Return an instance of this class formed from ``json_dict``."""
171-
returncls(json_dict)
169+
returncls(json_dict,session)
172170

173171
@classmethod
174-
deffrom_json(cls,json):
172+
deffrom_json(cls,json,session):
175173
"""Return an instance of this class formed from ``json``."""
176-
returncls(loads(json))
174+
returncls(loads(json),session)
177175

178176
def__eq__(self,other):
179177
returnself._uniq==other._uniq
@@ -349,6 +347,10 @@ def refresh(self, conditional=False):
349347
self._update_attributes(json)
350348
returnself
351349

350+
defnew_session(self):
351+
"""Helper function to generate a new session"""
352+
returnGitHubSession()
353+
352354

353355
classBaseComment(GitHubCore):
354356

‎github3/pulls.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class PullDestination(models.GitHubCore):
2424
http://developer.github.com/v3/pulls/#get-a-single-pull-request
2525
"""
2626

27-
def__init__(self,dest,direction):
28-
super(PullDestination,self).__init__(dest)
27+
def__init__(self,dest,direction,session=None):
28+
super(PullDestination,self).__init__(dest,session)
2929
from .repos.repoimportShortRepository
3030
#: Direction of the merge with respect to this destination
3131
self.direction=direction
@@ -36,7 +36,7 @@ def __init__(self, dest, direction):
3636
#: :class:`User <github3.users.User>` representing the owner
3737
self.user=None
3838
ifdest.get('user'):
39-
self.user=users.ShortUser(dest.get('user'),None)
39+
self.user=users.ShortUser(dest.get('user'),self)
4040
#: SHA of the commit at the head
4141
self.sha=dest.get('sha')
4242
self._repo_name=''
@@ -118,7 +118,7 @@ def _update_attributes(self, pull):
118118
self._api=pull['url']
119119

120120
#: Base of the merge
121-
self.base=PullDestination(pull['base'],'Base')
121+
self.base=PullDestination(pull['base'],'Base',self)
122122

123123
#: Body of the pull request message
124124
self.body=pull['body']
@@ -136,7 +136,7 @@ def _update_attributes(self, pull):
136136
self.created_at=self._strptime_attribute(pull,'created_at')
137137

138138
#: The new head after the pull request
139-
self.head=PullDestination(pull['head'],'Head')
139+
self.head=PullDestination(pull['head'],'Head',self)
140140

141141
#: The unique id of the pull request
142142
self.id=self._get_attribute(pull,'id')
@@ -175,7 +175,7 @@ def _update_attributes(self, pull):
175175

176176
#: :class:`User <github3.users.ShortUser>` object representing the
177177
#: creator of the pull request
178-
self.user=users.ShortUser(pull['user'])
178+
self.user=users.ShortUser(pull['user'],self)
179179

180180
# This is only present if the PR has been assigned.
181181
#: :class:`User <github3.users.ShortUser>` object representing the

‎github3/repos/comparison.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _update_attributes(self, compare):
6969
#: objects.
7070
self.commits=self._get_attribute(compare,'commits', [])
7171
ifself.commits:
72-
self.commits= [RepoCommit(com)forcominself.commits]
72+
self.commits= [RepoCommit(com,self)forcominself.commits]
7373

7474
#: List of dicts describing the files modified.
7575
self.files=self._get_attribute(compare,'files', [])

‎github3/repos/pages.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ def _update_attributes(self, build):
3737
from ..importusers
3838
#: :class:`User <github3.users.User>` representing who pushed the
3939
#: commit
40-
self.pusher=self._class_attribute(build,'pusher',users.ShortUser)
40+
self.pusher=self._class_attribute(build,'pusher',users.ShortUser,
41+
self)
4142

4243
#: SHA of the commit that triggered the build
4344
self.commit=self._get_attribute(build,'commit')

‎github3/repos/release.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def _update_attributes(self, release):
6565

6666
#: :class:`User <github3.users.ShortUser>` object representing the
6767
#: creator of the release
68-
self.author=users.ShortUser(release['author'])
68+
self.author=users.ShortUser(release['author'],self)
6969

7070
#: URLs to various attributes
7171
forurltypein ['assets_url','html_url','tarball_url',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp