Extract from a udiff an iterator of tuples of (start, end) line
    numbers.
500256
def modified_lines_from_udiff(udiff):
    """"""
    chunks = re.split('\n@@ [^\n]+\n', udiff)[1:]

    line_numbers = re.findall('@@\s[+-]\d+,\d+ \+(\d+)', udiff)
    line_numbers = list(map(int, line_numbers))

    for c, start in zip(chunks, line_numbers):
        ilines = enumerate((line for line in c.splitlines()
                            if not line.startswith('-')),
                           start=start)
        added_lines = [i for i, line in ilines if line.startswith('+')]
        if added_lines:
            yield (added_lines[0], added_lines[-1])
623964
def diff_lines(self):
    """"""
    start_lines = self._build_file_source_lines[:]
    end_lines = self.build_file_lines()
    diff_generator = unified_diff(start_lines,
                                  end_lines,
                                  fromfile=self.build_file.relpath,
                                  tofile=self.build_file.relpath,
                                  lineterm='')
    return list(diff_generator)
435589
def _find_terminator(self, iterator):
        
        for line in iterator:
            if not line:
                break
            line = line.strip()
            if line:
                return line
        return b""
1314533
private Tuple getNextTuple()
    {
    if( nextTuple_ == null)
      {
      // Still traversing values for current start variable?
      int tupleSize = getTupleSize();
      if( !(values_ != null && values_.hasNext()))
        {
        // No, still traversing subtuples for current start variable?
        values_ = null;
        subTuple_ = null;
        if( !(subTuples_ != null && subTuples_.hasNext()))
          {
          // No, advance to next start variable.
          subTuples_ = null;
          varStart_++;
          if( tupleSize > 1)
            {
            for( ;
                 varStart_ < varEnd_
                   &&
                   (subTuples_ = new TupleIterator( tupleSize - 1, varDefs_.subList( varStart_ + 1, varDefs_.size()), randSeq_))
                   .hasNext() == false;

                 varStart_++);
            }
          }
        }

      // More tuples remaining?
      if( varStart_ < varEnd_)
        {
        VarDef startVarDef = varDefs_.get( varStart_);
        if( values_ == null)
          {
          // Resume traversing values for current start variable.
          values_ = RandSeq.reorderIf( randSeq_, startVarDef.getValidValues());
          if( !values_.hasNext())
            {
            throw new IllegalStateException( "Can't complete tuples -- no valid values defined for var=" + startVarDef);
            }
          if( tupleSize > 1)
            {
            // Advance to next subtuple for current start variable.
            subTuple_ = subTuples_.next();
            }
          }

        nextTuple_ = new Tuple();
        nextTuple_.add( new VarBindingDef( startVarDef, values_.next()));
        if( subTuple_ != null)
          {
          nextTuple_.addAll( subTuple_);
          }
        }
      }

    return nextTuple_;
    }
1085899
def line_numbers
      return (line..line) unless @value && text

      end_line = line + lines.count
      end_line = nontrivial_end_line if line == end_line

      (line..end_line)
    end
1108972
def window(seq, n=2):

    

    it = iter(seq)
    result = tuple(islice(it, n))

    if len(result) == n:
        yield result

    for token in it:
        result = result[1:] + (token,)
        yield result
403408
def line_range(self, line_number):
    """"""
    if line_number <= 0 or line_number > len(self.lines):
      raise IndexError('NOTE: Python file line numbers are offset by 1.')

    if line_number not in self.logical_lines:
      return slice(line_number, line_number + 1)
    else:
      start, stop, _ = self.logical_lines[line_number]
      return slice(start, stop)
27046
def get_line_number (s, index):
    """
    i = 0
    if index < 0:
        return 0
    line = 1
    while i < index:
        if s[i] == '\n':
            line += 1
        i += 1
    return line
698371
def _chunk_from_ranges(contents_lines,
                       start_line_index,
                       start_column_index,
                       end_line_index,
                       end_column_index):
    
    # If the start and end line are the same we have to compensate for
    # that by subtracting start_column_index from end_column_index
    if start_line_index == end_line_index:
        end_column_index -= start_column_index

    lines = contents_lines[start_line_index:end_line_index + 1]
    lines[0] = lines[0][start_column_index:]
    lines[-1] = lines[-1][:end_column_index]

    return _ChunkInfo(start_line_index,
                      start_column_index,
                      lines)
191254
def iter_cols(self, start=None, end=None):
        """"""
        start = start or 0
        end = end or self.ncols
        for i in range(start, end):
            yield self.iloc[:, i]
254524
def lines(input):
    """"""
    for raw_line in input:
        line = raw_line.strip()
        if line and not line.startswith('#'):
            yield strip_comments(line)
209883
def trim(sequences, start, end):
    
    logging.info("Trimming from %d to %d", start, end)
    return (sequence[start:end] for sequence in sequences)
602306
def getlines(self, bufnr=None):
        
        buf = self._vim.buffers[bufnr] if bufnr else self._vim.current.buffer
        return buf[:]
560304
def find_line_beginning(strings: Sequence[str],
                        linestart: Optional[str]) -> int:
    
    if linestart is None:  # match an empty line
        for i in range(len(strings)):
            if is_empty_string(strings[i]):
                return i
        return -1
    for i in range(len(strings)):
        if strings[i].find(linestart) == 0:
            return i
    return -1
923365
def getlines(fname):
    

    with open(fname, 'rU') as f:
        for line in f:
            if line.strip() and not line.startswith('#'):
                yield line.split('#', 1)[0].strip()
183486
def pp_tuple(self, tup):
        """"""
        last_line = self.f.getvalue().split("\n")[-1]
        l = len(last_line)+1
        indent = ' ' * l
        self.write('(')
        sep = ''
        for item in tup:
            self.write(sep)
            l += len(sep)
            s = repr(item)
            l += len(s)
            self.write(s)
            sep = ','
            if l > LINE_LENGTH:
                l = 0
                sep += '\n' + indent
            else:
                sep += ' '
                pass
            pass
        if len(tup) == 1:
            self.write(", ")
        self.write(')')
1284314
def get_block_start(lines, lineno, maximum_indents=80):
    """"""
    pattern = get_block_start_patterns()
    for i in range(lineno, 0, -1):
        match = pattern.search(lines.get_line(i))
        if match is not None and \
           count_line_indents(lines.get_line(i)) <= maximum_indents:
            striped = match.string.lstrip()
            # Maybe we're in a list comprehension or generator expression
            if i > 1 and striped.startswith('if') or striped.startswith('for'):
                bracs = 0
                for j in range(i, min(i + 5, lines.length() + 1)):
                    for c in lines.get_line(j):
                        if c == '#':
                            break
                        if c in '[(':
                            bracs += 1
                        if c in ')]':
                            bracs -= 1
                            if bracs < 0:
                                break
                    if bracs < 0:
                        break
                if bracs < 0:
                    continue
            return i
    return 1