#NEWLINE# def dispatch_hook( key , hooks , hook_data , **kwargs ) : #NEWLINE# #INDENT# 'Dispatches a hook dictionary on a given piece of data.' #NEWLINE# hooks = ( hooks or dict ( ) ) #NEWLINE# hooks = hooks . get ( key ) #NEWLINE# if hooks : #NEWLINE# #INDENT# if hasattr ( hooks , '__call__' ) : #NEWLINE# #INDENT# hooks = [ kwargs ] #NEWLINE# #UNINDENT# for hook in hooks : #NEWLINE# #INDENT# _hook_data = hook ( hook_data , ** kwargs ) #NEWLINE# if ( _hook_data is not None ) : #NEWLINE# #INDENT# hook_data = _hook_data #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return hook_data