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

Commit5a838d2

Browse files
committed
Progress towards pengwynn/octokit like behavior
This lets us store the ETag for calls to endpoints that we return asiterators. It is an awesome little bit of python.
1 parent4fb1575 commit5a838d2

File tree

2 files changed

+5
-23
lines changed

2 files changed

+5
-23
lines changed

‎github3/models.py

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -139,35 +139,17 @@ def api(self):
139139
defapi(self,uri):
140140
self._uri=urlparse(uri)
141141

142-
def_iter(self,count,url,cls,params=None):
142+
def_iter(self,count,url,cls,params=None,etag=None):
143143
"""Generic iterator for this project.
144144
145145
:param int count: How many items to return.
146146
:param int url: First URL to start with
147147
:param class cls: cls to return an object of
148148
:param params dict: (optional) Parameters for the request
149+
:param str etag: (optional), ETag from the last call
149150
"""
150-
while (count==-1orcount>0)andurl:
151-
response=self._get(url,params=params)
152-
ifparams:
153-
params=None# rel_next contains the params
154-
json=self._json(response,200)
155-
156-
ifjsonisNone:
157-
break
158-
159-
# languages returns a single dict. We want the items.
160-
ifisinstance(json,dict):
161-
json=json.items()
162-
163-
foriinjson:
164-
yieldcls(i,self)ifissubclass(cls,GitHubCore)elsecls(i)
165-
count-=1ifcount>0else0
166-
ifcount==0:
167-
break
168-
169-
rel_next=response.links.get('next', {})
170-
url=rel_next.get('url','')
151+
fromgithub3.structsimportGitHubIterable
152+
returnGitHubIterable(count,url,cls,params,etag)
171153

172154
@property
173155
defratelimit_remaining(self):

‎github3/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def __init__(self, user, session=None):
121121
self.plan=Plan(user.get('plan', {}))
122122

123123
def__repr__(self):
124-
return'<User [{0}:{1}]>'.format(self.login,self.name)
124+
return'<User [{0}:{1:s}]>'.format(self.login,self.name)
125125

126126
def__str__(self):
127127
returnself.login

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp