MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / to_pascal

Function to_pascal

camel/utils/commons.py:336–357  ·  view source on GitHub ↗

Convert a snake_case string to PascalCase. Args: snake (str): The snake_case string to be converted. Returns: str: The converted PascalCase string.

(snake: str)

Source from the content-addressed store, hash-verified

334
335
336def to_pascal(snake: str) -> str:
337 """Convert a snake_case string to PascalCase.
338
339 Args:
340 snake (str): The snake_case string to be converted.
341
342 Returns:
343 str: The converted PascalCase string.
344 """
345 # Check if the string is already in PascalCase
346 if re.match(r'^[A-Z][a-zA-Z0-9]*([A-Z][a-zA-Z0-9]*)*$', snake):
347 return snake
348 # Remove leading and trailing underscores
349 snake = snake.strip('_')
350 # Replace multiple underscores with a single one
351 snake = re.sub('_+', '_', snake)
352 # Convert to PascalCase
353 return re.sub(
354 '_([0-9A-Za-z])',
355 lambda m: m.group(1).upper(),
356 snake.title(),
357 )
358
359
360def get_pydantic_major_version() -> int:

Callers 1

get_openai_tool_schemaFunction · 0.90

Calls 1

subMethod · 0.45

Tested by

no test coverage detected