Telethon/telethon_generator/utils.py

9 lines
298 B
Python
Raw Normal View History

import re
def snake_to_camel_case(name, suffix=None):
# Courtesy of http://stackoverflow.com/a/31531797/4759433
2018-04-14 20:04:07 +03:00
result = re.sub(r'_([a-z])', lambda m: m.group(1).upper(), name)
result = result[:1].upper() + result[1:].replace('_', '')
return result + suffix if suffix else result