1
2
Fork 0
mirror of https://github.com/mat-1/azalea.git synced 2025-08-02 23:44:38 +00:00
azalea/codegen/lib/utils.py
2022-05-24 23:05:44 -05:00

15 lines
291 B
Python

import re
def to_snake_case(name: str):
s = re.sub('([A-Z])', r'_\1', name)
return s.lower().strip('_')
def to_camel_case(name: str):
s = re.sub('_([a-z])', lambda m: m.group(1).upper(), name)
return s[0].upper() + s[1:]
def padded_hex(n: int):
return f'0x{n:02x}'