Helper: turn: : {'string1': ['foo'], 'string2': ['foo', 'bar', 'foo'],} Into: : "string1 (foo)<br />string2 (foo, bar)"
12515
function sfuse(hash){
	var retval = '';

	var cache = [];
	us.each(hash, function(loc_list, str){
	    var locs = dedupe(loc_list);
	    cache.push( str + ' <small>[' + locs.join(', ') + ']</small>');
	});
	if( cache.length > 0 ){
	    retval = cache.join('<br />');	    
	}
	
	return retval;
    }
928386
def format_args(options):
    
    args = list()

    for key, value in options.items():
        # convert foo_bar key into --foo-bar option
        key = key.replace('_', '-')

        if value is True:
            # key: True
            # --key
            args.append('--{key}'.format(key=key))
        elif is_sequence(value):
            # key: ['foo', 'bar']
            # --key=foo,bar
            values = [str(val) for val in value]
            args.append('--{key}={values}'.format(
                key=key, values=','.join(values)))
        else:
            # key: 'foo'
            # --key=foo
            args.append('--{key}={value}'.format(key=key, value=value))

    return args
958984
def _build_param_string(params):
        
        pairs = []
        for key, value in params.iteritems():
            if value is None:
                value = ''
            pairs.append('{0}={1}'.format(key, value))
        if len(pairs) > 0:
            return '?{0}'.format('&'.join(pairs))
        return ''
881277
def str_args(args):
    
    res = []
    for x in args:
        if isinstance(x, tuple) and len(x) == 2:
            key, value = x
            if value and str_arg(value):
                res += ["%s=%s" % (key, str_arg(value))]
        else:
            res += [str_arg(x)]
    return ', '.join(res)
1070892
def normalize_string_keys(old):
    """"""
    new = {}
    for key, value in old.items():
        if isinstance(key, bytes_):
            new[key.decode('utf8')] = value
        else:
            new[key] = value
    return new
770479
def _convert_list2str(self, fields):
        
        if isinstance(fields, tuple) or isinstance(fields, list):
            return ','.join(fields)
        return fields
543448
def _split_index(params):
    
    result = {}
    for key in params:
        if isinstance(params[key], dict):
            value = params[key]['_value']
        else:
            value = params[key]
        result[key] = value
    return result
326400
def string_to_expression_parts(expression_str)
      return {} if expression_str.nil?

      parts, interval = split_parts_and_interval(expression_str)

      expression_parts = ::Hash[EXPRESSION_PART_KEYS.zip(parts)]
      expression_parts.select! do |_key, value|
        !value.nil?
      end
      expression_parts[:interval] = interval unless interval.nil?

      expression_parts
    end
1029756
def list2dict(list_of_options):
    """"""
    d = {}
    for key, value in list_of_options:
        d[key] = value
    return d
189401
def attribs_to_string(attrib_dict, keys):
    
    for key, value in attrib_dict.iteritems():
        if (isinstance(value, list) or isinstance(value, dict) or
            isinstance(value, tuple)):
            attrib_dict[key] = value

    return attrib_dict
221379
def join_strings(key, value, fmt, meta):  # pylint: disable=unused-argument
    """"""
    if key in ['Para', 'Plain']:
        _join_strings(value)
    elif key == 'Image':
        _join_strings(value[-2])
    elif key == 'Table':
        _join_strings(value[-5])
783737
def to_s
      arr = []
      if freq = @hash.delete('FREQ')
        arr << "FREQ=#{freq.join(',')}"
      end
      arr.concat(@hash.map do |key, value|
        if value.is_a?(Array)
          "#{key}=#{value.join(',')}"
        end
      end.compact)
      arr.join(';')
    end
626333
def _stringlist_to_dictionary(input_string):
    '''
    
    '''
    li = str(input_string).split(',')
    ret = {}
    for item in li:
        pair = str(item).replace(' ', '').split('=')
        if len(pair) != 2:
            log.warning('Cannot process stringlist item %s', item)
            continue

        ret[pair[0]] = pair[1]
    return ret
1349455
def stringer(x):
    
    if isinstance(x, string_types):
        return x
    if isinstance(x, (list, tuple)):
        return [stringer(y) for y in x]
    if isinstance(x, dict):
        return dict((stringer(a), stringer(b)) for a, b in x.items())
    return text_type(x)
867905
private String toJsStringSet(Iterable<String> strings) {
    StringBuilder sb = new StringBuilder();
    boolean isFirst = true;
    sb.append('{');
    for (String str : strings) {
      if (!isFirst) {
        sb.append(", ");
      }
      isFirst = false;
      writeStringLiteral(str, sb);
      sb.append(": true");
    }
    sb.append('}');
    return sb.toString();
  }
931014
def _join(lst, key, sep=";"):
    
    return sep.join([d[key] for d in lst if d[key]])
426265
def _join_strings(x):
    """"""
    for i in range(len(x)-1):  # Process successive pairs of elements
        if x[i]['t'] == 'Str' and x[i+1]['t'] == 'Str':
            x[i]['c'] += x[i+1]['c']
            del x[i+1]  # In-place deletion of element from list
            return None  # Forces processing to repeat
    return True