def _convert_key(name): # camelCase to BIG_SNAKE while preserving acronyms, i.e. # FooBARs -> FOO_BARS (and not FOO_BA_RS) name = re.sub(r'([A-Z])([A-Z]+)', lambda m: m.group(1) + m.group(2).lower(), name) name = snakify(name).upper() special_cases = {'PDFLATEX_PROGRAM': 'XELATEX_PATH', 'IS_ROOM_BOOKING_ACTIVE': 'ENABLE_ROOMBOOKING'} return special_cases.get(name, name)
def test_snakify(input, output): assert snakify(input) == output