Generate a `AddEvent` object from a string
551648
def from_str(string):
        
        match = re.match(r'^ADD (\w+)$', string)
        if match:
            return AddEvent(match.group(1))
        else:
            raise EventParseError
69984
function simulateEvent(target_object, event_type) {
  if (!exists(target_object)) {
    throw new TypeError('simulateEvent: target object must be defined');
  }

  if (typeof event_type !== 'string') {
    throw new TypeError('simulateEvent: event type must be a string');
  }

  var event = setupEvent(event_type);
  fireEvent(target_object, event, event_type);
}
354973
def add_event(self, key, event):
        """"""
        assert isinstance(key, str)
        assert isinstance(event, bytes)
        self.conn.execute('INSERT INTO events(uuid,event) VALUES (?,?)',
                          (key, event.decode('utf-8')))
327609
def GetFormattedEventObject(cls, event):
    
    time_string = timelib.Timestamp.CopyToIsoFormat(event.timestamp)

    lines_of_text = [
        '+-' * 40,
        '[Timestamp]:',
        '  {0:s}'.format(time_string)]

    pathspec = getattr(event, 'pathspec', None)
    if pathspec:
      lines_of_text.append('[Pathspec]:')
      attribute_string = pathspec.comparable.replace('\n', '\n  ')
      attribute_string = '  {0:s}\n'.format(attribute_string)
      lines_of_text.append(attribute_string)

    # TODO: add support for event tag after event clean up.

    lines_of_text.append('[Reserved attributes]:')
    out_additional = ['[Additional attributes]:']

    for attribute_name, attribute_value in sorted(event.GetAttributes()):
      if attribute_name not in definitions.RESERVED_VARIABLE_NAMES:
        attribute_string = '  {{{0!s}}} {1!s}'.format(
            attribute_name, attribute_value)
        out_additional.append(attribute_string)

      elif attribute_name not in ('pathspec', 'tag'):
        attribute_string = '  {{{0!s}}} {1!s}'.format(
            attribute_name, attribute_value)
        lines_of_text.append(attribute_string)

    lines_of_text.append('')
    out_additional.append('')

    lines_of_text.extend(out_additional)
    return '\n'.join(lines_of_text)
11906
function addEvent(el, e, callback, capture) {
    if (el.addEventListener) {
      el.addEventListener(e, callback, capture || false);
    }
    else
      if (el.attachEvent) {
        el.attachEvent('on' + e, callback);
      }
  }
76879
function genWeexHandler (params, handlerCode) {
  var innerHandlerCode = handlerCode;
  var exps = params.filter(function (exp) { return simplePathRE.test(exp) && exp !== '$event'; });
  var bindings = exps.map(function (exp) { return ({ '@binding': exp }); });
  var args = exps.map(function (exp, i) {
    var key = "$_" + (i + 1);
    innerHandlerCode = innerHandlerCode.replace(exp, key);
    return key
  });
  args.push('$event');
  return '{\n' +
    "handler:function(" + (args.join(',')) + "){" + innerHandlerCode + "},\n" +
    "params:" + (JSON.stringify(bindings)) + "\n" +
    '}'
}
1097877
@Override
	public ITraceEvent createEvent(String rawEventText, int sourceLineNumber) throws IntraceException {
		
		if (rawEventText==null){
			return null;
		}
		String parts[] = rawEventText.split("~");
		rawEventText = parts[0];
		StackTraceElement[] stackTrace = null;
		if (parts.length==2) {
			stackTrace = parseStackTrace(parts[1]);
		}

		int indexOfLastColon = rawEventText.lastIndexOf(TOKEN_COLON);
		if (indexOfLastColon==-1) {
			throw new RuntimeException("1000 Major exception.  To separate parts of a date, there should be multiple colons in this event text, but found zero [" + rawEventText + "]");
		}
		sourceLineNumber = -1; //Input sourceLineNumber is ignored.  -1 is default used if trace event doesn't have line number, which probably means agent wasn't configured to provide it.
		
		//If the character to the left of the last colon is a curly, 
		//then the text to the right of the last colon is the source line number.
		char isCurlyBrace = rawEventText.charAt(indexOfLastColon-1);
		if (isCurlyBrace==ENTRY_MARKER || isCurlyBrace==EXIT_MARKER) {
			sourceLineNumber = Integer.parseInt(rawEventText.substring(indexOfLastColon+1));	
		} else { // then there is no line number at the end of the line, so see if there is a curly at the end of the line.
			isCurlyBrace = rawEventText.charAt(rawEventText.length()-1);
		}
		
		ITraceEvent event = null;
		if (isCurlyBrace==ENTRY_MARKER) {
			event = m_entryExitParser.createEvent(rawEventText, sourceLineNumber);
			event.setEventType(EventType.ENTRY );
		} else if (isCurlyBrace==EXIT_MARKER) {
			event = m_entryExitParser.createEvent(rawEventText, sourceLineNumber);
			event.setEventType(EventType.EXIT );
		} else {
			event = m_otherParser.createEvent(rawEventText, sourceLineNumber);
		}
		
		event.setStackTrace(stackTrace);
		return event;
	}
