<s> from collections import OrderedDict <EOL> import re <EOL> first_cap_re = re . compile ( '<STR_LIT>' ) <EOL> all_cap_re = re . compile ( '<STR_LIT>' ) <EOL> def underscoreToCamel ( match ) : <EOL> return match . group ( ) [ <NUM_LIT:0> ] + match . group ( ) [ <NUM_LIT:2> ] . upper ( ) <EOL> def camelize ( data ) : <EOL> if isinstance ( data , dict ) : <EOL> new_dict = OrderedDict ( ) <EOL> for key , value in data . items ( ) : <EOL> new_key = re . sub ( r"<STR_LIT>" , underscoreToCamel , key ) <EOL> new_dict [ new_key ] = camelize ( value ) <EOL> return new_dict <EOL> if isinstance ( data , ( list , tuple ) ) : <EOL> for i in range ( len ( data ) ) : <EOL> data [ i ] = camelize ( data [ i ] ) <EOL> return data <EOL> return data <EOL> def camel_to_underscore ( name ) : <EOL> s1 = first_cap_re . sub ( r'<STR_LIT>' , name ) <EOL> return all_cap_re . sub ( r'<STR_LIT>' , s1 ) . lower ( ) <EOL> def underscoreize ( data ) : <EOL> if isinstance ( data , dict ) : <EOL> new_dict = { } <EOL> for key , value in data . items ( ) : <EOL> new_key = camel_to_underscore ( key ) <EOL> new_dict [ new_key ] = underscoreize ( value ) <EOL> return new_dict <EOL> if isinstance ( data , ( list , tuple ) ) : <EOL> for i in range ( len ( data ) ) : <EOL> data [ i ] = underscoreize ( data [ i ] ) <EOL> return data <EOL> return data </s>
