(self, block, lineno, indent, filename)
return block
Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).
Refactors one doctest.
Refactors one doctest .
def refactor_doctest(self, block, lineno, indent, filename):
        """Refactors one doctest.

        A doctest is given as a block of lines, the first of which starts
        with ">>>" (possibly indented), while the remaining lines start
        with "..." (identically indented).

        """
        try:
            tree = self.parse_block(block, lineno, indent)
        except Exception as err:
            if self.logger.isEnabledFor(logging.DEBUG):
                for line in block:
                    self.log_debug("Source: %s", line.rstrip("\n"))
            self.log_error("Can't parse docstring in %s line %s: %s: %s",
                           filename, lineno, err.__class__.__name__, err)
            return block
        if self.refactor_tree(tree, filename):
            new = str(tree).splitlines(keepends=True)
            # Undo the adjustment of the line numbers in wrap_toks() below.
            clipped, new = new[:lineno-1], new[lineno-1:]
            assert clipped == ["\n"] * (lineno-1), clipped
            if not new[-1].endswith("\n"):
                new[-1] += "\n"
            block = [indent + self.PS1 + new.pop(0)]
            if new:
                block += [indent + self.PS2 + line for line in new]
        return block
def refactor_doctest ( self , block , lineno , indent , filename ) : try : tree = self . parse_block ( block , lineno , indent ) except Exception as err : if self . logger . isEnabledFor ( logging . DEBUG ) : for line in block : self . log_debug ( "Source: %s" , line . rstrip ( "\n" ) ) self . log_error ( "Can't parse docstring in %s line %s: %s: %s" , filename , lineno , err . __class__ . __name__ , err ) return block if self . refactor_tree ( tree , filename ) : new = str ( tree ) . splitlines ( keepends = True ) # Undo the adjustment of the line numbers in wrap_toks() below. clipped , new = new [ : lineno - 1 ] , new [ lineno - 1 : ] assert clipped == [ "\n" ] * ( lineno - 1 ) , clipped if not new [ - 1 ] . endswith ( "\n" ) : new [ - 1 ] += "\n" block = [ indent + self . PS1 + new . pop ( 0 ) ] if new : block += [ indent + self . PS2 + line for line in new ] return block