Partially format a format_string, swapping out any '{methodname}' or '{methodnamehyphen}' components.
434324
def replace_methodname(format_string, methodname):
    

    methodnamehyphen = methodname.replace('_', '-')
    ret = format_string
    ret = ret.replace('{methodname}', methodname)
    ret = ret.replace('{methodnamehyphen}', methodnamehyphen)
    return ret
1097318
def safe_trim(qty_as_string):
    '''
    
    '''
    qty_formatted = qty_as_string
    if '.' in qty_as_string:
        # only affect numbers with decimals
        while True:
            if qty_formatted[-1] == '0' and qty_formatted[-2] != '.':
                qty_formatted = qty_formatted[:-1]
            else:
                break

    return qty_formatted
676962
def format_all(format_string, env):
    

    prepared_env = parse_pattern(format_string, env, lambda x, y: [FormatWrapper(x, z) for z in y])
    # Generate each possible combination, format the string with it and yield
    # the resulting string:
    for field_values in product(*prepared_env.itervalues()):
        format_env = dict(izip(prepared_env.iterkeys(), field_values))
        yield format_string.format(**format_env)
14522
def _format_from_dict(self, format_string, **kwargs):
        
        kwargs_copy = self.base_dict.copy()
        kwargs_copy.update(**kwargs)
        localpath = format_string.format(**kwargs_copy)
        if kwargs.get('fullpath', False):
            return self.fullpath(localpath=localpath)
        return localpath
870705
function(url, params, formatFunction) {

		if (params) {

			// Set default formatting function
			formatFunction = formatFunction || encodeURIComponent;

			// Override the items in the URL which already exist
			for (var x in params) {
				var str = '([\\?\\&])' + x + '=[^\\&]*';
				var reg = new RegExp(str);
				if (url.match(reg)) {
					url = url.replace(reg, '$1' + x + '=' + formatFunction(params[x]));
					delete params[x];
				}
			}
		}

		if (!this.isEmpty(params)) {
			return url + (url.indexOf('?') > -1 ? '&' : '?') + this.param(params, formatFunction);
		}

		return url;
	}
35416
def format(self, formatstring, *args):
        """"""

        # Make a new section
        if self.incoming_section:
            self.SendMessage(['s', {'name': args}])
            self.incoming_section = False
1003011
def _reformat_docstring(doc, format_fn, code_newline=""):
    
    out = []
    status = {"listing": False, "add_line": False, "eat_line": False}
    code = False
    for line in doc:
        if status["add_line"]:
            out.append("\n")
        status["add_line"] = False
        if status["eat_line"]:
            status["eat_line"] = False
            if line.strip() == "":
                continue
        # check for start/end of code block
        if line.strip() == "```":
            code = not code
            out.append(line + code_newline)
            continue
        if not code:
            # if we are in a block listing a blank line ends it
            if line.rstrip() == "":
                status["listing"] = False
            # format the line
            line = format_fn(line, status)
            # see if block start
            if re_listing.match(line):
                status["listing"] = True
        out.append(line.rstrip() + "\n")
    return out
1158547
public static void formatForConsole(StringBuilder buf, int width, Collection<TrackedParameter> options) {
    for(TrackedParameter pair : options) {
      Parameter<?> par = pair.getParameter();
      println(buf//
          .append(SerializedParameterization.OPTION_PREFIX).append(par.getOptionID().getName()) //
          .append(' ').append(par.getSyntax()).append(FormatUtil.NEWLINE), //
          width, getFullDescription(par));
    }
  }
280861
def _format_str(format_int):
    """"""
    for dictionary in _formats, _subtypes, _endians:
        for k, v in dictionary.items():
            if v == format_int:
                return k
    else:
        return 'n/a'
311128
def _GetFormatter(self, format_str):
        
        formatter, args, func_type = self.formatters.LookupWithType(format_str)
        if formatter:
            return formatter, args, func_type
        else:
            raise BadFormatter('%r is not a valid formatter' % format_str)
343658
function stringFormat(source) {
        var args = arguments;
        return source.replace(
            /\{([0-9]+)\}/g,
            function (match, index) {
                return args[index - 0 + 1];
            });
    }
1097646
function format(string) {
  string = _.toString(string);

  // Replace all code snippets with a token.
  var snippets = [];
  string = string.replace(reCode, function(match) {
    snippets.push(match);
    return token;
  });

  return string
    // Add line breaks.
    .replace(/:\n(?=[\t ]*\S)/g, ':<br>\n')
    .replace(/\n( *)[-*](?=[\t ]+\S)/g, '\n<br>\n$1*')
    .replace(/^[\t ]*\n/gm, '<br>\n<br>\n')
    // Normalize whitespace.
    .replace(/\n +/g, ' ')
    // Italicize parentheses.
    .replace(/(^|\s)(\(.+\))/g, '$1*$2*')
    // Mark numbers as inline code.
    .replace(/[\t ](-?\d+(?:.\d+)?)(?!\.[^\n])/g, ' `$1`')
    // Replace all tokens with code snippets.
    .replace(reToken, function(match) {
      return snippets.shift();
    })
    .trim();
}
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;
    }
612677
function getFormattedValues (formatString, rawValues) {
      var formattedValueString = formatString;
      var rawValuesLength = rawValues.length;

      for (var i = 0; i < rawValuesLength; i++) {
        formattedValueString = formattedValueString.replace(
          VALUE_PLACEHOLDER, +rawValues[i].toFixed(4));
      }

      return formattedValueString;
    }
1362017
def format_hooks(self, hooks):
        '''
        
        '''
        str_hooks = [str(i).split()[0].strip('<') for i in hooks]
        return [i.split('.')[-1] for i in str_hooks if '.' in i]
1140413
def string_format
      (command_environment.map do |key, value|
        [key, value].join("=")
      end + [command]).join(" ")
    end
815866
def _format_extname(self, ext):
        """"""
        if ext is None:
            outs = ext
        else:
            outs = '{0},{1}'.format(ext[0], ext[1])
        return outs