Returns a string in a nagios "checkresults" compatible format
518981
def _format_checkresult(**kwargs):
    
    o = {}
    o['check_type'] = '1'
    o['check_options'] = '0'
    o['scheduled_check'] = '1'
    o['reschedule_check'] = '1'
    o['latency'] = '0.0'
    o['start_time'] = '%5f' % time.time()
    o['finish_time'] = '%5f' % time.time()
    o['early_timeout'] = '0'
    o['exited_ok'] = '1'
    o['long_plugin_output'] = ''
    o['performance_data'] = ''
    o.update(locals())
    o.update(kwargs)
    del o['kwargs']
    del o['o']

    template = _host_check_result
    # Escape all linebreaks if we have them
    for k, v in o.items():
        if isinstance(v, basestring) and '\n' in v:
            o[k] = v.replace('\n', '\\n')

    # Livestatus returns slightly different output than status.dat
    # Lets normalize everything to status.dat format
    if 'name' in o and not 'host_name' in o:
        o['host_name'] = o['name']
    if 'state' in o and not 'return_code' in o:
        o['return_code'] = o['state']
    if 'description' in o and not 'service_description' in o:
        o['service_description'] = o['description']
    if not o['performance_data'] and 'perf_data' in o:
        o['performance_data'] = o['perf_data']

    # If this is a service (as opposed to host) lets add service_description field in out putput
    if 'service_description' in o:
        template += "service_description={service_description}\n"
    if not o['performance_data'].endswith('\\n'):
        o['performance_data'] += '\\n'

    # Format the string and return
    return template.format(**o) + '\n'
1069267
private static String notReadyToString(Iterable<HasMetadata> resources) {
    StringBuilder sb = new StringBuilder();
    sb.append("Resources that are not ready: ");
    boolean first = true;
    for (HasMetadata r : resources) {
      if (first) {
        first = false;
      } else {
        sb.append(", ");
      }
      sb.append("[Kind:").append(r.getKind())
        .append(" Name:").append(r.getMetadata().getName())
        .append(" Namespace:").append(r.getMetadata().getNamespace())
        .append("]");
    }
    return sb.toString();
  }
749483
def show_results(results, n=10):
    
    import nntoolkit.evaluate
    classification = nntoolkit.evaluate.show_results(results, n)
    return "<pre>" + classification.replace("\n", "<br/>") + "</pre>"
1182629
function getResult(matcherName, pass, ...messageWithPlaceholderValues) {
  const formattedMessage = format.apply(this, messageWithPlaceholderValues);
  messages[matcherName] = formattedMessage; // Save {not} message for later use
  return {
    pass,
    message: formattedMessage.replace(' {not}', pass ? ' not' : '')
  };
}
476832
function normalizeResult(result) {
  if (result.uri) {
    console.log('normalizing', result);
    if (!result._source) {
      result._source = {};
    }
    ['title', 'timestamp', 'uri', 'annotationSummary', 'annotations', 'visitors'].forEach(function(f) {
      result._source[f] = result[f];
    });
  }
  return result;
}
1229998
def __chopStringDict(self, data):
        ''''''

        r = {}
        d = data.split('\t')

        for item in d:
            item_parts = item.split('::')
            if len(item_parts) == 2:
                (name, value) = item_parts
            else:
                name = item_parts[0]
                value = item_parts[1]

            name = self.__filter(name)
            r[name] = value

        if "hostperfdata" in r:
            r["type"] = "hostcheck"
            r["perfdata"] = r["hostperfdata"]
            r["checkcommand"] = re.search("(.*?)!\(?.*", r["hostcheckcommand"]).group(1)
            r["name"] = "hostcheck"
        else:
            r["type"] = "servicecheck"
            r["perfdata"] = r["serviceperfdata"]
            r["checkcommand"] = re.search("((.*)(?=\!)|(.*))", r["servicecheckcommand"]).group(1)
            r["name"] = self.__filter(r["servicedesc"])

        r["hostname"] = self.replacePeriod(self.__filter(r["hostname"]))

        return r
515284
def to_s
      string = ''

      string += 'ws'
      string += 's' if self.secure
      string += '://'
      string += self.host
      string += ':' + self.port.to_s if self.port
      string += self.resource_name || '/'

      return string
    end
1361646
def _get_result_string(self, key):
        

        row, col, tab = key

        result_obj = self.grid.code_array[row, col, tab]

        try:
            # Numpy object arrays are converted because of numpy repr bug
            result_obj = result_obj.tolist()

        except AttributeError:
            pass

        return unicode(result_obj)
932717
public String resultToString(int res) {
        String resultString = "";
        switch (res) {
            case POSSIBLE:
                resultString = "Certificate to be tried.\n";
                break;
            case BACK:
                resultString = "Certificate backed out since path does not "
                    + "satisfy build requirements.\n";
                break;
            case FOLLOW:
                resultString = "Certificate satisfies conditions.\n";
                break;
            case FAIL:
                resultString = "Certificate backed out since path does not "
                    + "satisfy conditions.\n";
                break;
            case SUCCEED:
                resultString = "Certificate satisfies conditions.\n";
                break;
            default:
                resultString = "Internal error: Invalid step result value.\n";
        }
        return resultString;
    }
