Coverage for mcp_chatkit_widget / naming.py: 100%

9 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2025-12-11 06:37 +0000

1"""Helper utilities for widget naming conventions.""" 

2 

3 

4def _sanitize_tool_name(widget_name: str) -> str: 

5 """Convert widget names into safe snake_case identifiers.""" 

6 sanitized = widget_name.lower().replace(" ", "_").replace("-", "_") 

7 sanitized = "".join(c for c in sanitized if c.isalnum() or c == "_") 

8 if sanitized and sanitized[0].isdigit(): 

9 sanitized = "_" + sanitized 

10 return sanitized 

11 

12 

13def _to_camel_case(snake_str: str) -> str: 

14 """Convert a snake_case string into CamelCase.""" 

15 components = snake_str.split("_") 

16 return "".join(x.title() for x in components)