Mutate enclosed fields
334532
def _mutate(self):
        '''
        
        '''
        for i in range(self._field_idx, len(self._fields)):
            self._field_idx = i
            if self._current_field().mutate():
                return True
            self._current_field().reset()
        return False
373342
function generateNamedFieldExtractors(input) {
  var names = input.filter(function(matcher, index, array) {
    // has a name?
    return matcher.name;
  });
  // has duplicates?
  names.forEach(function(matcher, index, array) {
    var isDuplicate = array.slice(0, index).some(function(previousMatcher) {
      return previousMatcher.name == matcher.name;
    });
    if (isDuplicate) {
      throw new Error("duplicate named field '" + matcher.name + "'");
    }
  });
  return names;
}
138928
function handleFieldBelong (field, names, space, factory) {

            var curr = names.shift();
            if ( curr ) {
                space.forEach(function (item) {
                    if ( item && item.field === curr ) {
                        if ( names.length === 0 ) {
                            if ( !item[field] ) {
                                item[field] = [];
                            }
                            item[field].push(factory)
                        } else if ( item.param ) {
                            handleFieldBelong(field, names, item.param, factory);
                        }
                    }
                });
            }
        }
114680
def prepend_field(self, field_name, list_value):
    """"""
    return self._single_list_field_operation(field_name, list_value, prepend=True)
946553
function mutateDOM(contexts) {
    var length = contexts.length;
    var index, context, parent, childrenLength, oldOrder, newOrder;
    var moves, movesLength, move, beforeElement;
    var moving = {};

    for (index = 0; index < length; index++) {
        context = contexts[index];
        parent = context.parent;
        childrenLength = context.children.length;

        oldOrder = parent.children;
        newOrder = new Array(childrenLength);
        while (childrenLength--) {
            newOrder[childrenLength] = context.children[childrenLength].node;
        }

        moves = diff(oldOrder, newOrder);

        movesLength = moves.length;
        while (movesLength--) {
            moving[getID(moves[movesLength].element)] = moves[movesLength].index;
        }

        movesLength = moves.length;
        while (movesLength--) {
            move = moves[movesLength];
            beforeElement = newOrder[move.index + 1] || null;

            while (true) {
                if (beforeElement && (moving[getID(beforeElement)] !== undefined)) {
                    // The element we're inserting this one before is going to be moved—but has not
                    // been moved yet, take its place.
                    beforeElement = newOrder[moving[getID(beforeElement)] + 1];
                } else {
                    break;
                }
            }

            moving[getID(move.element)] = undefined;
            parent.insertBefore(move.element, beforeElement);
        }
    }
}
268164
def _set_fields(self, fields):
        """"""
        for f in fields:
            if hasattr(self, f):
                setattr(self, f, fields[f])
            else:
                raise TypeError("'{arg}' is an invalid argument for {instance_type}".format(arg=f, instance_type=self.__class__.__name__))
184420
function mutate(Component, title, api = {}) {
  class Mutated extends React.Component {
    constructor(props, context) {
      super(props);

      this.ToRender = Component;
      const mutations = context.mutations;

      if (!mutations || !mutations[title]) {
        return;
      }

      // Convert old style mutations to new style mutations
      if (!Array.isArray(mutations[title])) {
        mutations[title] = [mutations[title]];
      }

      // Apply all mutations to the component
      for (let mut of mutations[title]) {
        this.ToRender = mut(this.ToRender, api);
      }
    }

    render() {
      const ToRender = this.ToRender;
      return <ToRender {...this.props} />;
    }
  }

  Mutated.contextTypes = {
    mutations: PropTypes.object
  };

  return Mutated;
}
1056613
public boolean mutateAttachments(CollectionUtils.Functor<Map<String, Object>,
            Map<String, Object>> functor) {
        {
            Map<String, Object> properties = getProperties();
            Map<String, Object> editedProperties = null;
            Map<String, Object> attachments = (Map<String, Object>) properties.get("_attachments");
            Map<String, Object> editedAttachments = null;
            if (attachments != null) {
                for (String name : attachments.keySet()) {

                    Map<String, Object> attachment = new HashMap<String, Object>(
                            (Map<String, Object>) attachments.get(name));
                    attachment.put("name", name);
                    Map<String, Object> editedAttachment = functor.invoke(attachment);
                    if (editedAttachment == null) {
                        return false;  // block canceled
                    }
                    if (editedAttachment != attachment) {
                        if (editedProperties == null) {
                            // Make the document properties and _attachments dictionary mutable:
                            editedProperties = new HashMap<String, Object>(properties);
                            editedAttachments = new HashMap<String, Object>(attachments);
                            editedProperties.put("_attachments", editedAttachments);
                        }
                        editedAttachment.remove("name");
                        editedAttachments.put(name, editedAttachment);
                    }
                }
            }
            if (editedProperties != null) {
                setProperties(editedProperties);
                return true;
            }
            return false;
        }
    }
