#NEWLINE# def register_listener( self , event , func ) : #NEWLINE# #INDENT# 'Add a function as a listener for the specified event.\n        ' #NEWLINE# wrapped_func = self . _set_log_level_and_params ( logging . WARNING , func ) #NEWLINE# cls = self . __class__ #NEWLINE# if ( ( cls . listeners is None ) or ( cls . _raw_listeners is None ) ) : #NEWLINE# #INDENT# cls . _raw_listeners = defaultdict ( list ) #NEWLINE# cls . listeners = defaultdict ( list ) #NEWLINE# #UNINDENT# if ( func not in cls . _raw_listeners [ event ] ) : #NEWLINE# #INDENT# cls . _raw_listeners [ event ] . append ( func ) #NEWLINE# cls . listeners [ event ] . append ( wrapped_func )