def wrap(impl, number=None): if impl is None: return None if number is None: number = pn_event_type(impl) event = Event(impl, number) # check for an application defined ApplicationEvent and return that. This # avoids an expensive wrap operation invoked by event.context if pn_event_class(impl) == PN_PYREF and \ isinstance(event.context, EventBase): return event.context else: return event
def wrap(impl): if impl is None: return None number = pn_event_type(impl) cls = pn_event_class(impl) if cls: clsname = pn_class_name(cls) context = wrappers[clsname](pn_event_context(impl)) # check for an application defined ApplicationEvent and return that. This # avoids an expensive wrap operation invoked by event.context if cls == PN_PYREF and isinstance(context, EventBase): return context else: clsname = None event = Event(impl, number, clsname, context) return event