1085287
def _generate_struct_properties(self, fields):
        """"""
        for field in fields:
            doc = self.process_doc(field.doc,
                                   self._docf) if field.doc else undocumented
            self.emit_wrapped_text(
                self.process_doc(doc, self._docf), prefix=comment_prefix)
            self.emit(fmt_property(field=field))
            self.emit()
372314
protected function makeMutatableFields(Collection $fields = null)
    {
        if (is_null($fields))
        {
            return '';
        }

        $mutatables = [];

        foreach ($fields as $field)
        {
            if (in_array($field->type, ['document', 'gallery', 'markdown', 'node', 'node_collection']))
            {
                $mutatables[] = "'{$field->name}' => '{$field->type}'";
            }
        }

        return implode(",", $mutatables);
    }
920682
def mutate_stream (instream, outstream):
    """"""

    chunk = None
    key = None
    data = None
    misclines = []

    for fullline in instream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New chunk
            if chunk is not None:
                if key is not None:
                    chunk.data.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield chunk
                chunk.emit (outstream)

            chunk = FileChunk ()
            for miscline in misclines:
                chunk._addLine (miscline, None)
            misclines = []
            chunk.data.section = m.group (1)
            chunk._addLine (fullline, None)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            if chunk is not None:
                chunk._addLine (fullline, None)
            else:
                misclines.append (fullline)
            continue

        m = escre.match (fullline)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            chunk.data.set_one (key, data.decode ('utf8'))
            chunk._addLine (fullline, key)
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if chunk is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                chunk.data.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not data[-1].isspace ():
                data += ' '
            chunk._addLine (fullline, key)
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            chunk._addLine (fullline, key)
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if chunk is not None:
        if key is not None:
            chunk.data.set_one (key, data.strip ().decode ('utf8'))
        yield chunk
        chunk.emit (outstream)
630649
def _set(self, instance, value, **kw):
        
        logger.debug("ATFieldManager::set: value=%r" % value)

        # check field permission
        if not self.field.checkPermission("write", instance):
            raise Unauthorized("You are not allowed to write the field {}"
                               .format(self.name))

        # check if field is writable
        if not self.field.writeable(instance):
            raise Unauthorized("Field {} is read only."
                               .format(self.name))

        # id fields take only strings
        if self.name == "id":
            value = str(value)

        # get the field mutator
        mutator = self.field.getMutator(instance)

        # Inspect function and apply *args and **kwargs if possible.
        mapply(mutator, value, **kw)

        return True
1065013
function() {
    this.appendDummyInput()
        .appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE);
    this.appendStatementInput('STACK');
    this.appendDummyInput('STATEMENT_INPUT')
        .appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS)
        .appendField(new Blockly.FieldCheckbox('TRUE'), 'STATEMENTS');
    this.setColour(Blockly.Blocks.procedures.HUE);
    this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);
    this.contextMenu = false;
  }
828380
function MUTATE_PROP_x(state, payload, PROP_SUBPROP, conf, propValue) {
    if (!isWhat.isArray(payload))
        payload = [payload];
    var ids = getIdsFromPayload(payload, conf, PROP_SUBPROP);
    if (!checkIdWildcardRatio(ids, PROP_SUBPROP, conf))
        return;
    var lastId = ids.pop();
    var propPathWithoutLast = PROP_SUBPROP.slice(0, -1);
    var pathWithIds = fillinPathWildcards(ids, propPathWithoutLast, state, conf);
    var ref = getDeepRef(state, pathWithIds);
    var newValue = getValueFromPayloadPiece(payload.pop());
    if (isWhat.isObject(newValue))
        newValue.id = lastId;
    if (isWhat.isObject(propValue))
        newValue = merge(propValue, newValue);
    return Vue.set(ref, lastId, newValue);
}
826765
def iterate_over_fields(cls):
        """"""
        for attr in dir(cls):
            clsattr = getattr(cls, attr)
            if isinstance(clsattr, BaseField):
                yield attr, clsattr
545113
function(opt_paramIds) {
    var container = document.createElement('mutation');
    if (opt_paramIds) {
      container.setAttribute('name', this.getFieldValue('NAME'));
    }
    for (var i = 0; i < this.arguments_.length; i++) {
      var parameter = document.createElement('arg');
      parameter.setAttribute('name', this.arguments_[i]);
      if (opt_paramIds && this.paramIds_) {
        parameter.setAttribute('paramId', this.paramIds_[i]);
      }
      container.appendChild(parameter);
    }

    // Save whether the statement input is visible.
    if (!this.hasStatements_) {
      container.setAttribute('statements', 'false');
    }
    return container;
  }
272383
def fix_additional_fields(data):
        """"""
        result = dict()
        for key, value in data.items():
            if isinstance(value, dict):
                result.update(KserSpan.to_flat_dict(key, value))
            else:
                result[key] = value
        return result