comparison mercurial/url.py @ 29729:44ea12756fef

url: use `iter(callable, sentinel)` instead of while True This is functionally equivalent, but is a little more concise.
author Augie Fackler <augie@google.com>
date Fri, 05 Aug 2016 14:00:39 -0400
parents b76ea1384bf2
children f1c9fafcbf46
comparison
equal deleted inserted replaced
29728:1a29db79a98d 29729:44ea12756fef
206 206
207 while True: 207 while True:
208 version, status, reason = res._read_status() 208 version, status, reason = res._read_status()
209 if status != httplib.CONTINUE: 209 if status != httplib.CONTINUE:
210 break 210 break
211 while True: 211 # skip lines that are all whitespace
212 skip = res.fp.readline().strip() 212 list(iter(lambda: res.fp.readline().strip(), ''))
213 if not skip:
214 break
215 res.status = status 213 res.status = status
216 res.reason = reason.strip() 214 res.reason = reason.strip()
217 215
218 if res.status == 200: 216 if res.status == 200:
219 while True: 217 # skip lines until we find a blank line
220 line = res.fp.readline() 218 list(iter(res.fp.readline, '\r\n'))
221 if line == '\r\n':
222 break
223 return True 219 return True
224 220
225 if version == 'HTTP/1.0': 221 if version == 'HTTP/1.0':
226 res.version = 10 222 res.version = 10
227 elif version.startswith('HTTP/1.'): 223 elif version.startswith('HTTP/1.'):