value: '{x}', format_spec: 'f' -> '{x:f}'
160471
def _inject_format_spec(self, value, format_spec):
        
        t = type(value)
        return value[:-1] + t(u':') + format_spec + t(u'}')
56173
function formatValue(value) {
		
		var out;
		var type = util.sType(value);
		
		// if there is a type, check all sub items for types
		if (_.has(value, 'attributes.type') && _.has(value, '$value') && _.keys(value).length === 2) {
			out = util.moRef(value);
		}
		else if (type) {
			if (util.isArray(value)) {
				out = [];
				
				var subtype = type;
				
				if (subtype.match(/^ArrayOf/)) {
					subtype = subtype.replace(/^ArrayOf/, '');

					if (!Array.isArray(_.get(value, subtype)) && value[subtype]) {
						value[subtype] = [value[subtype]];
					}
				}
				
				_.forEach(value[_.keys(value)[1]], function(obj) {
					out.push(formatValue(obj));
				});
			}
			else if (util.isBoolean(value)) {
				
				// check for valid true values, otherwise false
				if (_.includes(['1', 'true'], _.lowerCase(value.$value))) {
					out = true;
				}
				else {
					out = false;
				}
			}
			else if (util.isInt(value)) {
				out = Number(value.$value);
			}
			else if (_.has(value, '$value')) {
				out = value.$value;
			}
			else {
				out = formatValue(_.omit(value, 'attributes'));
			}
			
		}
		else if (Array.isArray(value)) {
			out = [];
			_.forEach(value, function(val) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out.push(formatValue(val));
				}
				else {
					out.push(cast(val));
				}
			});
		}
		else if (util.hasKeys(value)) {
			out = {};
			_.forEach(value, function(val, key) {
				if (util.sType(val) || util.isArray(val) || util.hasKeys(val)) {
					out[key] = formatValue(val);
				}
				else {
					out[key] = cast(val);
				}
			});
		}
		else {
			out = cast(value);
		}
		return out;
	}
805960
def get_format_spec(self):
        '''
        
        '''
        return u"{{:{align}{width}}}".format(align=self.align, width=self.width)
1311243
function formatSpecDescription(spec) {
    const egText = spec.example ? ` (eg. "${spec.example}")` : ''
    const docsText = spec.docs ? `. See ${spec.docs}` : ''
    return `${spec.desc}${egText}${docsText}` || ''
}
527359
def _format_value(self, value):
        
        if len(value) > 0:
            if value[0] == ".":
                value = self.package + value
            else:
                v_dot = value.find(".")
                if v_dot == 0:
                    value = self.package + "." + value
                elif v_dot == -1:
                    value = self.package + "." + value
        return value
888032
def format_field(self, value, format_spec):
        """"""
        if isinstance(value, datetime) and not format_spec:
            return super().format_field(value, '%Y-%m-%d_%H-%M-%S')
        if value is None:
            return ''
        return super().format_field(value, format_spec)
646280
def format_field_by_match(self, value, match):
        """"""
        groups = match.groups()
        fill, align, sign, sharp, zero, width, comma, prec, type_ = groups
        if not comma and not prec and type_ not in list('fF%'):
            return None
        if math.isnan(value) or math.isinf(value):
            return None
        locale = self.numeric_locale
        # Format number value.
        prefix = get_prefix(sign)
        if type_ == 'd':
            if prec is not None:
                raise ValueError('precision not allowed in '
                                 'integer format specifier')
            string = format_number(value, 0, prefix, locale)
        elif type_ in 'fF%':
            format_ = format_percent if type_ == '%' else format_number
            string = format_(value, int(prec or DEFAULT_PREC), prefix, locale)
        else:
            # Don't handle otherwise.
            return None
        if not comma:
            # Formatted number always contains group symbols.
            # Remove the symbols if not required.
            string = remove_group_symbols(string, locale)
        if not (fill or align or zero or width):
            return string
        # Fix a layout.
        spec = ''.join([fill or u'', align or u'>',
                        zero or u'', width or u''])
        return format(string, spec)
1320706
def format_value(value, sf=3):
    
    if isinstance(value, str):
        return value

    elif isinstance(value, list) or isinstance(value, np.ndarray):
        value = list(value)
        for i in range(len(value)):
            vv = format_value(value[i])
            value[i] = vv
        return "[" + ", ".join(value) + "]"

    elif value is None:
        return "N/A"

    else:
        fmt_str = "{0:.%ig}" % sf
        return fmt_str.format(value)
836072
function formatStr(str, values) {
    values = values || {};

    if (typeof str !== 'string') {
        return str;
    }

    return str.replace(FORMAT_REGEXP, (m0, m1, m2) => (m1 === '%' ? "%{" + m2 + "}" : values[m2]));
}
717920
def format_field(self, value, format_spec):
        
        if format_spec:
            spec, arg = format_spec[0], format_spec[1:]
            arg = arg or None
        else:
            spec = arg = None
        return self._format_field(spec, arg, value, self.numeric_locale)
