#NEWLINE# def _autofill_config( config_path , config , metadata , **kwargs ) : #NEWLINE# #INDENT# 'autofill config by metadata.' #NEWLINE# generals = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# specified = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( key , value ) in metadata . items ( ) : #NEWLINE# #INDENT# if key . startswith ( '$' ) : #NEWLINE# #INDENT# generals [ key ] = value #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if key . startswith ( '_' ) : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# specified [ key ] = value #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# config_keys = set ( config . keys ( ) ) #NEWLINE# specified_keys = set ( specified . keys ( ) ) #NEWLINE# intersect_keys = ( config_keys & specified_keys ) #NEWLINE# not_found_keys = ( config_keys - specified_keys ) #NEWLINE# redundant_keys = ( specified_keys - config_keys ) #NEWLINE# for key in redundant_keys : #NEWLINE# #INDENT# self_config = _autofill_self_config ( ( '%s/%s' % ( config_path , key ) ) , key , None , specified [ key ] , ** kwargs ) #NEWLINE# if ( self_config is not None ) : #NEWLINE# #INDENT# config [ key ] = self_config #NEWLINE# #UNINDENT# #UNINDENT# for key in intersect_keys : #NEWLINE# #INDENT# config [ key ] = _autofill_self_config ( ( '%s/%s' % ( config_path , key ) ) , key , config [ key ] , specified [ key ] , ** kwargs ) #NEWLINE# #UNINDENT# for key in not_found_keys : #NEWLINE# #INDENT# for ( general_key , general_value ) in generals . items ( ) : #NEWLINE# #INDENT# config [ key ] = _autofill_self_config ( ( '%s/%s' % ( config_path , key ) ) , key , config [ key ] , general_value , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# return config