def _register_handler(event, fun, external=False):
    """Register a function to be an event handler"""
    registry = core.HANDLER_REGISTRY
    if external:
        registry = core.EXTERNAL_HANDLER_REGISTRY

    if not isinstance(event, basestring):
        # If not basestring, it is a BaseEvent subclass.
        # This occurs when class methods are registered as handlers
        event = core.parse_event_to_name(event)

    if event in registry:
        registry[event].append(fun)
    else:
        registry[event] = [fun]
    return fun
def _register_handler ( event , fun , external = False ) : registry = core . HANDLER_REGISTRY if external : registry = core . EXTERNAL_HANDLER_REGISTRY if not isinstance ( event , basestring ) : event = core . parse_event_to_name ( event ) if event in registry : registry [ event ] . append ( fun ) else : registry [ event ] = [ fun ] return fun
Register a function to be an event handler