def get_indent_fix(text, indent_chars=(' ' * 4), tab_stop_width_spaces=4, sol=False):
 app = qapplication()
 editor = CodeEditor(parent=None)
 editor.setup_editor(language='Python', indent_chars=indent_chars, tab_stop_width_spaces=tab_stop_width_spaces)
 editor.set_text(text)
 cursor = editor.textCursor()
 cursor.movePosition(QTextCursor.End)
 if sol:
  lines = text.splitlines(True)
  repeat = len(lines[(-1)].lstrip())
  cursor.movePosition(QTextCursor.Left, n=repeat)
 editor.setTextCursor(cursor)
 editor.fix_indent()
 return to_text_string(editor.toPlainText())

def get_indent_fix ( text , indent_chars = ( ' ' * 4 ) , tab_stop_width_spaces = 4 , sol = False ) : app = qapplication ( ) editor = CodeEditor ( parent = None ) editor . setup_editor ( language = 'Python' , indent_chars = indent_chars , tab_stop_width_spaces = tab_stop_width_spaces ) editor . set_text ( text ) cursor = editor . textCursor ( ) cursor . movePosition ( QTextCursor . End ) if sol : lines = text . splitlines ( True ) repeat = len ( lines [ ( - 1 ) ] . lstrip ( ) ) cursor . movePosition ( QTextCursor . Left , n = repeat ) editor . setTextCursor ( cursor ) editor . fix_indent ( ) return to_text_string ( editor . toPlainText ( ) )
return text with last lines indentation fixed .