Traverse structure and attempts to close all found StreamWrappers on best effort basis.
(cls, v, depth=0)
| 314 | |
| 315 | @classmethod |
| 316 | def close_streams(cls, v, depth=0): |
| 317 | """Traverse structure and attempts to close all found StreamWrappers on best effort basis.""" |
| 318 | if depth > 10: |
| 319 | return |
| 320 | if isinstance(v, StreamWrapper): |
| 321 | v.close() |
| 322 | else: |
| 323 | # Traverse only simple structures |
| 324 | if isinstance(v, dict): |
| 325 | for vv in v.values(): |
| 326 | cls.close_streams(vv, depth=depth + 1) |
| 327 | elif isinstance(v, (list, tuple)): |
| 328 | for vv in v: |
| 329 | cls.close_streams(vv, depth=depth + 1) |
| 330 | |
| 331 | def __getattr__(self, name): |
| 332 | file_obj = self.__dict__['file_obj'] |
no test coverage detected