'Un-block comment current line or selection'

def unblockcomment(self):

    def __is_comment_bar(cursor):
        return to_text_string(cursor.block().text()).startswith(self.__blockcomment_bar())
    cursor1 = self.textCursor()
    if __is_comment_bar(cursor1):
        return
    while (not __is_comment_bar(cursor1)):
        cursor1.movePosition(QTextCursor.PreviousBlock)
        if cursor1.atStart():
            break
    if (not __is_comment_bar(cursor1)):
        return
    def __in_block_comment(cursor):
        cs = self.comment_string
        return to_text_string(cursor.block().text()).startswith(cs)
    cursor2 = QTextCursor(cursor1)
    cursor2.movePosition(QTextCursor.NextBlock)
    while ((not __is_comment_bar(cursor2)) and __in_block_comment(cursor2)):
        cursor2.movePosition(QTextCursor.NextBlock)
        if (cursor2.block() == self.document().lastBlock()):
            break
    if (not __is_comment_bar(cursor2)):
        return
    cursor3 = self.textCursor()
    cursor3.beginEditBlock()
    cursor3.setPosition(cursor1.position())
    cursor3.movePosition(QTextCursor.NextBlock)
    while (cursor3.position() < cursor2.position()):
        cursor3.setPosition((cursor3.position() + 2), QTextCursor.KeepAnchor)
        cursor3.removeSelectedText()
        cursor3.movePosition(QTextCursor.NextBlock)
    for cursor in (cursor2, cursor1):
        cursor3.setPosition(cursor.position())
        cursor3.select(QTextCursor.BlockUnderCursor)
        cursor3.removeSelectedText()
    cursor3.endEditBlock()
