equal
deleted
inserted
replaced
195 error may happen. Python 3 already works around that. |
195 error may happen. Python 3 already works around that. |
196 ''' |
196 ''' |
197 |
197 |
198 def __init__(self, fp): |
198 def __init__(self, fp): |
199 self.fp = fp |
199 self.fp = fp |
|
200 self.throttle = not pycompat.ispy3 and fp.isatty() |
200 |
201 |
201 def __getattr__(self, key): |
202 def __getattr__(self, key): |
202 return getattr(self.fp, key) |
203 return getattr(self.fp, key) |
203 |
204 |
204 def close(self): |
205 def close(self): |
206 self.fp.close() |
207 self.fp.close() |
207 except IOError: |
208 except IOError: |
208 pass |
209 pass |
209 |
210 |
210 def write(self, s): |
211 def write(self, s): |
|
212 if not pycompat.ispy3: |
|
213 self.softspace = 0 |
211 try: |
214 try: |
|
215 if not self.throttle: |
|
216 return self.fp.write(s) |
212 # This is workaround for "Not enough space" error on |
217 # This is workaround for "Not enough space" error on |
213 # writing large size of data to console. |
218 # writing large size of data to console. |
214 limit = 16000 |
219 limit = 16000 |
215 l = len(s) |
220 l = len(s) |
216 start = 0 |
221 start = 0 |
217 self.softspace = 0 |
|
218 while start < l: |
222 while start < l: |
219 end = start + limit |
223 end = start + limit |
220 self.fp.write(s[start:end]) |
224 self.fp.write(s[start:end]) |
221 start = end |
225 start = end |
222 except IOError as inst: |
226 except IOError as inst: |