Format messages for collectd to consume.
486899
def formatter(self, key, value):
        
        template = "PUTVAL {host}/fedmsg/fedmsg_wallboard-{key} " +\
            "interval={interval} {timestamp}:{value}"
        timestamp = int(time.time())
        interval = self.hub.config['collectd_interval']
        return template.format(
            host=self.host,
            timestamp=timestamp,
            value=value,
            interval=interval,
            key=key,
        )
452097
def _split_message(self, message):
        
        if len(message) == 3:
            return message
        else:
            # get_more and kill_cursors messages don't include BSON documents.
            request_id, data = message
            return request_id, data, 0
1255041
def format_usage(self, ctx, formatter):
        """"""
        pieces = self.collect_usage_pieces(ctx)
        formatter.write_usage(ctx.command_path, ' '.join(pieces))
725446
private String formatMessage(final String message) {
        if (null != reformatter) {
            return reformatter.reformat(context, message);
        } else {
            return message;
        }
    }
222709
function messageFormat (type, inspect) {
  var msg = this.detailed
    ? 'expect %s `%s`, but %s `%s` given'
    : 'expect `%s`, but `%s` given'
  return this.detailed
    ? util.format(msg, type.expected, inspect.expected, type.actual, inspect.actual)
    : util.format(msg, type.expected, type.actual)
}
182188
def run(self):
        """"""
        for msg in self.messages:
            col = getattr(msg, 'col', 0)
            yield msg.lineno, col, (msg.tpl % msg.message_args), msg.__class__
816274
def build_messages_metrics(messages):
    """"""
    count_types = collections.Counter(
        line.get('type') or None
        for line in messages)
    count_modules = collections.Counter(
        line.get('module') or None
        for line in messages)
    count_symbols = collections.Counter(
        line.get('symbol') or None
        for line in messages)
    count_paths = collections.Counter(
        line.get('path') or None
        for line in messages)

    return {
        'types': count_types,
        'modules': count_modules,
        'symbols': count_symbols,
        'paths': count_paths,
    }
25691
def format(collection, **params):
    """"""
    binary = io.BytesIO()
    with tarfile.TarFile(fileobj=binary, mode='w') as tar:
        mode = params.get('mode', 0o640)
        now = calendar.timegm(datetime.datetime.utcnow().timetuple())
        for filename, content in collection:
            content_type, encoding = mimetypes.guess_type(filename)
            content = content_types.get(content_type).format(content, **params)
            content = content_encodings.get(encoding).encode(content)
            member_content = io.BytesIO(content)
            member_info = tarfile.TarInfo(filename)
            member_info.size = len(content)
            member_info.mode = mode
            member_info.mtime = now
            tar.addfile(member_info, member_content)
    binary.seek(0)
    return binary.read()
425168
def format(collection, **params):
    """"""
    binary = io.BytesIO()
    with zipfile.ZipFile(binary, 'w') as zip_:
        now = datetime.datetime.utcnow().timetuple()
        for filename, content in collection:
            content_type, encoding = mimetypes.guess_type(filename)
            content = content_types.get(content_type).parse(content, **params)
            content = content_encodings.get(encoding).decode(content)
            zip_info = zipfile.ZipInfo(filename, now)
            zip_info.file_size = len(content)
            zip_.writestr(zip_info, content)
    binary.seek(0)
    return binary.read()
78224
def format_message(severity, datetime, progname, msg)
      if String === msg then
        msg.inject('') { |s, line| s << super(severity, datetime, progname, line.chomp) }
      else
        super
      end
    end
1120550
function (msg) {
    var self = this;
    if (! _.has(msg, 'collection')) {
      return '';
    } else if (typeof(msg.collection) === 'string') {
      if (msg.collection === '')
        throw Error("Message has empty collection!");
      return msg.collection;
    } else {
      throw Error("Message has non-string collection!");
    }
  }
