'Set a text with </> markers for selected text and | as cursor.'

def set_aug_text(self, text):

    real_text = re.sub('[<>|]', '', text)
    self.setText(real_text)
    cursor_pos = self._get_index(text, '|')
    sel_start_pos = self._get_index(text, '<')
    sel_end_pos = self._get_index(text, '>')
    if ((sel_start_pos is not None) and (sel_end_pos is None)):
        raise ValueError('<    given    without    >!')
    if ((sel_start_pos is None) and (sel_end_pos is not None)):
        raise ValueError('>    given    without    <!')
    if (cursor_pos is not None):
        if ((sel_start_pos is not None) or (sel_end_pos is not None)):
            raise ValueError("Can't    mix    |    and    </>!")
        self.setCursorPosition(cursor_pos)
    elif (sel_start_pos is not None):
        if (sel_start_pos > sel_end_pos):
            raise ValueError('<    given    after    >!')
        sel_len = ((sel_end_pos - sel_start_pos) - 1)
        self.setSelection(sel_start_pos, sel_len)