1049866
def _groups_or_na_fun(regex):
    """"""
    if regex.groups == 0:
        raise ValueError("pattern contains no capture groups")
    empty_row = [np.nan] * regex.groups

    def f(x):
        if not isinstance(x, str):
            return empty_row
        m = regex.search(x)
        if m:
            return [np.nan if item is None else item for item in m.groups()]
        else:
            return empty_row
    return f
241439
def progress_string(self):
        """"""

        if not self.last_result:
            return self._status_string()

        def location_string(hostname, pid):
            if hostname == os.uname()[1]:
                return "pid={}".format(pid)
            else:
                return "{} pid={}".format(hostname, pid)

        pieces = [
            "{}".format(self._status_string()), "[{}]".format(
                self.resources.summary_string()), "[{}]".format(
                    location_string(
                        self.last_result.get(HOSTNAME),
                        self.last_result.get(PID))), "{} s".format(
                            int(self.last_result.get(TIME_TOTAL_S)))
        ]

        if self.last_result.get(TRAINING_ITERATION) is not None:
            pieces.append("{} iter".format(
                self.last_result[TRAINING_ITERATION]))

        if self.last_result.get(TIMESTEPS_TOTAL) is not None:
            pieces.append("{} ts".format(self.last_result[TIMESTEPS_TOTAL]))

        if self.last_result.get(EPISODE_REWARD_MEAN) is not None:
            pieces.append("{} rew".format(
                format(self.last_result[EPISODE_REWARD_MEAN], ".3g")))

        if self.last_result.get(MEAN_LOSS) is not None:
            pieces.append("{} loss".format(
                format(self.last_result[MEAN_LOSS], ".3g")))

        if self.last_result.get(MEAN_ACCURACY) is not None:
            pieces.append("{} acc".format(
                format(self.last_result[MEAN_ACCURACY], ".3g")))

        return ", ".join(pieces)
448865
function formatErrors (results) {
    return ''; 

    var failCount = results.fail.length;
    var past = (failCount === 1) ? 'was' : 'were';
    var plural = (failCount === 1) ? 'failure' : 'failures';

    var out = '\n' + pad(format.red.bold('Failed Tests:') + ' There ' + past + ' ' + format.red.bold(failCount) + ' ' + plural + '\n');
    out += formatFailedAssertions(results);

    return out;
  }
764208
static function transformGetFunctionsResults( $results, $rname, $method = '' )
    {
        switch( $rname )
        {
            case 'system.listMethods':
                foreach ( $results as $key => $value )
                {
                    $results[$key] = preg_replace( array( '/^([^ ]+ )/', '/(\(.+)$/' ), '', $value );
                }
                return $results;
                break;
            case 'system.methodHelp':
                return ''; /// @todo
                break;
            case 'system.methodSignature':
                foreach ( $results as $key => $value )
                {
                    if ( preg_match( '/^([^ ]+) ([^\(]+)\((.+)\)$/', $value, $matches ) )
                    {
                        if ( $method == $matches[2] )
                        {
                            $params = array( $matches[1] );
                            foreach( explode( ', ', $matches[3] ) as $param )
                            {
                                $param = explode( ' ', $param, 2 );
                                $name = substr( $param[1], 1); // php likes dollars in var names
                                $params[$name] = $param[0];
                            }
                            return array( $params );
                        }
                    }
                }
                return array(); /// @todo return error 'method not found'
                break;
        } // switch
    }
1268678
def get(method, hmc, uri, uri_parms, logon_required):
        """"""
        query_str = uri_parms[0]
        try:
            console = hmc.consoles.lookup_by_oid(None)
        except KeyError:
            raise InvalidResourceError(method, uri)
        result_password_rules = []
        filter_args = parse_query_parms(method, uri, query_str)
        for password_rule in console.password_rules.list(filter_args):
            result_password_rule = {}
            for prop in password_rule.properties:
                if prop in ('element-uri', 'name', 'type'):
                    result_password_rule[prop] = password_rule.properties[prop]
            result_password_rules.append(result_password_rule)
        return {'password-rules': result_password_rules}
661628
def get_results(self):
        

        return {'status': self.status,
                'error_msg': self.error_msg,
                'k': self.k,
                'x': self.x,
                'lam': self.lam*self.obj_sca,
                'nu': self.nu*self.obj_sca,
                'mu': self.mu*self.obj_sca,
                'pi': self.pi*self.obj_sca}
1012812
function(results, filename, options) {
        "use strict";
        if (results.messages.length > 0 || !options.quiet) {
            this.json.push({
                filename: filename,
                messages: results.messages,
                stats: results.stats
            });
        }
        return "";
    }
296753
def get_ok_results(self, verbose=True):
        
        if len(self.trials) == 0:
            return []

        not_ok = np.where(np.array(self.statuses()) != "ok")[0]

        if len(not_ok) > 0 and verbose:
            print("{0}/{1} trials were not ok.".format(len(not_ok), len(self.trials)))
            print("Trials: " + str(not_ok))
            print("Statuses: " + str(np.array(self.statuses())[not_ok]))

        r = [merge_dicts({"tid": t["tid"]}, t["result"].to_dict())
             for t in self.trials if t["result"]["status"] == "ok"]
        return r