Adjust key targets per rewrites
489565
List<ResolveTask> adjustResourceRenames(final List<ResolveTask> renames) {
        final Map<KeyScope, List<ResolveTask>> scopes = renames.stream().collect(Collectors.groupingBy(rt -> rt.scope));

        final List<ResolveTask> res = new ArrayList<>();
        for (final Map.Entry<KeyScope, List<ResolveTask>> group : scopes.entrySet()) {
            final KeyScope scope = group.getKey();
            final List<ResolveTask> tasks = group.getValue();
            final Map<URI, URI> rewrites = tasks.stream()
                    // FIXME this should be filtered out earlier
                    .filter(t -> t.out != null)
                    .collect(toMap(
                            t -> t.in.uri,
                            t -> t.out.uri
                    ));
            final KeyScope resScope = rewriteScopeTargets(scope, rewrites);
            tasks.stream().map(t -> new ResolveTask(resScope, t.in, t.out)).forEach(res::add);
        }

        return res;
    }
354298
function (key, regexp, replacement, editor) {
            key = key.toLowerCase();

            return getPreviousKeyForEditing(key, editor)
            .then(bindr(Result.andThen, editOnlyWhenPreviousKeyExists))
            .then(bindr(Result.andThen, function (description) {
                const old_message = description.message;
                const new_message = old_message
                    .replace(regexp, replacement)
                    .replace(/\s+/, " ");

                if (old_message === new_message) {
                    return Fail("unchanged");
                }

                if (new_message.length > maxMessageLength) {
                    return Fail("message-length-exceeded");
                }

                if (new_message === "") {
                    return Fail("no-message-left");
                }

                description.message = new_message;
                description.editor = editor;
                description.time = now();

                return Ok(description);
            }))
            .then(bindr(Result.andThen, beforeUpdate))
            .then(bindr(Result.map, function (value) {
                db.set(key, value);
                return value;
            }));
        }
646006
def updateAllKeys(self):
        """"""
        for kf, key in zip(self.kf_list, self.sorted_key_list()):
            kf.update(key, self.dct[key])
1090861
private function rearrangeHostHeaderKey()
    {
        if (!isset($this->headers['Host'])) {
            return;
        }

        $tmp = $this->headers['Host'];
        $keys = array_keys($this->headers);
        $hostIndex = array_search('Host', $keys, true);

        if (false === $hostIndex) {
            return;
        }

        array_splice($this->headers, $hostIndex, 1);

        $this->headers = ['Host' => $tmp] + $this->headers;
    }