909315
def parse_format_specifier(specification):
    
    m = _parse_format_specifier_regex.match(specification)
    if m is None:
        raise ValueError(
            "Invalid format specifier: {!r}".format(specification))
    format_dict = m.groupdict('')

    # Convert zero-padding into fill and alignment.
    zeropad = format_dict.pop('zeropad')
    if zeropad:
        # If zero padding is requested, fill and align fields should be absent.
        if format_dict['align']:
            raise ValueError(
                "Invalid format specifier: {!r}".format(specification))
        # Impossible to have 'fill' without 'align'.
        assert not format_dict['fill']
        format_dict['align'] = '='
        format_dict['fill'] = '0'

    # Default alignment is right-aligned.
    if not format_dict['align']:
        format_dict['align'] = '>'

    # Default fill character is space.
    if not format_dict['fill']:
        format_dict['fill'] = ' '

    # Default sign is '-'.
    if not format_dict['sign']:
        format_dict['sign'] = '-'

    # Convert minimum width to an int; default is zero.
    format_dict['minimumwidth'] = int(format_dict['minimumwidth'] or '0')

    # Convert precision to an int, or `None` if no precision given.
    if format_dict['precision']:
        format_dict['precision'] = int(format_dict['precision'][1:])
    else:
        format_dict['precision'] = None

    # If no rounding mode is given, assume 'N'.
    if not format_dict['rounding']:
        format_dict['rounding'] = 'N'

    return format_dict
118225
def formatted_value(value, format, width)
      value_str = value ? format(format, value) : ' ' * width # all space for nil value
      length = value_str.length
      if length > width
        value_str.slice(0..width - 1)
      elsif length < width
        ' ' * (width - length) + value_str
      else
        value_str
      end
    end
1222740
def format_field(self, value, spec):
        

        if spec.startswith('date:'):
            _, format_ = spec.split(':', 1)
            return self.format_date(value, format_)
        elif spec.startswith('datetime:'):
            _, format_ = spec.split(':', 1)
            return self.format_datetime(value, format_)
        elif spec == 'number':
            return self.format_number(value)
        else:
            return super(I18nFormatter, self).format_field(value, spec)
823499
def special_format_field(self, obj, format_spec):
        """"""
        if format_spec == "env":
            return "${{{0}}}".format(obj)
        elif format_spec == "from_env":
            if obj not in os.environ:
                raise NoSuchEnvironmentVariable(wanted=obj)
            return os.environ[obj]
610935
function defaultValue(spec)
{
  if (util.isRegExp(spec)) return "";
	return ({
        "string": "",
        "id": null,
        "number": 0,
        "boolean": false,
        "date": new Date(),
        "regexp": new RegExp(),
        "function": function() { },
        "array": [],
        "object": {}
    })[spec];
}
1121064
def construct_format(f, type_map=CONSTRUCT_CODE):
  
  formatted = ""
  if type_map.get(f.type_id, None):
    return "%s('%s')" % (type_map.get(f.type_id), f.identifier)
  elif f.type_id == 'string' and f.options.get('size', None):
    return "string('%s', { length: %d })" % (f.identifier, f.options['size'].value)
  elif f.type_id == 'string':
    return "string('%s', { greedy: true })" % (f.identifier)
  elif f.type_id == 'array':
    fill = f.options['fill'].value
    f_ = copy.copy(f)
    f_.type_id = fill
    size = f.options.get('size', None)
    size_fn = f.options.get('size_fn', None)
    field_type = type_map.get(f_.type_id, None)
    if field_type is None:
      field_type = "%s.prototype.parser" % f_.type_id
    else:
      field_type = "'%s'" % field_type
    if size is not None:
      d = { "'uint16'" : "'uint16le'", "'uint32'" : "'uint32le'", "'uint64'" : "'uint16le'",
            "'int16'" : "'int16le'", "'int32'" : "'int32le'", "'int64'" : "'int16le'" }
      field_type_arr = d.get(field_type, field_type)
      return "array('%s', { length: %d, type: %s })" % (f.identifier, size.value, field_type_arr)
    elif f.options.get('size_fn') is not None:
      return "array('%s', { type: %s, length: '%s' })" % (f_.identifier, field_type, size_fn.value)
    else:
      return "array('%s', { type: %s, readUntil: 'eof' })" % (f_.identifier, field_type)
  else:
    return "nest('%s', { type: %s.prototype.parser })" % (f.identifier, f.type_id)
  return formatted
797404
function getFormattedValue(value) {
            let format;

            if (isInteger(value)) {
                format = formatIntegerValue;
            } else {
                format = formatDecimalValue;
            }

            return format(value);
        }