#NEWLINE# def flatten_blocks( lines , num_indents = ( - 1 ) ) : #NEWLINE# #INDENT# ' Takes a list (block) or string (statement) and flattens it into a string\n        with indentation.\n    ' #NEWLINE# INDENTATION = ( ' ' * 4 ) #NEWLINE# if ( not lines ) : #NEWLINE# #INDENT# return '' #NEWLINE# #UNINDENT# if isinstance ( lines , six . string_types ) : #NEWLINE# #INDENT# return ( ( INDENTATION * lines ) + lines ) #NEWLINE# #UNINDENT# return '\n' . join ( [ flatten_blocks ( line , ( num_indents + 1 ) ) for line in lines ] )