Subscribe a callable to the .changed signal, but only for a specified list of options. The callable should accept arguments (options, updated), and may raise an OptionsError. The event will automatically be unsubscribed if the callable goes out of scope.
(self, func, opts)
| 145 | raise e |
| 146 | |
| 147 | def subscribe(self, func, opts): |
| 148 | """ |
| 149 | Subscribe a callable to the .changed signal, but only for a |
| 150 | specified list of options. The callable should accept arguments |
| 151 | (options, updated), and may raise an OptionsError. |
| 152 | |
| 153 | The event will automatically be unsubscribed if the callable goes out of scope. |
| 154 | """ |
| 155 | for i in opts: |
| 156 | if i not in self._options: |
| 157 | raise exceptions.OptionsError("No such option: %s" % i) |
| 158 | |
| 159 | self._subscriptions.append((signals.make_weak_ref(func), set(opts))) |
| 160 | |
| 161 | def _notify_subscribers(self, updated) -> None: |
| 162 | cleanup = False |