Convert BiDi method suffix to friendly event name. Examples: "contextCreated" -> "context_created" "navigationStarted" -> "navigation_started" "userPromptOpened" -> "user_prompt_opened"
(method_suffix: str)
| 624 | |
| 625 | @staticmethod |
| 626 | def _convert_method_to_event_name(method_suffix: str) -> str: |
| 627 | """Convert BiDi method suffix to friendly event name. |
| 628 | |
| 629 | Examples: |
| 630 | "contextCreated" -> "context_created" |
| 631 | "navigationStarted" -> "navigation_started" |
| 632 | "userPromptOpened" -> "user_prompt_opened" |
| 633 | """ |
| 634 | # Convert camelCase to snake_case |
| 635 | s1 = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", method_suffix) |
| 636 | return re.sub("([a-z0-9])([A-Z])", r"\1_\2", s1).lower() |
| 637 | |
| 638 | def generate_code(self, enhancements: dict[str, Any] | None = None) -> str: |
| 639 | """Generate Python code for this module. |