Block processing function & callbacks
482865
protected function process_block_rule($name, $block) {
        $this->rulestack[] = array('callback' => method_exists($this, $name."_block_rule") ? $name."_block_rule" : null, 'rule' => $block);

        $this->string = preg_replace_callback($block['expression'], array($this, 'block_callback'), $this->string);

        array_pop($this->rulestack);
    }
327347
function BlockData(index, buf, cb, count) {
  this.index = index;
  this.buf = buf;
  this.cb = cb;
  this.count = count | 0;
}
369684
def process_block(self, block):
        
        ret = []
        output = None
        input_lines = None
        lineno = self.IP.execution_count

        input_prompt = self.promptin % lineno
        output_prompt = self.promptout % lineno
        image_file = None
        image_directive = None

        for token, data in block:
            if token == COMMENT:
                out_data = self.process_comment(data)
            elif token == INPUT:
                (out_data, input_lines, output, is_doctest, decorator,
                    image_file, image_directive) = \
                          self.process_input(data, input_prompt, lineno)
            elif token == OUTPUT:
                out_data = \
                    self.process_output(data, output_prompt,
                                        input_lines, output, is_doctest,
                                        decorator, image_file)
            if out_data:
                ret.extend(out_data)

        # save the image files
        if image_file is not None:
            self.save_image(image_file)

        return ret, image_directive
1081701
function processBlocks(textString, options, data) {

	var replacer = function replacer(match, $1, $2, $3, $4, $5, $6, offset, input) {
		var out = '',
			dataValue,
			type = String($2),
			key = String($3 || '').trim(),
			blockText = String($5),
			nestedBlocks;

		dataValue = _extract(key, data);

		if (options && typeof options === 'object' && options.strictKeys) {
			if(Number.isNaN(dataValue)) {
				return match;
			}
		}

		nestedBlocks = blockText.match(pattern);
		if (nestedBlocks) {
			blockText = blockText.replace(pattern, function(match, $1, $2, $3, $4, $5, $6, offset, input) {
				var index = match.indexOf($5);
				var length = $5.length;
				var body = $5.replace(/(?:\\*)\[(.+?)(?:\\*)\]/g, "\\[$1]");
				return match.substr(0, index) + body + match.substr(index + length);
			});
		}

		var obj = {}, proto = {}, KEY;
		if (typeof dataValue === 'object' && type === '#') {
			for(KEY in dataValue) {
				obj = {}, proto = {};
				proto.KEY = proto.INDEX = KEY;
				obj[KEY] = proto.VALUE = dataValue[KEY];
				obj.__proto__ = proto;
				if (typeof dataValue[KEY] === 'object' && !isNaN(parseInt(KEY))) {
					obj = dataValue[KEY];
					obj.__proto__ = proto;
				}
				out += renderData(blockText, options, obj, Boolean(options.prefix));
			}
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (dataValue && (type === '~' || type === '#')) {
			// block logical truthy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		} else if (!dataValue && (type === '^' || type === '!')) {
			// block logical falsy
			proto.KEY = proto.INDEX = key;
			proto.VALUE = Boolean(dataValue);
			obj = data;
			obj.__proto__ = proto;

			out += renderData(blockText, options, obj, Boolean(options.prefix));
			if (nestedBlocks) {
				out = processBlocks(out, options, data);
			}
		}
		return out;
	};

	var pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)([^\\r\\n]+)\\s*\\])([\\s]?)([\\s\\S]*?)(\\[\\s*\\/\\3\\s*\\]\\4?)', 'mg');

	if(typeof data === 'object' && data !== null) {
		if (options && typeof options === 'object' && options.prefix) {
			pattern = new RegExp('(\\[\\s*(~|\\^|\\!|#)'+rxquote(String(options.prefix))+'[\\.\\-\\_]([^\\r\\n]+)\\s*\\])(\\s?)([\\s\\S]*?)(\\[\\s*\\/'+rxquote(String(options.prefix))+'[\\.\\-\\_]\\3\\s*\\]\\4?)', 'mg');
		}
		textString = textString.replace(pattern, replacer);
	}

	return textString;
}
642981
def blocks(self):
        
        if not self.is_function:
            raise ValueError('expected function value, got %s' % (self._kind,))
        it = ffi.lib.LLVMPY_FunctionBlocksIter(self)
        parents = self._parents.copy()
        parents.update(function=self)
        return _BlocksIterator(it, parents)
