Add a new dispatching token as with statement. Parameters ---------- token : str The dispatching token. Returns ------- res : Any The context with new dispatching token.
(self, token: str)
| 417 | return decorator.dispatch_token |
| 418 | |
| 419 | def with_dispatch_token(self, token: str): |
| 420 | """Add a new dispatching token as with statement. |
| 421 | |
| 422 | Parameters |
| 423 | ---------- |
| 424 | token : str |
| 425 | The dispatching token. |
| 426 | |
| 427 | Returns |
| 428 | ------- |
| 429 | res : Any |
| 430 | The context with new dispatching token. |
| 431 | """ |
| 432 | |
| 433 | self.dispatch_tokens.append(token) |
| 434 | enter_func = dispatch.get(token=token, type_name="enter_token", default=lambda *args: None) |
| 435 | context = enter_func(self) |
| 436 | |
| 437 | def pop_token(): |
| 438 | exit_func = dispatch.get( |
| 439 | token=token, type_name="exit_token", default=lambda *args: None |
| 440 | ) |
| 441 | exit_func(self, context) |
| 442 | self.dispatch_tokens.pop() |
| 443 | |
| 444 | return _deferred(pop_token) |
| 445 | |
| 446 | def set_class_context(self, class_name: str, is_base_py_module: bool = False): |
| 447 | """Set the current class context for parsing. |
no test coverage detected