# TODO: make it so this function returns text so one statment is on one
    # line that means no splitting up things like function definitions into
    # multiple lines

def split_python_text_into_lines(text):
    """
    # TODO: make it so this function returns text so one statment is on one
    # line that means no splitting up things like function definitions into
    # multiple lines
    """
    #import jedi
    #script = jedi.Script(text, line=1, column=None, path='')
    def parentesis_are_balanced(line):
        """
        helper

        References:
            http://stackoverflow.com/questions/18007995/recursive-paren-balance
        """
        def balanced(str_, i=0, cnt=0, left='(', right=')'):
            if i == len(str_):
                return cnt == 0
            if cnt < 0:
                return False
            if str_[i] == left:
                return  balanced(str_, i + 1, cnt + 1)
            elif str_[i] == right:
                return  balanced(str_, i + 1, cnt - 1)
            return balanced(str_, i + 1, cnt)
        return balanced(line)

    lines = text.split('\n')
    new_lines = []
    current_line = ''
    for line in lines:
        current_line += line
        if parentesis_are_balanced(current_line):
            new_lines.append(current_line)
            current_line = ''
    return lines