615828
function () {
    const oThis = this
    ;

    oThis.snmData.lastProcessedBlock = oThis.toBlock;

    fs.writeFileSync(
      oThis.filePath,
      JSON.stringify(oThis.snmData),
      function (err) {
        if (err)
          logger.error(err);
      }
    );

    if (oThis.interruptSignalObtained) {
      logger.info('Exiting Process....');
      process.exit(1);
    }
  }
888811
def processing_blocks(self):
        
        sbi_ids = Subarray(self.get_name()).sbi_ids
        pbs = []
        for sbi_id in sbi_ids:
            sbi = SchedulingBlockInstance(sbi_id)
            pbs.append(sbi.processing_block_ids)
        return 'PB', pbs
463456
function handleCallback(query, q, model, resultsPerPage, callback) {
  return async.parallel({
    results: function(callback) {
      query.exec(callback);
    },
    count: function(callback) {
      model.count(q, function(err, count) {
        callback(err, count);
      });
    }
  }, function(error, data) {
    if (error) {
      return callback(error);
    }
    callback(null, data.results, Math.ceil(data.count / resultsPerPage) || 1, data.count);
  });
}
930929
function (blockList) {
        this.errors = [];
        this.tree = new Node("file", null);
        this.tree.content = [];

        this._advance(blockList, 0, this.tree.content);

        this._postProcessTree();
    }
721970
function (callback) {
    return function (err, stdout, stderr) {
        if (err) {
            throw err;
        } else if (stderr) {
            log('sync error', 'failed with the following output:');
            console.log('\n', stderr, '\n');
        } else {
            log('sync', 'completed successfully');
            log();
            if (callback) callback();
        }
    };
}
456952
function () {
    const oThis = this;

    process.on('SIGINT', function () {
      logger.info("Received SIGINT, cancelling block scaning");
      oThis.interruptSignalObtained = true;
    });
    process.on('SIGTERM', function () {
      logger.info("Received SIGTERM, cancelling block scaning");
      oThis.interruptSignalObtained = true;
    });
  }
644448
function process( $tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace )
    {
        if ( count( $functionParameters ) == 0 || !count( $functionParameters['condition'] ) )
        {
            eZDebug::writeError( "Not enough arguments passed to 'if' function." );
            return;
        }

        $ifValue = $tpl->elementValue( $functionParameters['condition'], $rootNamespace, $currentNamespace, $functionPlacement );

        $show        = $ifValue; // whether to show the child being currently processing
        $showWasTrue = $show;    // true if $show has been assigned 'true' value at least once in the current {if}...{/if} block.
        $foundElse   = false;    // true if 'else' has been met once in the current {if}...{/if} block.

        if ( !is_array( $functionChildren ) )
        {
            return;
        }
        foreach ( $functionChildren as $key => $child )
        {
            $childType = $child[0];

            // parse 'elseif', 'else' functions
            if ( $childType == eZTemplate::NODE_FUNCTION )
            {
                $childFunctionName      =& $child[2];
                $childFunctionArgs      =& $child[3];
                $childFunctionPlacement =& $child[4];

                if ( $childFunctionName == 'else' )
                {
                    if ( $foundElse  )
                    {
                        eZDebug::writeError( "Duplicated 'else'" );
                        $show = false;
                        continue;
                    }

                    $show = !$showWasTrue;
                    $foundElse = true;
                    continue;
                }
                elseif ( $childFunctionName == 'elseif' )
                {
                    if ( $foundElse  )
                    {
                        eZDebug::writeError( "There should be no more 'elseif' after 'else'" );
                        $show = false;
                        continue;
                    }

                    if ( !isset( $childFunctionArgs['condition'] ) || !count( $childFunctionArgs['condition'] ) ) // no arguments passes to 'elseif' (should not happen)
                        $elseifValue = false;
                    else
                        $elseifValue = $tpl->elementValue( $childFunctionArgs['condition'], $rootNamespace, $currentNamespace, $functionPlacement );

                    if ( !$showWasTrue && $elseifValue )
                        $show = $showWasTrue = true;
                    else
                        $show = false;
                    continue;
                }
                elseif ( $childFunctionName == 'break' )
                {
                    if ( !$show )
                            continue;
                    return array( 'breakFunctionFound' => 1 );
                }
                elseif ( $childFunctionName == 'continue' )
                {
                    if ( !$show )
                            continue;
                    return array( 'continueFunctionFound' => 1 );
                }
                elseif ( $childFunctionName == 'skip' )
                {
                    if ( !$show )
                            continue;
                    return array( 'skipFunctionFound' => 1 );
                }
            }

            if ( $show )
            {
                $rslt = $tpl->processNode( $child, $textElements, $rootNamespace, $currentNamespace );

                // handle 'break', 'continue' and 'skip'
                if ( is_array( $rslt ) && ( array_key_exists( 'breakFunctionFound', $rslt ) ||
                                            array_key_exists( 'continueFunctionFound', $rslt )  ||
                                            array_key_exists( 'skipFunctionFound', $rslt ) ) )
                {
                    return $rslt;
                }
            }
        }
    }
