This only exists to be able to attach a .close method to iterators that do not support attribute assignment (most of itertools).
| 3024 | |
| 3025 | |
| 3026 | class _closeiter(object): |
| 3027 | """ This only exists to be able to attach a .close method to iterators that |
| 3028 | do not support attribute assignment (most of itertools). """ |
| 3029 | |
| 3030 | def __init__(self, iterator, close=None): |
| 3031 | self.iterator = iterator |
| 3032 | self.close_callbacks = makelist(close) |
| 3033 | |
| 3034 | def __iter__(self): |
| 3035 | return iter(self.iterator) |
| 3036 | |
| 3037 | def close(self): |
| 3038 | for func in self.close_callbacks: |
| 3039 | func() |
| 3040 | |
| 3041 | |
| 3042 | class ResourceManager(object): |
no outgoing calls
no test coverage detected
searching dependent graphs…