def unIndentBlock(block):
            currentIndent = blockIndentation(block)

            if currentIndent.endswith('\t'):
                charsToRemove = 1
            elif withSpace:
                charsToRemove = 1 if currentIndent else 0
            else:
                if self.useTabs:
                    charsToRemove = min(spacesCount(currentIndent), self.width)
                else:  # spaces
                    if currentIndent.endswith(self.text()):  # remove indent level
                        charsToRemove = self.width
                    else:  # remove all spaces
                        charsToRemove = min(spacesCount(currentIndent), self.width)

            if charsToRemove:
                cursor = cursorAtSpaceEnd(block)
                cursor.setPosition(cursor.position() - charsToRemove, QTextCursor.KeepAnchor)
                cursor.removeSelectedText()
def log_stream(self, logger_name, level_name, format_str):
        """ Attaches a log handler to the specified logger and sends emitted logs 
            back as stream. 
        """
        if logger_name != "" and logger_name not in self.available_loggers():
            raise ValueError("logger {0} is not available".format(logger_name))

        level_name_upper = level_name.upper() if level_name else "NOTSET"
        try:
            level = getattr(logging, level_name_upper)
        except AttributeError, e:
            raise AttributeError("log level {0} is not available".format(level_name_upper))