<s> from Dart . sublime_plugin_lib import PluginLogger <EOL> _logger = PluginLogger ( __name__ ) <EOL> class EventSource ( object ) : <EOL> ON_PUB_BUILD = '<STR_LIT>' <EOL> ON_DART_RUN = '<STR_LIT>' <EOL> ON_INSTALL = '<STR_LIT>' <EOL> handlers = { <EOL> ON_PUB_BUILD : [ ] , <EOL> ON_DART_RUN : [ ] , <EOL> } <EOL> def raise_event ( self , source , name , * args , ** kwargs ) : <EOL> for handler in EventSource . handlers . get ( name , [ ] ) : <EOL> handler ( source . __class__ . __qualname__ , * args , ** kwargs ) <EOL> def add_event_handler ( self , name , func ) : <EOL> if name not in EventSource . handlers : <EOL> raise KeyError ( '<STR_LIT>' . format ( name ) ) <EOL> if func not in EventSource . handlers [ name ] : <EOL> EventSource . handlers [ name ] . append ( func ) </s>