462175
function sk(key) {
    if (globalKeySanitize) {
      return key;
    } else {
      return key.replace(/\s+/g, '_')
                .replace(/\//g, '-')
                .replace(/[^a-zA-Z_\-0-9\.]/g, '');
    }
  }
186845
function applyReplacementRules(rulesset, content) {
  return rulesset.reduce((a,b) => {
    return a.replace(b[0], b[1]);
  }, content);
}
630459
def rewriteInstallNameCommand(self, loadcmd):
        """"""
        if self.id_cmd is not None:
            self.rewriteDataForCommand(self.id_cmd, loadcmd)
            return True
        return False
759942
def config_amend_key_(self,key,value):
        
        cfg_i = self._cfg
        keys = key.split('.')
        last_key = keys.pop()
        trail = []
        for e in keys:
            cfg_i.setdefault(e,{})
            cfg_i = cfg_i[e]
            trail.append(e)
            if not isinstance(cfg_i,dict):
                raise Exception('.'.join(trail) + ' has conflicting dict/scalar types!')
        cfg_i.setdefault(last_key,value)
407274
private String adjustKey(String key) {

        // replace the &nbsp; with spaces
        key = key.replaceAll("&nbsp;", " ");
        // now eleiminate all double spaces
        int keyLen;
        do {
            keyLen = key.length();
            key = key.replaceAll("  ", " ");
        } while (key.length() != keyLen);
        return key;
    }
838794
def apply(self):
        """"""
        # In this phase, we replace the substitutions in hyperlinks
        # with the contents of the sub-nodes introduced during phase 1.
        # We also remove those temporary nodes from the tree.
        subst_re = re.compile(self.subst_pattern)

        # Apply the substitutions to hyperlink references.
        for link in self.document.traverse(nodes.reference):
            substitutions = link.get('varlinks')
            if not substitutions:
                continue

            replacer = self._replace(substitutions, link.children, 1)
            link['refuri'] = subst_re.sub(replacer, link['refuri'])
            content = subst_re.sub(replacer, link[0])
            # Cleanup the temporary nodes and recreate the node's content.
            link.clear()
            del link['varlinks']
            link.append(nodes.Text(content))

        # Do the same with hyperlink targets.
        for link in self.document.traverse(nodes.target):
            substitutions = link.get('varlinks')
            if not substitutions:
                continue

            replacer = self._replace(substitutions, link.children, 0)
            link['refuri'] = subst_re.sub(replacer, link['refuri'])
            # Cleanup the temporary nodes.
            link.clear()
            del link['varlinks']
697019
def adjust(self):
        

        if self._fro is None and self._to is not None:
            self._fro = dict(
                [(value.lower(), key) for key, value in self._to.items()])
        if self._to is None and self._fro is not None:
            self._to = dict(
                [(value.lower(), key) for key, value in self._fro.items()])
251172
def keys(self, pattern, *, encoding=_NOTSET):
        """"""
        return self.execute(b'KEYS', pattern, encoding=encoding)
727015
def normalize!
      if path && path == ''
        set_path('/')
      end
      if scheme && scheme != scheme.downcase
        set_scheme(self.scheme.downcase)
      end
      if host && host != host.downcase
        set_host(self.host.downcase)
      end        
    end
976955
private void adjustApproximatedKNNDistances(MkCoPEntry entry, Map<DBID, KNNList> knnLists) {
    MkCoPTreeNode<O> node = getNode(entry);

    if(node.isLeaf()) {
      for(int i = 0; i < node.getNumEntries(); i++) {
        MkCoPLeafEntry leafEntry = (MkCoPLeafEntry) node.getEntry(i);
        approximateKnnDistances(leafEntry, knnLists.get(leafEntry.getRoutingObjectID()));
      }
    }
    else {
      for(int i = 0; i < node.getNumEntries(); i++) {
        MkCoPEntry dirEntry = node.getEntry(i);
        adjustApproximatedKNNDistances(dirEntry, knnLists);
      }
    }

    ApproximationLine approx = node.conservativeKnnDistanceApproximation(settings.kmax);
    entry.setConservativeKnnDistanceApproximation(approx);
  }
610846
function _adjustIpStrFormat(ipString) {
        var ip = ipString.split('.');
        ipString = '';
        for (var i = 0; i < ip.length; i += 1) {
            switch (ip[i].length) {
                case 1:
                    ip[i] = '00' + ip[i];
                    break;
                case 2:
                    ip[i] = '0' + ip[i];
                    break;
                default:
                    break;
            }
            ipString += ip[i];
        }
        return ipString.trim();
    }
1299961
private void rewriteProperty(JSONObject node, String key, JSONArray rewriteProperty) throws JSONException {
    if (node.get(cleanup(key)) instanceof String) {
      if (rewriteProperty.length() == 2) {
        if (rewriteProperty.get(0) instanceof String && rewriteProperty.get(1) instanceof String) {
          String pattern = rewriteProperty.getString(0);
          String replacement = rewriteProperty.getString(1);

          Pattern compiledPattern = Pattern.compile(pattern);
          Matcher matcher = compiledPattern.matcher(node.getString(cleanup(key)));
          node.put(cleanup(key), matcher.replaceAll(replacement));
        }
      }
    }
  }
608701
def transform(self, keys):
        """"""
        key = keys['regular'][0]
        modifiers = keys['modifiers']

        try:
            if not modifiers:
                if key in self._letters or key in self._digits:
                    res = key
                elif key in self._command_keys:
                    res = '<' + key + '>'
                else:
                    res = self._layout['no_mods'][key]
            elif self._only_shifts(modifiers):
                if key in self._letters:
                    res = key.upper()
                else:
                    res = self._layout['shift'][key]
            elif self._only_right_alt(modifiers):
                res = self._layout['right_alt'][key]
            else:
                res = None
        except KeyError:
            res = None

        return res