#NEWLINE# def substitute_variables( input_data , substitutions ) : #NEWLINE# #INDENT# '\n  Replaces variables with values from substitutions.\n  ' #NEWLINE# def f( value ) : #NEWLINE# #INDENT# if ( not isinstance ( value , basestring ) ) : #NEWLINE# #INDENT# return value #NEWLINE# #UNINDENT# new_value = Template ( value ) . safe_substitute ( substitutions ) #NEWLINE# if ( new_value != value ) : #NEWLINE# #INDENT# LOG . debug ( ( 'Substituted %s -> %s' % ( repr ( value ) , repr ( new_value ) ) ) ) #NEWLINE# #UNINDENT# return new_value #NEWLINE# #UNINDENT# return recursive_walk ( f , input_data )