#NEWLINE# def merge_dicts( base , updates ) : #NEWLINE# #INDENT# "\n    Recursively merge dict ``updates`` into dict ``base`` (mutating ``base``.)\n\n    * Values which are themselves dicts will be recursed into.\n    * Values which are a dict in one input and *not* a dict in the other input\n      (e.g. if our inputs were ``{'foo': 5}`` and ``{'foo': {'bar': 5}}``) are\n      irreconciliable and will generate an exception.\n    " #NEWLINE# for ( key , value ) in updates . items ( ) : #NEWLINE# #INDENT# if ( key in base ) : #NEWLINE# #INDENT# if isinstance ( value , dict ) : #NEWLINE# #INDENT# if isinstance ( base [ key ] , dict ) : #NEWLINE# #INDENT# merge_dicts ( base [ key ] , value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise _merge_error ( base [ key ] , value ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( base [ key ] , dict ) : #NEWLINE# #INDENT# raise _merge_error ( base [ key ] , value ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# base [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# base [ key ] = value