Converts
 "prefs" => { "voting" => "members" }
 to
 "prefs/voting" => "members
965852
def flatten_nested_keys(body)
      options = {}
      body.each do |key, value|
        next unless value.is_a?(Hash)
        value = flatten_nested_keys(value.dup)
        value.each do |nested_key, nested_value|
          options["#{key}/#{nested_key}"] = nested_value
        end
        body.delete(key)
      end
      body.merge(options)
    end
149813
def make_attributes(s, gff3=True, keep_attr_order=True):
    
    if gff3:
        """
        hack: temporarily replace the '+' sign in the attributes column
        with the string 'PlusSign' to prevent urlparse.parse_qsl() from
        replacing the '+' sign with a space
        """
        s = s.replace('+', 'PlusSign')
        d = parse_qs(s, keep_attr_order=keep_attr_order)
        for key in d:
            d[key][0] = unquote(d[key][0].replace('PlusSign', '+').replace('"', ''))
    else:
        attributes = s.split(";")
        d = DefaultOrderedDict(list) if keep_attr_order else defaultdict(list)
        for a in attributes:
            a = a.strip()
            if ' ' not in a:
                continue
            key, val = a.split(' ', 1)
            val = unquote(val.replace('"', '').replace('=', ' ').strip())
            d[key].append(val)

    for key, val in d.items():
        d[key] = list(flatten([v.split(",") for v in val]))

    return d
992493
def to_s
      string = "#{@name}"
      # If value is either nil or an empty array
      if @value.nil? || @value.is_a?(Array) && @value.size == 0
        string << " (#{@type}"
        string << "/#{@subtype}" if @subtype
        string << ')'
        string << ' [required]' if @required
      else
        if @type.eql?('Array')
          string << ' ='
          @value.each { |v| string << "\n  - #{v}" }
        else
          string << " = #{@value}"
        end
      end
      string << "\n"
    end
325723
function (member) {
        if ("[" !== member.charAt(0) || "]" !== member.charAt(member.length - 1)) {
            return "";
        }
        return _gpfEncodeAttributeMember(member.substr(1, member.length - 2)); // Extract & encode member name
    }
213420
private String toStringImpl() {
		StringBuffer result = new StringBuffer(128);
		result.append('@');
		result.append(type.getName());
		result.append('(');
		boolean firstMember = true;
		for (Map.Entry<String, Object> e : memberValues.entrySet()) {
			if (firstMember)
				firstMember = false;
			else
				result.append(", ");

			result.append(e.getKey());
			result.append('=');
			result.append(memberValueToString(e.getValue()));
		}
		result.append(')');
		return result.toString();
	}
372469
def _strip(self, tokens, criteria, prop, rev=False):
        """"""
        num = len(tokens)
        res = []
        for i, token in enumerate(reversed(tokens) if rev else tokens):
            if criteria(token) and num > i + 1:
                res.insert(0, tokens.pop()) if rev else res.append(tokens.pop(0))
            else:
                break
        if res:
            self[prop] = self._clean(' '.join(res))
        return tokens
1259410
function(obj_) {
  var obj = sg.smartAttrs(obj_ || {});

  if (!obj.tags)              { return obj; }

  var arr = obj.tags;
  if (_.isString(obj.tags)) {
    arr = obj.tags.split(/[, ]+/g);
  }

  // Turn a string into tags: 'foo, bar, baz=quxx'
  obj.tags = sg.reduce(arr, {}, function(m, str) {
    var result   = {};
    var parts    = str.split(/[=] ?/g);
    var key      = parts.shift();

    if (parts.length <= 0) {
      return sg.kv(m, key, true);
    }

    return sg.kv(m, key, parts.join('='));
  });

  return obj;
}
459762
def pre_filter(self):
        
        if self._name not in self.PRE_FILTER_FIELDS or self._template:
            return ''
        if not self._value:
            return '"equal={},cat="'.format(self.PRE_FILTER_FIELDS[self._name])

        if self._is_regex:
            needle = self._value[1:-1]
            needle = self.CLEAN_PRE_VAL_RE.sub(' ', needle)
            needle = self.SPLIT_PRE_VAL_RE.split(needle)
        else:
            needle = self.CLEAN_PRE_VAL_RE.sub(' ', self._value)
            needle = self.SPLIT_PRE_GLOB_RE.split(needle)
        needle = list(sorted(needle, key=len))[-1]

        if needle:
            try:
                needle.encode('ascii')
            except UnicodeEncodeError:
                return ''
            else:
                return r'"string.contains_i=${},\"{}\""'.format(
                       self.PRE_FILTER_FIELDS[self._name], needle.replace('"', r'\\\"'))

        return ''
