

def parse_event_packet(self, packet):
    try:
        name_and_metadata = packet.split(':', 1)
        if (len(name_and_metadata) != 2):
            raise Exception(('Unparseable event packet: %s' % packet))
        name = name_and_metadata[0]
        metadata = name_and_metadata[1]
        (title_length, text_length) = name.split(',')
        title_length = int(title_length[3:])
        text_length = int(text_length[:(- 1)])
        event = {
            'title': metadata[:title_length],
            'text': self._unescape_event_text(metadata[(title_length + 1):((title_length + text_length) + 1)]),
        }
        meta = metadata[((title_length + text_length) + 1):]
        for m in meta.split('|')[1:]:
            if (m[0] == 't'):
                event['alert_type'] = m[2:]
            elif (m[0] == 'k'):
                event['aggregation_key'] = m[2:]
            elif (m[0] == 's'):
                event['source_type_name'] = m[2:]
            elif (m[0] == 'd'):
                event['date_happened'] = int(m[2:])
            elif (m[0] == 'p'):
                event['priority'] = m[2:]
            elif (m[0] == 'h'):
                event['hostname'] = m[2:]
            elif (m[0] == '#'):
                event['tags'] = sorted(m[1:].split(','))
        return event
    except (IndexError, ValueError):
        raise Exception(('Unparseable event packet: %s' % packet))

dataset/ETHPy150Open serverdensity/sd-agent/aggregator.py Aggregator.parse_event_packet/original