def snake2ucamel(value):
UNDER, LETTER, OTHER = object(), object(), object()<EOL>def group_key_function(char):<EOL><INDENT>if char == "<STR_LIT:_>":<EOL><INDENT>return UNDER<EOL><DEDENT>if char in string.ascii_letters:<EOL><INDENT>return LETTER<EOL><DEDENT>return OTHER<EOL><DEDENT>def process_group(idx, key, chars):<EOL><INDENT>if key is LETTER:<EOL><INDENT>return "<STR_LIT>".join([chars[<NUM_LIT:0>].upper()] + chars[<NUM_LIT:1>:])<EOL><DEDENT>if key is OTHERor len(chars) != <NUM_LIT:1>or idx in [<NUM_LIT:0>, last]or LETTER not in (groups[idx-<NUM_LIT:1>][<NUM_LIT:1>], groups[idx+<NUM_LIT:1>][<NUM_LIT:1>]):<EOL><INDENT>return "<STR_LIT>".join(chars)<EOL><DEDENT>return "<STR_LIT>"<EOL><DEDENT>raw_groups_gen = itertools.groupby(value, key=group_key_function)<EOL>groups = [(idx, key, list(group_gen))<EOL>for idx, (key, group_gen) in enumerate(raw_groups_gen)]<EOL>last = len(groups) - <NUM_LIT:1><EOL>return "<STR_LIT>".join(itertools.starmap(process_group, groups))<EOL>
Casts a snake_case string to an UpperCamelCase string.