615542
def to_s
      repr = ""
      repr += "id: #{id}\n" if id
      repr += "event: #{event}\n" if event
      if data.empty?
        repr += "data: \n"
      else
        data.split("\n").each { |l| repr += "data: #{l}\n" }
      end
      repr += "\n"
    end
142305
def convert(obj, ids, attr_type, item_func, cdata, parent='root'):
    """"""
    
    LOG.info('Inside convert(). obj type is: "%s", obj="%s"' % (type(obj).__name__, unicode_me(obj)))
    
    item_name = item_func(parent)
    
    if isinstance(obj, numbers.Number) or type(obj) in (str, unicode):
        return convert_kv(item_name, obj, attr_type, cdata)
        
    if hasattr(obj, 'isoformat'):
        return convert_kv(item_name, obj.isoformat(), attr_type, cdata)
        
    if type(obj) == bool:
        return convert_bool(item_name, obj, attr_type, cdata)
        
    if obj is None:
        return convert_none(item_name, '', attr_type, cdata)
        
    if isinstance(obj, dict):
        return convert_dict(obj, ids, parent, attr_type, item_func, cdata)
        
    if isinstance(obj, collections.Iterable):
        return convert_list(obj, ids, parent, attr_type, item_func, cdata)
        
    raise TypeError('Unsupported data type: %s (%s)' % (obj, type(obj).__name__))
607778
function objectToString(o) {
  return '{' + keys(o).map(k => `${k}: ${o[k]}`).join(', ') + '}';
}
1280862
function (text, replacements) {
        'use strict';
        var keys = getKeysFromTemplate(text),//Object.keys(replacements),
            len = keys.length,
            i = 0,
            key,
            value;
        while (i < len) {
            key = keys[i];
            if (key.indexOf('.') !== -1) {
                value = getNestedValue(replacements, key);
            } else {
                value = replacements[key];
            }
            if (value) {
                text = text.split('{' + key + '}').join(value);
            }
            i += 1;
        }
        return text;
    }
261718
def _to_key(d):
        """"""
        as_str = json.dumps(d, sort_keys=True)
        return as_str.replace('"{{', '{{').replace('}}"', '}}')
1168908
def transpose(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs,
                                                       {'perm' : 'axes'})
    return 'transpose', new_attrs, inputs
800758
function objectKeys(target, pred) {
  pred = pred || has;
  var results = [];


  for (var key in target) {
    if (pred(target, key)) {
      results.push(String(key));
    }
  }

  return results;
}
1125851
function flatten(source, opts) {
  opts = opts || {};
  var delimiter = opts.delimiter = opts.delimiter || '.';
  var o = {};
  function iterate(source, parts) {
    var k, v;
    parts = parts || [];
    for(k in source) {
      v = source[k];
      if(v && typeof v === 'object' && Object.keys(v).length) {
        iterate(v, parts.concat(k));
      }else{
        o[parts.concat(k).join(delimiter)] = v;
      }
    }
  }
  iterate(source);
  return o;
}
632856
function mappingMembers(mapping) {
  const { from, to } = mapping
  const memberUris = [ from, to ].filter(Boolean)
    .map(bundle => reduceSet(bundle[memberField(bundle)] || []))
  return [].concat(...memberUris).sort()
}