Returns the python module and obj given an event name
437600
def parse_event_name(name):
    
    try:
        app, event = name.split('.')
        return '{}.{}'.format(app, EVENTS_MODULE_NAME), event
    except ValueError:
        raise InvalidEventNameError(
            (u'The name "{}" is invalid. '
             u'Make sure you are using the "app.KlassName" format'
             ).format(name))
4439
def print_event(attributes=[]):
    
    def python_callback(event):
        cls_name = event.__class__.__name__
        attrs = ', '.join(['{attr}={val}'.format(attr=attr, val=event.__dict__[attr])
                       for attr in attributes])
        print('{cls_name}({attrs})'.format(cls_name=cls_name, attrs=attrs))
    return python_callback
336030
def named_object(name):
    """"""
    name_parts = name.split('.')
    module = named_module('.'.join(name_parts[:-1]))
    return getattr(module, name_parts[-1])
121410
def import_event_modules():
    
    for installed_app in getsetting('INSTALLED_APPS'):
        module_name = u'{}.{}'.format(installed_app, EVENTS_MODULE_NAME)
        try:
            import_module(module_name)
        except ImportError:
            pass
558304
def get_event(self, name, default=_sentinel):
        
        if name not in self.events:
            if self.create_events_on_access:
                self.add_event(name)
            elif default is not _sentinel:
                return default
        return self.events[name]
570042
def getmodule(object):
    """"""
    if ismodule(object):
        return object
    if isclass(object):
        return sys.modules.get(object.__module__)
    try:
        file = getabsfile(object)
    except TypeError:
        return None
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    for module in sys.modules.values():
        if hasattr(module, '__file__'):
            modulesbyfile[getabsfile(module)] = module.__name__
    if modulesbyfile.has_key(file):
        return sys.modules[modulesbyfile[file]]
    main = sys.modules['__main__']
    if hasattr(main, object.__name__):
        mainobject = getattr(main, object.__name__)
        if mainobject is object:
            return main
    builtin = sys.modules['__builtin__']
    if hasattr(builtin, object.__name__):
        builtinobject = getattr(builtin, object.__name__)
        if builtinobject is object:
            return builtin
905956
function (obj, eventType, eventHandler) {
			if (!obj.eventHandlers) { obj.eventHandlers = {}; }
			if (!obj.eventHandlers[eventType]) {
				obj.eventHandlers[eventType] = [];
			}
			if (eventHandler) {
				obj.eventHandlers[eventType].push(eventHandler);
			}
			return obj.eventHandlers[eventType];
		}
494441
def is_module(obj):
    
    return True if obj and isinstance(obj, ModuleType) or inspect.isclass(obj) else False
203721
def from_events(self, instance, ev_args, ctx):
        

        obj = yield from self._process(instance, ev_args, ctx)
        self.__get__(instance, type(instance)).append(obj)
        return obj
610698
def getfunc(obj, name=''):
    ''''''
    if name:
        obj = getattr(obj, name)
    return getattr(obj, '__func__', obj)
232477
function getEventObject(eventObjects, eventType, listener) {
        var i, numberOfEvents = eventObjects.length;

        for (i = 0; i < numberOfEvents; i += 1) {
            if (isValueEqualToValue(eventObjects[i].type, eventType) &&
                    isValueEqualToValue(eventObjects[i].callback, listener)) {
                return eventObjects[i];
            }
        }

        return null;
    }
1135129
def import_object(name):
    
    parts = name.split('.')
    if len(parts) < 2:
        raise ValueError("Invalid name '%s'" % name)
    module_name = ".".join(parts[:-1])
    obj_name = parts[-1]
    module = importlib.import_module(module_name)
    return getattr(module, obj_name)
1004026
def _get_event(self, event, find_str):
        """"""
        # Get the term with the given element id
        element = event.find(find_str)
        if element is None:
            return None
        element_id = element.attrib.get('id')
        element_term = self.tree.find("*[@id='%s']" % element_id)
        if element_term is None:
            return None
        time, location = self._extract_time_loc(element_term)

        # Now see if there is a modifier like assoc-with connected
        # to the main concept
        assoc_with = self._get_assoc_with(element_term)

        # Get the element's text and use it to construct a Concept
        element_text_element = element_term.find('text')
        if element_text_element is None:
            return None
        element_text = element_text_element.text
        element_db_refs = {'TEXT': element_text}
        element_name = sanitize_name(element_text)

        element_type_element = element_term.find('type')
        if element_type_element is not None:
            element_db_refs['CWMS'] = element_type_element.text
            # If there's an assoc-with, we tack it on as extra grounding
            if assoc_with is not None:
                element_db_refs['CWMS'] += ('|%s' % assoc_with)

        concept = Concept(element_name, db_refs=element_db_refs)
        if time or location:
            context = WorldContext(time=time, geo_location=location)
        else:
            context = None
        event_obj = Event(concept, context=context)
        return event_obj
162777
def _module_refs(obj, named):
    '''
    '''
     # ignore this very module
    if obj.__name__ == __name__:
        return ()
     # module is essentially a dict
    return _dict_refs(obj.__dict__, named)
1000592
def _get_module(self, line):
        """"""
        #Finding the module name is trivial; start at the beginning of
        #the module and iterate lines until we find the module.
        for sline in self._source:
            if len(sline) > 0 and sline[0] != "!":
                rmatch = self.RE_MODULE.match(sline)
                if rmatch is not None:
                    self.modulename = rmatch.group("name")
                    break
        else:
            #We don't even have the start of a module in this code file
            return
            
        #Before we carry on with the rest of the context, find the separating
        #CONTAINS keyword so we know whether to look for types or subs/funcs.
        #If the code parser hasn't ever parsed this module, parse it now.
        self.parser.isense_parse(self._orig_path, self.modulename)
        self.module = self.parser.modules[self.modulename]

        if line > self.module.contains_index:
            self.section = "contains"
725834
function(obj, name, callback, context, listening) {
    obj._events = eventsApi(onApi, obj._events || {}, name, callback, {
      context: context,
      ctx: obj,
      listening: listening
    });

    if (listening) {
      var listeners = obj._listeners || (obj._listeners = {});
      listeners[listening.id] = listening;
    }

    return obj;
  }
1243527
def find_handlers(event_name, registry=HANDLER_REGISTRY):
    
    handlers = []

    # event_name can be a BaseEvent or the string representation
    if isinstance(event_name, basestring):
        matched_events = [event for event in registry.keys()
            if fnmatch.fnmatchcase(event_name, event)]
        for matched_event in matched_events:
            handlers.extend(registry.get(matched_event))
    else:
        handlers = registry.get(find_event(event_name), [])

    return handlers