Format a string representing the kinds.
968835
def format_kinds(raw):
    """"""
    output = ' '.join('{} {}'.format(*kind) for kind in raw if kind)
    return output
1126269
function format(str, swaps) {
  // First replace the %S strings
  var index = 0;
  str = str.replace(/%S/g, function() {
    return swaps[index++];
  });
  // Then %n$S style strings
  str = str.replace(/%([0-9])\$S/g, function(match, idx) {
    return swaps[idx - 1];
  });
  return str;
}
565073
def process_strings(self, string, docstrings=False):
        """"""

        m = RE_STRING_TYPE.match(string)
        stype = self.get_string_type(m.group(1) if m.group(1) else '')
        if not self.match_string(stype) and not docstrings:
            return '', False
        is_bytes = 'b' in stype
        is_raw = 'r' in stype
        is_format = 'f' in stype
        content = m.group(3)
        if is_raw and (not is_format or not self.decode_escapes):
            string = self.norm_nl(content)
        elif is_raw and is_format:
            string = self.norm_nl(FE_RFESC.sub(self.replace_unicode, content))
        elif is_bytes:
            string = self.norm_nl(RE_BESC.sub(self.replace_bytes, content))
        elif is_format:
            string = self.norm_nl(RE_FESC.sub(self.replace_unicode, content))
        else:
            string = self.norm_nl(RE_ESC.sub(self.replace_unicode, content))

        return textwrap.dedent(RE_NON_PRINTABLE.sub('\n', string) if is_bytes else string), is_bytes
1371528
def _format_strings(self):
        

        values = self.values
        return [val.strftime('%Y-%m-%d %H:%M:%S') if val is not None else self.nat_rep for val in values]
992436
function format (str, ...args) {
  return str.replace(/{(\d+)}/g, function (match, number) {
    return typeof args[number] === 'undefined'
      ? match
      : args[number]
    ;
  })
}
1044465
def _format_week(self, name, type, a_per):
        """"""
        return '{},{},{}/{},{}/{}'.format(name, type, a_per.st_month, a_per.st_day,
                                          a_per.end_month, a_per.end_day)
45846
def _type_string(label, case=None):
    """"""
    return label, abstractSearch.in_string, lambda s: abstractRender.default(s, case=case), ""
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]));
}
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;
	}
710843
def _format_str(string):
    """"""
    if isinstance(string, _STRTYPES):
        if _IS_PYTHON3:
            array = _array.array('I')
            array.frombytes(string.encode(_utf32_codec))
        else: # Python 2
            if isinstance(string, unicode):
                array = _array.array(b'I')
                array.fromstring(string.encode(_utf32_codec))
            else:
                array = _array.array(b'B')
                array.fromstring(string)
        return array
    return string
809237
def formatter(self, value):
        '''
        
        '''
        if not self._bitwise:
            n = self.getName(value)
            if n is None:
                return value
            else:
                return n
        else:
            names = []
            for k,v in sorted(self._values.items(), key=lambda x: x[1], reverse=True):
                if (v & value) == v:
                    names.append(k)
                    value = value ^ v
            names.reverse()
            if value != 0:
                names.append(hex(value))
            if not names:
                return 0 
            return ' '.join(names)
1064188
def ensure_unicode_string(value):
    """"""
    if not isinstance(value, six.string_types):
        raise TypeError(u'Expected string value, got: {}'.format(value))
    return six.text_type(value)
438179
def pretty_str(self, indent=0):
        
        if self.parenthesis:
            return (' ' * indent) + '(' + self.name + ')'
        return (' ' * indent) + self.name
402413
def pretty_str(self, indent=0):
        
        indent = ' ' * indent
        if self.value is not None:
            return '{}{} {}'.format(indent, self.name, pretty_str(self.value))
        return indent + self.name
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'
57905
def kinds(context, show_all, ids_or_names):
    
    logging.info(_('Entering kind mode'))
    logging.debug('args: %s', ids_or_names)
    sense = context.obj['sense']
    none = True
    if show_all:
        none = False
        print(sense.query_kinds(None))
    else:
        for id_or_name in ids_or_names:
            id_name = sense.query_kinds(id_or_name)
            if id_name:
                none = False
                print(id_name)
    sys.exit(1 if none else 0)
87024
def eval_string_type(self, text, is_string=False):
        """"""

        stype = set()
        wstype = set()

        for m in RE_ITER_STRING_TYPES.finditer(text):
            value = m.group(0)
            if value == '*':
                wstype.add('u')
                wstype.add('f')
                wstype.add('r')
                wstype.add('b')
            elif value.endswith('*'):
                wstype.add(value[0].lower())
            else:
                stype.add(value.lower())

        if is_string and 'b' not in stype and 'f' not in stype:
            stype.add('u')

        return stype, wstype