mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2024-11-21 22:56:38 +01:00
03d2359061
Co-authored-by: poolitzer <github@poolitzer.eu> Co-authored-by: Hinrich Mahler <22366557+Bibo-Joshi@users.noreply.github.com> Co-authored-by: Harshil <37377066+harshil21@users.noreply.github.com> Co-authored-by: aelkheir <arelkheir@gmail.com> Co-authored-by: aelkheir <90580077+aelkheir@users.noreply.github.com>
15 lines
527 B
Python
15 lines
527 B
Python
import re
|
|
|
|
|
|
def to_camel_case(snake_str):
|
|
"""https://stackoverflow.com/a/19053800"""
|
|
components = snake_str.split("_")
|
|
# We capitalize the first letter of each component except the first one
|
|
# with the 'title' method and join them together.
|
|
return components[0] + "".join(x.title() for x in components[1:])
|
|
|
|
|
|
def to_snake_case(camel_str):
|
|
"""https://stackoverflow.com/a/1176023"""
|
|
name = re.sub("(.)([A-Z][a-z]+)", r"\1_\2", camel_str)
|
|
return re.sub("([a-z0-9])([A-Z])", r"\1_\2", name).lower()
|