Iterator for lines passing |line, original_line_number, modified_line_number| as block arguments
166708
def each_line
      original_line_number = @original_line_number
      modified_line_number = @modified_line_number

      @lines.each do |line|
        if line.addition?
          yield line, nil, modified_line_number
          modified_line_number += 1
        elsif line.deletion?
          yield line, original_line_number, nil
          original_line_number += 1
        elsif line.unchanged?
          yield line, original_line_number, modified_line_number
          original_line_number += 1
          modified_line_number += 1
        else
          yield line
        end
      end
    end
350894
def blocks(self, lines):
        """"""
        state = markdown.blockparser.State()
        blocks = []

        # We use three states: start, ``` and '\n'
        state.set('start')

        # index of current block
        currblock = 0

        for line in lines:
            line += '\n'
            if state.isstate('start'):
                if line[:3] == '```':
                    state.set('```')
                else:
                    state.set('\n')
                blocks.append('')
                currblock = len(blocks) - 1
            else:
                marker = line[:3]  # Will capture either '\n' or '```'
                if state.isstate(marker):
                    state.reset()
            blocks[currblock] += line

        return blocks
1372247
def input_iterator
      return arguments.each unless arguments.empty?
      return IO.foreach(options[:input]) if options[:input]

      $stdin.each_line
    end
28203
function iterator(params, cmd, p)
{
  var value = params[p];

  // shortcut
  if (!cmd) return cmd;

  // fold booleans into strings accepted by shell
  if (typeof value == 'boolean')
  {
    value = value ? '1' : '';
  }

  if (value !== null && ['undefined', 'string', 'number'].indexOf(typeof value) == -1)
  {
    // empty out cmd to signal the error
    return '';
  }

  // use empty string for `undefined`
  return cmd.replace(new RegExp('\\$\\{' + p + '\\}', 'g'), (value !== undefined && value !== null) ? value : '');
}
687631
def readlines(self, *args, **kwargs):
        """"""
        return list(iter(partial(self.readline, *args, **kwargs), u''))
664867
def blocks(self, *args, **kwargs):
    
    return Stream(blocks(iter(self), *args, **kwargs))
67274
def iter_file_commands(self):
        
        while True:
            line = self.next_line()
            if line is None:
                break
            elif len(line) == 0 or line.startswith(b'#'):
                continue
            # Search for file commands in order of likelihood
            elif line.startswith(b'M '):
                yield self._parse_file_modify(line[2:])
            elif line.startswith(b'D '):
                path = self._path(line[2:])
                yield commands.FileDeleteCommand(path)
            elif line.startswith(b'R '):
                old, new = self._path_pair(line[2:])
                yield commands.FileRenameCommand(old, new)
            elif line.startswith(b'C '):
                src, dest = self._path_pair(line[2:])
                yield commands.FileCopyCommand(src, dest)
            elif line.startswith(b'deleteall'):
                yield commands.FileDeleteAllCommand()
            else:
                self.push_line(line)
                break
870960
def load_lines(self, key, noexpire=None):
        ''''''
        return line_iterator(self.load_fd(key, noexpire=noexpire))
983645
def _paste_tokens_line_by_line(tokens, token_type, begin, end):
    """"""
    block_index = begin

    while block_index < end:
        rst_line = tokens[block_index].line
        line_traversal_index = block_index
        pasted = ""
        try:
            while tokens[line_traversal_index].line == rst_line:
                pasted += tokens[line_traversal_index].content
                line_traversal_index += 1
        except IndexError:
            assert line_traversal_index == end

        last_tokens_len = len(tokens)
        tokens = _replace_token_range(tokens,
                                      block_index,
                                      line_traversal_index,
                                      [Token(type=token_type,
                                             content=pasted,
                                             line=tokens[block_index].line,
                                             col=tokens[block_index].col)])
        end -= last_tokens_len - len(tokens)
        block_index += 1

    return (block_index, len(tokens), tokens)
996729
def normal_iterator(first_line, next_lines, &block)
      Enumerator.new do |y|
        y << first_line
        loop do
          y << next_lines.next
        end
      end.each_slice(batch_size).with_index(&block)
    end
719450
def blocks(self, ignore_blank_lines=True):
        
        start, end = self.get_range(ignore_blank_lines=ignore_blank_lines)
        block = self._trigger.next()
        while block.blockNumber() <= end and block.isValid():
            yield block
            block = block.next()
848086
def iterateBlocksBackFrom(block):
        
        count = 0
        while block.isValid() and count < MAX_SEARCH_OFFSET_LINES:
            yield block
            block = block.previous()
            count += 1
1215521
def writelines(self, lines):
        '''
            
        '''
        if self.__closed:
            raise OSError()
        for line in lines:
            self.write(line)
612811
def iterlines(s):
    
    prevnl = -1
    while True:
        nextnl = s.find('\n', prevnl + 1)
        if nextnl < 0:
            yield s[(prevnl+1):]
            break
        else:
            yield s[(prevnl+1):nextnl]
            prevnl = nextnl
715002
def iter_token_lines(tokenlist):
    
    line = []
    for token, c in explode_tokens(tokenlist):
        line.append((token, c))

        if c == '\n':
            yield line
            line = []

    yield line
1315719
def iter_lines(self, warn_only=False):
        """"""
        remain = ""
        for data in self.iter_content(LINE_CHUNK_SIZE, warn_only=True):
            line_break_found = data[-1] in (b"\n", b"\r")
            lines = data.decode(self.codec).splitlines()
            lines[0] = remain + lines[0]
            if not line_break_found:
                remain = lines.pop()
            for line in lines:
                yield line
        if remain:
            yield remain

        self._state = FINISHED
        if not warn_only:
            self.raise_for_error()
182488
def at_line(self, line: FileLine) -> Iterator[Statement]:
        
        num = line.num
        for stmt in self.in_file(line.filename):
            if stmt.location.start.line == num:
                yield stmt