| 41 | |
| 42 | |
| 43 | class UTF8StreamEncoder: |
| 44 | def __init__(self, iterator): |
| 45 | self._iterator = iterator |
| 46 | |
| 47 | def __iter__(self): |
| 48 | return self |
| 49 | |
| 50 | def next(self): |
| 51 | return self.__next__() |
| 52 | |
| 53 | def __next__(self): |
| 54 | res = next(self._iterator) |
| 55 | if isinstance(res, str): |
| 56 | res = res.encode('utf-8') |
| 57 | return res |
| 58 | |
| 59 | def close(self): |
| 60 | if is_closable_iterator(self._iterator): |
| 61 | self._iterator.close() |
| 62 | |
| 63 | def __getattr__(self, attr): |
| 64 | if attr.startswith('__'): |
| 65 | raise AttributeError(self, attr) |
| 66 | return getattr(self._iterator, attr) |
| 67 | |
| 68 | |
| 69 | class ResponseEncoder: |
no outgoing calls
no test coverage detected
searching dependent graphs…