555057
function( size, step, limit, callback ) {

    var args = [].slice.call( arguments )
    callback = args.pop()

    if( this.fd == null )
      return callback.call( this, new Error( 'Invalid file descriptor' ) )

    limit = args.pop() || 0x2000
    step  = args.pop() || 0x80
    size  = args.pop() || 0x200

    var self = this

    var readBlock = function() {

      var block = Buffer.allocUnsafe( size )

      self.fs.read( self.fd, block, 0, size, 0, function( error, bytesRead ) {

        if( error != null ) {
          // EINVAL tells us that the block size
          // ain't just right (yet); everything
          // else is probably user error
          if( error.code !== 'EINVAL' )
            return callback.call( self, error )
          // Increase the blocksize by `step`
          size += step
          // Attempt next size read
          return readBlock()
        }

        // Check if bytes read correspond
        // to current block size
        if( size !== bytesRead ) {
          error = new Error( 'Size and bytes read mismatch: ' + size + ', ' + bytesRead )
          return callback.call( self, error )
        }

        // Check if the limit has been reached,
        // and terminate with error, if so
        if( size > limit ) {
          error = new Error( 'Reached limit of ' + limit + ' bytes' )
          return callback.call( self, error )
        }

        // We've successfully found the
        // smallest readable block size;
        // stop looking...
        self.blockSize = size
        callback.call( self, null, size )

      })

    }

    // Start reading blocks
    readBlock()

    return this

  }
215680
function processAsBuffer( file ) {
	return function( callback ) {
		var json = JSON.parse(file.contents);
		callback( json, path.dirname(file.path) );
	}
}
127414
def _do_bgread(stream, blockSizeLimit, pollTime, closeStream, results):
    '''
        
    '''

    # Put the whole function in a try instead of just the read portion for performance reasons.
    try:
        while True:
            nextData = nonblock_read(stream, limit=blockSizeLimit)
            if nextData is None:
                break
            elif nextData:
                results.addBlock(nextData)

            time.sleep(pollTime)
    except Exception as e:
        results.error = e
        return

    if closeStream and hasattr(stream, 'close'):
        stream.close()

    results.isFinished = True
612097
function _process(templates, params, cb) {
    var _templates = _.extend(templates, {}), // process template copies, not the originals
      tasks = {};

    _.keys(_templates).forEach(function (key) {
      tasks[key] = function (cb) {
        _templates[key].process(params, function (data) {
          cb(null, data);
        });
      };
    });

    async.parallel(tasks, function (err, results) {
      cb(results);
    });
  }
1307035
function(callback){
    var result,
        i;

    if(!files || files.length === 0){
        return callback(null, true);
    }

    output("Processing queries...");

    for(i=0; i<files.length; i++){
        while((result = cqlRegex.exec(files[i])) !== null) {
            batchQueries.push(result[1].replace(/\s+/g, ' ').trim());
        }
    }

    callback(null, true);
}