Convert a string into camelCase. Args: string (:obj:`str`): The string to convert to camelCase. Returns: :obj:`str`: The camelCased string.
(string: str)
| 36 | return re.sub(r"_$", "", string) if not trailing_underscore else string |
| 37 | |
| 38 | def camelcase(string: str) -> str: |
| 39 | """Convert a string into camelCase. |
| 40 | |
| 41 | Args: |
| 42 | string (:obj:`str`): |
| 43 | The string to convert to camelCase. |
| 44 | |
| 45 | Returns: |
| 46 | :obj:`str`: The camelCased string. |
| 47 | """ |
| 48 | import re |
| 49 | if not string: |
| 50 | return "" |
| 51 | # Turn into snake_case, then remove "_" and capitalize first letter |
| 52 | string = "".join(f"{s[0].upper()}{s[1:].lower()}" |
| 53 | for s in re.split(r'_', snakecase(string)) if s) |
| 54 | # Make first letter lower |
| 55 | return f"{string[0].lower()}{string[1:]}" if string else "" |
| 56 | |
| 57 | def remove_commas(s): |
| 58 | if isinstance(s, str): |
no test coverage detected