319696
function MessageFormatter() {
  this.format = format;
  function format(result) {
    _.each(result, function(message) {
      console.log(message);
    });
  }
}
578315
def format_msg(external_id, external_id_prop, wdid, msg, msg_type=None, delimiter=";"):
    
    fmt = ('{}' + delimiter) * 4 + '{}'  # '{};{};{};{};{}'
    d = {'external_id': external_id,
         'external_id_prop': external_id_prop,
         'wdid': wdid,
         'msg': msg,
         'msg_type': msg_type}
    for k, v in d.items():
        if isinstance(v, str) and delimiter in v and '"' in v:
            v = v.replace('"', "'")
        if isinstance(v, str) and delimiter in v:
            d[k] = '"' + v + '"'

    s = fmt.format(d['external_id'], d['external_id_prop'], d['wdid'], d['msg'], d['msg_type'])
    return s
1339043
def generate_messages_info(msgs):
    """"""

    for msg in msgs:
        msg.swift_name = camel_case_from_underscores(msg.name)

        msg.formatted_description = ""
        if msg.description:
            msg.description = " ".join(msg.description.split())
            msg.formatted_description = "\n/**\n    %s\n*/\n" % " ".join(msg.description.split())
        msg.message_description = msg.description.replace('"','\\"')

        for field in msg.ordered_fields:
            field.swift_name = lower_camel_case_from_underscores(field.name)
            field.return_type = swift_types[field.type][0]
            
            # configure fields initializers
            if field.enum:
                # handle enums
                field.return_type = camel_case_from_underscores(field.enum)
                field.initial_value = "try data.mavEnumeration(offset: %u)" % field.wire_offset
            elif field.array_length > 0:
                if field.return_type == "String":
                    # handle strings
                    field.initial_value = "data." + swift_types[field.type][2] % (field.wire_offset, field.array_length)
                else:
                    # other array types
                    field.return_type = "[%s]" % field.return_type
                    field.initial_value = "try data.mavArray(offset: %u, count: %u)" % (field.wire_offset, field.array_length)
            else:
                # simple type field
                field.initial_value = "try data." + swift_types[field.type][2] % field.wire_offset
            
            field.formatted_description = ""
            if field.description:
                field.description = " ".join(field.description.split())
                field.formatted_description = "\n\t/// " + field.description + "\n"
         
        fields_info = map(lambda field: '("%s", %u, "%s", "%s")' % (field.swift_name, field.wire_offset, field.return_type, field.description.replace('"','\\"')), msg.fields)
        msg.fields_info = ", ".join(fields_info)

    msgs.sort(key = lambda msg : msg.id)
115097
def _set_format(self, msg):
        
        num_points = msg.height * msg.width
        self._format = '<' + num_points * 'ffff'
1335272
function (message) {
    var objs = [], collector = '', chr, msglen, data;

    this.data += message;
    data = new Buffer(this.data, 'utf8');

    for (var i = 0; i < data.length; i += 1) {
        chr = data[i];
        if (chr > 47 && chr < 58) {
            collector += String.fromCharCode(chr);
        } else if (chr !== 10 && chr !== 13) {
            msglen = parseInt(collector, 10);

            if (msglen + i <= data.length) {
              objs.push(JSON.parse(data.toString('utf8', i, msglen + i)));
              data = data.slice(i + msglen);
              collector = '';
              i = 0;
            } else {
              break;
            }
        }
    }
    this.data = data.toString('utf8');
    return objs;
}
204744
def format(self, record):
        """"""
        record = ColoredRecord(record)
        record.log_color = self.color(self.log_colors, record.levelname)

        # Set secondary log colors
        if self.secondary_log_colors:
            for name, log_colors in self.secondary_log_colors.items():
                color = self.color(log_colors, record.levelname)
                setattr(record, name + '_log_color', color)

        # Format the message
        if sys.version_info > (2, 7):
            message = super(ColoredFormatter, self).format(record)
        else:
            message = logging.Formatter.format(self, record)

        # Add a reset code to the end of the message
        # (if it wasn't explicitly added in format str)
        if self.reset and not message.endswith(escape_codes['reset']):
            message += escape_codes['reset']

        if '|' in message:
            desc, data = message.split("|", 1)
            desc = desc + escape_codes['reset']
            data = escape_codes['green'] + data
            message = desc + '|' + data

        return message