Determines the conditional formatted message strings.

    Args:
      event_values (dict[str, object]): event values.

    Returns:
      tuple(str, str): formatted message string and short message string.
974168
def _ConditionalFormatMessages(self, event_values):
    
    # Using getattr here to make sure the attribute is not set to None.
    # if A.b = None, hasattr(A, b) is True but getattr(A, b, None) is False.
    string_pieces = []
    for map_index, attribute_name in enumerate(self._format_string_pieces_map):
      if not attribute_name or attribute_name in event_values:
        if attribute_name:
          attribute = event_values.get(attribute_name, None)
          # If an attribute is an int, yet has zero value we want to include
          # that in the format string, since that is still potentially valid
          # information. Otherwise we would like to skip it.
          # pylint: disable=unidiomatic-typecheck
          if (not isinstance(attribute, (bool, float)) and
              not isinstance(attribute, py2to3.INTEGER_TYPES) and
              not attribute):
            continue

        string_pieces.append(self.FORMAT_STRING_PIECES[map_index])

    format_string = self.FORMAT_STRING_SEPARATOR.join(string_pieces)

    string_pieces = []
    for map_index, attribute_name in enumerate(
        self._format_string_short_pieces_map):
      if not attribute_name or event_values.get(attribute_name, None):
        string_pieces.append(self.FORMAT_STRING_SHORT_PIECES[map_index])
    short_format_string = self.FORMAT_STRING_SEPARATOR.join(string_pieces)

    return self._FormatMessages(
        format_string, short_format_string, event_values)
890649
private static String formatString(String message, Object[] values) {
        if (Checker.isNotEmpty(message)) {
            if (Checker.isNotEmpty(values)) {
                return StrUtil.format(String.format(message, values), values);
            }
            return message;
        }
        return ValueConsts.EMPTY_STRING;
    }
1341597
def events(self):
        ''''''
        ret = []
        while True:
            e = self.poll()
            if e is None:
                break
            ret.append(e)
        return ret
1264494
def WriteEventBody(self, event):
    
    output_values = []
    for field_name in self._fields:
      output_value = self._dynamic_fields_helper.GetFormattedField(
          event, field_name)

      output_value = self._SanitizeField(output_value)
      output_values.append(output_value)

    output_line = '{0:s}\n'.format(self._field_delimiter.join(output_values))
    self._output_writer.Write(output_line)
329993
def GetFormattedField(self, event, field_name):
    
    callback_name = self._FIELD_FORMAT_CALLBACKS.get(field_name, None)
    callback_function = None
    if callback_name:
      callback_function = getattr(self, callback_name, None)

    if callback_function:
      output_value = callback_function(event)
    else:
      output_value = getattr(event, field_name, '-')

    if output_value is None:
      output_value = '-'

    elif not isinstance(output_value, py2to3.STRING_TYPES):
      output_value = '{0!s}'.format(output_value)

    return output_value
366045
def bind_events(self, events):
        '''
        '''
        evs = self._events
        if evs and events:
            for event in evs.values():
                if event.name in events:
                    event.bind(events[event.name])
436929
public String events(EventCondition condition) {
        String description = "event on: " + condition.getDataId();
        if (condition.getExpression() != null) {
            description += " [" + condition.getExpression() + "]";
        }
        return description;
    }
1338399
def _FormatSourceShort(self, event):
    
    source_short, _ = self._output_mediator.GetFormattedSources(event)
    if source_short is None:
      data_type = getattr(event, 'data_type', 'UNKNOWN')
      raise errors.NoFormatterFound(
          'Unable to find event formatter for: {0:s}.'.format(data_type))

    return source_short
391055
def on_message(self, event):
        '''
        '''

        metadata = self._parse_metadata(event)
        message = Message(text=metadata['text'],
                          metadata=metadata).__dict__
        if message.get('text'):
            message['text'] = self.find_and_replace_userids(message['text'])
            message['text'] = self.find_and_replace_channel_refs(
                message['text']
            )
        return message
1357197
def events(self):
        
        if self._events is None:
            self._events = EventList(self)
        return self._events
628126
def _msg_text(self):
        
        msg_text = u""

        if self._format:
            msg_text_fields = ["%%%\n```"]

            for event_property in self._format:
                property_value = self.event.get(event_property)
                if property_value is None:
                    self.log.warning(u"Unrecognized `%s` event property.", event_property)
                    continue
                msg_text_fields.append(
                    u"{property_name}: {property_value}".format(
                        property_name=event_property, property_value=property_value
                    )
                )

            msg_text_fields.append("```\n%%%")

            msg_text = u"\n".join(msg_text_fields)
        else:
            # Override when verbosity
            if self.event.get('Message'):
                msg_text = u"{message}\n".format(message=self.event['Message'])
            elif self.event.get('InsertionStrings'):
                msg_text = u"\n".join([i_str for i_str in self.event['InsertionStrings'] if i_str.strip()])

        if self.notify_list:
            msg_text += u"\n{notify_list}".format(notify_list=' '.join([" @" + n for n in self.notify_list]))

        return msg_text
685991
def format_message_type(message_type):
    
    if message_type == MsgType.NOT_SET:
        return "NOT_SET"
    elif message_type == MsgType.ACK:
        return "ACK"
    elif message_type == MsgType.JOIN:
        return "JOIN"
    elif message_type == MsgType.UNJOIN:
        return "UNJOIN"
    elif message_type == MsgType.CONFIG:
        return "CONFIG"
    elif message_type == MsgType.UPDATE:
        return "UPDATE"
    elif message_type == MsgType.DATA:
        return "DATA"
    else:
        return u"{}".format(message_type)
113908
def _GetMessageFileKeys(self, event_log_provider_key):
    
    table_names = ['message_file_per_event_log_provider']
    column_names = ['message_file_key']
    condition = 'event_log_provider_key == {0:d}'.format(
        event_log_provider_key)

    generator = self._database_file.GetValues(
        table_names, column_names, condition)
    for values in generator:
      yield values['message_file_key']
1218219
def print_prompt_values(values, message=None, sub_attr=None):
    """"""
    if message:
        prompt_message(message)

    for index, entry in enumerate(values):
        if sub_attr:
            line = '{:2d}: {}'.format(index, getattr(utf8(entry), sub_attr))
        else:
            line = '{:2d}: {}'.format(index, utf8(entry))

        with indent(3):
            print_message(line)
441605
def _GetFlagValues(self, flags):
    
    event_types = []
    for event_flag, description in self._FLAG_VALUES.items():
      if event_flag & flags:
        event_types.append(description)
    return ', '.join(event_types)
598954
def iter_event_vars(self):
        

        # pylint: disable=invalid-name
        ns = '{urn:schemas-upnp-org:service-1-0}'
        scpd_body = requests.get(self.base_url + self.scpd_url).text
        tree = XML.fromstring(scpd_body.encode('utf-8'))
        # parse the state variables to get the relevant variable types
        statevars = tree.findall('{}stateVariable'.format(ns))
        for state in statevars:
            # We are only interested if 'sendEvents' is 'yes', i.e this
            # is an eventable variable
            if state.attrib['sendEvents'] == "yes":
                name = state.findtext('{}name'.format(ns))
                vartype = state.findtext('{}dataType'.format(ns))
                yield (name, vartype)
453273
def check_message(keywords, message):
    
    exc_type, exc_value, exc_traceback = sys.exc_info()
    if set(str(exc_value).split(" ")).issuperset(set(keywords)):
        exc_value.message = message
        raise