Applies a list of simple actions to apply to each provided item, in order to accumulate field values.
Provides a list of parsed `fields`.
Calls `callback(error, this)` when all accumulators were processed, or when processing a null item.
323492
function SequentialParser(accumulators, callback) {
  var step = 0;
  var fields = {};
  return {
    fields: fields,
    addField: function(key, value) {
      this.fields[key] = value;
    },
    parseItem: function(item) {
      if (step >= accumulators.length) {
        return console.warn(
          "warning: skipping item, because SequentialParser is done."
        );
      }
      var current = accumulators[step];
      if (current.field) {
        this.addField(current.field, item);
        ++step;
      } else if (current.accumulator) {
        var doneAccumulating = current.accumulator(item, this);
        if (doneAccumulating) ++step;
      } // no action => skip item
      else ++step;
      if (!item || step >= accumulators.length) {
        callback && callback(null, this);
      }
    }
  };
}
54016
def performAction(self, action):
        
        self._lastAction = []

        # Markups chosen for each generator.
        actions = self._allActions[action]

        n = self.numOffbids * len(self.generators)
        markups = actions[:n]
        withholds = actions[n:]

#        print "ALL ACTIONS:", self._allActions
#        print "ACTIONS:", markups, withholds

        self._offbid(markups, withholds)
529727
def _update_field(self, action, field, value, max_tries, tries=0):
        
        # Refresh our view of the document.
        self.fetch()

        # Update the field.
        action(self, field, value)

        # Attempt to save, retrying conflicts up to max_tries.
        try:
            self.save()
        except requests.HTTPError as ex:
            if tries < max_tries and ex.response.status_code == 409:
                self._update_field(
                    action, field, value, max_tries, tries=tries+1)
            else:
                raise
631674
def apply(self, collection, data):
        """"""
        value = self.value(data)
        if value is self.default:
            return collection
        return [o for o in collection if getattr(o, self.name, None) == value]
917498
def _apply_list(self, methods):
    
    def call(value):
      for method in methods:
        newvalue = method(self, value)
        if newvalue is not None:
          value = newvalue
      return value
    return call
154134
def each_do(action: Callable[[T], None]):
    

    def inner(collection: ActualIterable[T]):
        for each in collection:
            action(each)

    return inner
932490
def add_fields(self, fields):
        
        for field in fields:
            cls = field.__class__
            try:
                container = FieldsContainer.class_container[cls]
            except KeyError:
                raise ValueError('Object of type %s is an invalid field' % cls)
            getattr(self, container).append(field)
1119541
function updateActions() {
        this.plugin('done', function () {
          var cmd;
          if (envOptions['update-actions']) {
            // Don't disable actions since this is mostly for development.
            cmd = 'python manage.py update_actions';

            childProcess.exec(cmd, function (err, stdout, stderr) {
              console.log('\n' + BOLD + 'Updating Actions' + END_BOLD);
              console.log(stdout);
              if (stderr) {
                console.error(stderr);
              }
            });
          }
        });
      }
60868
def process(self, obj, pk_set=None, action=None, update_fields=None, **kwargs):
        """"""
        build_kwargs = self._get_build_kwargs(obj, pk_set, action, update_fields, **kwargs)

        if build_kwargs:
            self.index.build(**build_kwargs)
1059005
def add_field(field, func, dict_sequence):
    
    for item in dict_sequence:
        if field not in item:
            item[field] = func(item)
        yield item
1346802
function(collection){
	Array.apply(this);
	if(arguments.length >= 1){
		for(var i=0,len = collection.length;i<len;i++){
			var item = collection[i];
			if(this.indexOf(item) < 0){
				this.push(item);
			}
		}
	}
 }
48132
function (callback, a, b, c, d, e) {
	    var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;

	    ReactDefaultBatchingStrategy.isBatchingUpdates = true;

	    // The code is written this way to avoid extra allocations
	    if (alreadyBatchingUpdates) {
	      callback(a, b, c, d, e);
	    } else {
	      transaction.perform(callback, null, a, b, c, d, e);
	    }
	  }
869232
def _attach_fields(obj):
    
    for attr in base_fields.__all__:
        if not hasattr(obj, attr):
            setattr(obj, attr, getattr(base_fields, attr))
    for attr in fields.__all__:
        setattr(obj, attr, getattr(fields, attr))
8761
public void accumulate(Object workingMemoryContext,
                           Object context,
                           Tuple leftTuple,
                           InternalFactHandle handle,
                           Declaration[] declarations,
                           Declaration[] innerDeclarations,
                           WorkingMemory workingMemory) throws Exception {
        Object value = this.unwrapHandle ? ((LeftTuple) handle.getObject()).getFactHandle().getObject() : handle.getObject();
        ((CollectContext) context).result.add( value );
    }
983092
def append_fields(self, new_fields):
        '''
        
        '''
        for field in new_fields:
            self.push(field)
            if isinstance(field, Container):
                self.pop()
1089542
def write(self, values):
        
        # Insert only for docs targeted by the target
        filtered = {_id: value for _id, value in values.items() if _id in self._document_ids}

        if not filtered:
            return

        bulk = self.get_collection().initialize_ordered_bulk_op()
        for _id, value in filtered.items():
            bulk.find({'_id': _id}).upsert() \
                    .update_one({'$set': {self._field: value}})

        bulk.execute()
1042880
def populate_values(self, rows, field):
        
        self._values.clear()
        for row in rows:
            condition = SimpleConditionFactory.create_condition(self._field, row[field])
            if condition.scheme == 'plain':
                self._values.append(condition.expression)
            else:
                self._conditions.append(condition)