106090
def display_event(div, attributes=[]):
    
    style = 'float: left; clear: left; font-size: 10pt'
    return CustomJS(args=dict(div=div), code="""
        var attrs = %s;
        var args = [];
        for (var i = 0; i<attrs.length; i++ ) {
            var val = JSON.stringify(cb_obj[attrs[i]], function(key, val) {
                return val.toFixed ? Number(val.toFixed(2)) : val;
            })
            args.push(attrs[i] + '=' + val)
        }
        var line = "<span style=%r><b>" + cb_obj.event_name + "</b>(" + args.join(", ") + ")</span>\\n";
        var text = div.text.concat(line);
        var lines = text.split("\\n")
        if (lines.length > 35)
            lines.shift();
        div.text = lines.join("\\n");
    """ % (attributes, style))
79983
function (eventName, data) {
      if (document.createEvent) {
        var evt = document.createEvent('HTMLEvents');
        evt.initEvent(eventName, true, false);
        evt = this.extend(evt, data);
        return this.each(function (v) {
          return v.dispatchEvent(evt);
        });
      }
    }
276370
private void parseEvent(JsonObject event, Parser parser, int i) {

        JsonElement nameJE = event.get(Event.KEY_NAME);

        if (nameJE != null) {

            String name = nameJE.getAsString();

            if (MessageSentEvent.TYPE.equals(name)) {
                MessageSentEvent parsed = parser.parse(event, MessageSentEvent.class);
                messageSent.add(parsed);
                map.put(i, parsed);
            } else if (MessageDeliveredEvent.TYPE.equals(name)) {
                MessageDeliveredEvent parsed = parser.parse(event, MessageDeliveredEvent.class);
                messageDelivered.add(parsed);
                map.put(i, parsed);
            } else if (MessageReadEvent.TYPE.equals(name)) {
                MessageReadEvent parsed = parser.parse(event, MessageReadEvent.class);
                messageRead.add(parsed);
                map.put(i, parsed);
            }
        }
    }
702705
function CustomEvent(type, params) {
  const e = document.createEvent('CustomEvent');

  if (params) {
    e.initCustomEvent(type, params.bubbles, params.cancelable, params.detail);
  } else {
    e.initCustomEvent(type, false, false, undefined);
  }

  return e;
}
658704
def keyevent2tuple(event):
    """"""
    return (event.type(), event.key(), event.modifiers(), event.text(),
            event.isAutoRepeat(), event.count())
1039196
def create_event(id, category, text, extras)
      event = {}
      event['id'] = id
      event['ctime'] = Time.now.to_i * 1000
      event['category'] = category
      event['text'] = text
      event.merge!(extras) { |_key, v1, _v2| v1 }

      http_post('/events', event)
    end
32861
def _AddEvents(cls, Class):
        
        def make_event(event):
            return property(lambda self: self._GetDefaultEventHandler(event),
                             lambda self, Value: self._SetDefaultEventHandler(event, Value))
        for event in dir(Class):
            if not event.startswith('_'):
                setattr(cls, 'On%s' % event, make_event(event))
                cls._EventNames.append(event)
355903
def add_event(self, event):
        
        if not isinstance(event, event_pb2.Event):
            raise TypeError("Expected an event_pb2.Event proto, "
                            " but got %s" % type(event))
        self._async_writer.write(event.SerializeToString())
17041
def create_event_object(self,
                            event_type,
                            code,
                            value,
                            timeval=None):
        """"""
        if not timeval:
            timeval = self.__get_timeval()
        try:
            event_code = self.manager.codes['type_codes'][event_type]
        except KeyError:
            raise UnknownEventType(
                "We don't know what kind of event a %s is." % event_type)
        event = struct.pack(EVENT_FORMAT,
                            timeval[0],
                            timeval[1],
                            event_code,
                            code,
                            value)
        return event
290852
def addinterval(instr, add, interval):
    '''
        
    '''
    if not isinstance(instr, str):
        instr = str(instr)

    return add.join(
        instr[i:i+interval]
        for i in xrange(0,len(instr),interval))