If type_ is a subclass of self.exc and value has attributes matching self.attrs, raise ResourceDenied. Otherwise let the exception propagate (if any).
(self, type_=None, value=None, traceback=None)
| 51 | return self |
| 52 | |
| 53 | def __exit__(self, type_=None, value=None, traceback=None): |
| 54 | """If type_ is a subclass of self.exc and value has attributes matching |
| 55 | self.attrs, raise ResourceDenied. Otherwise let the exception |
| 56 | propagate (if any).""" |
| 57 | if type_ is not None and issubclass(self.exc, type_): |
| 58 | for attr, attr_value in self.attrs.items(): |
| 59 | if not hasattr(value, attr): |
| 60 | break |
| 61 | if getattr(value, attr) != attr_value: |
| 62 | break |
| 63 | else: |
| 64 | raise ResourceDenied("an optional resource is not available") |
| 65 | |
| 66 | # Context managers that raise ResourceDenied when various issues |
| 67 | # with the internet connection manifest themselves as exceptions. |
nothing calls this directly
no test coverage detected