Change a keyname to another, without changing position in sequence.

        Implemented so that transformations can be made on keys,
        as well as on values. (used by encode and decode)

        Also renames comments.
350013
def rename(self, oldkey, newkey):
        
        if oldkey in self.scalars:
            the_list = self.scalars
        elif oldkey in self.sections:
            the_list = self.sections
        else:
            raise KeyError('Key "%s" not found.' % oldkey)
        pos = the_list.index(oldkey)
        #
        val = self[oldkey]
        dict.__delitem__(self, oldkey)
        dict.__setitem__(self, newkey, val)
        the_list.remove(oldkey)
        the_list.insert(pos, newkey)
        comm = self.comments[oldkey]
        inline_comment = self.inline_comments[oldkey]
        del self.comments[oldkey]
        del self.inline_comments[oldkey]
        self.comments[newkey] = comm
        self.inline_comments[newkey] = inline_comment
377221
private boolean renameKeyForAllLanguages(String oldKey, String newKey) {

        try {
            loadAllRemainingLocalizations();
            lockAllLocalizations(oldKey);
            if (hasDescriptor()) {
                lockDescriptor();
            }
        } catch (CmsException | IOException e) {
            LOG.error(e.getLocalizedMessage(), e);
            return false;
        }
        for (Entry<Locale, SortedProperties> entry : m_localizations.entrySet()) {
            SortedProperties localization = entry.getValue();
            if (localization.containsKey(oldKey)) {
                String value = localization.getProperty(oldKey);
                localization.remove(oldKey);
                localization.put(newKey, value);
                m_changedTranslations.add(entry.getKey());
            }
        }
        if (hasDescriptor()) {
            CmsXmlContentValueSequence messages = m_descContent.getValueSequence(
                Descriptor.N_MESSAGE,
                Descriptor.LOCALE);
            for (int i = 0; i < messages.getElementCount(); i++) {

                String prefix = messages.getValue(i).getPath() + "/";
                String key = m_descContent.getValue(prefix + Descriptor.N_KEY, Descriptor.LOCALE).getStringValue(m_cms);
                if (key == oldKey) {
                    m_descContent.getValue(prefix + Descriptor.N_KEY, Descriptor.LOCALE).setStringValue(m_cms, newKey);
                    break;
                }
            }
            m_descriptorHasChanges = true;
        }
        m_keyset.renameKey(oldKey, newKey);
        return true;
    }
1066599
def record_rename(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/rename' % object_id, input_params, always_retry=always_retry, **kwargs)
151925
async def _replace(self, key: Text, data: Dict[Text, Any]) -> None:
        

        with await self.pool as r:
            await r.set(self.register_key(key), ujson.dumps(data))
1277695
def change_by(cls, name, num):
        """"""
        count = cls.count(name)
        if count + num < 0:
            raise CounterValueError('Counter[%s] will be negative '
                                    'after %+d.' % (name, num))

        counter = cls.collection.find_and_modify(
            {'name': name},
            {'$inc': {'seq': num}},
            new=True,
            upsert=True
        )
        return counter['seq']
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
643486
def set_comment(self, key_name, new_comment):
        """"""
        kf = self.dct[key_name]
        kf['comment'] = new_comment
284883
def transform(name, value)
      if transforms.key?(name)
        transforms[name].call(value)
      else
        modifiers.transform(name, value)
      end
    end
1106002
function renameKey(fp, opts) {
  if (opts && opts.renameKey) {
    return opts.renameKey(fp, opts);
  }
  return basename(fp);
}
325358
function updateKeys(obj, _) {
    var newObj = null;
    if (_.isArray(obj)) {
        newObj = [];
    } else if (_.isObject(obj)) {
        newObj = {};
    } else {
        return obj;
    }
    _.forEach(obj, function(value, key) {
        if (key.replace) {
            var newKey = key.replace(/\$|\./g, '_');
            newObj[newKey] = updateKeys(value, _);
        } else {
            newObj[key] = updateKeys(value, _);
        }
    });
    return newObj;
}
871448
def rename_keys(record: Mapping, key_map: Mapping) -> dict:
    """"""

    new_record = dict()

    for k, v in record.items():
        key = key_map[k] if k in key_map else k
        new_record[key] = v

    return new_record
1080205
def rename(self, **mapping):
        
        params = {k: v for k, v in self.get_param_values() if k != 'name'}
        return self.__class__(rename=mapping,
                              source=(self._source() if self._source else None),
                              linked=self.linked, **params)
542488
def update(self, E=None, **F):
        
        if E is not None:
            if hasattr(E, 'keys'):
                for K in E:
                    self.replace(K, E[K])
            elif hasattr(E, 'items'):
                for K, V in E.items():
                    self.replace(K, V)
            else:
                for K, V in E:
                    self.replace(K, V)
        for K in F:
            self.replace(K, F[K])
624555
def reorder_keys(self, keys):
        ''''''
        if len(keys) != len(self._keys):
            raise ValueError('The supplied number of keys does not match.')
        if set(keys) != set(self._d.keys()):
            raise ValueError('The supplied keys do not match the current set of keys.')
        self._keys = keys
778781
function transformPropertyName(attributeName) {
  if (propertiesToTransform[attributeName]) {
    return propertiesToTransform[attributeName];
  }
  if (nonTransformedProperties[attributeName] !== true) {
    return false;
  }
  return attributeName;
}
156152
def transform(data, keysToSplit=[]):
    
    transformed = { }
    for key in data:
        if key in keysToSplit:
            transformed[key] = data[key]['value'].split(SEPARATOR)
        else:
            transformed[key] = data[key]['value']
    return transformed
124172
def changebase(string, frm, to, minlen=0):
    
    if frm == to:
        return lpad(string, get_code_string(frm)[0], minlen)

    return encode(decode(string, frm), to, minlen)