def _(item, target): cursor = target.end_cursor target.clear_cursor = None cursor.insertText('\n') target.text_register.append(cursor.position(), item.username, style='in-prompt') if item.code and is_comment(item.code): in_prompt = _make_in_prompt(target.chat_prompt, item.execution_count) target.insert_html(in_prompt, cursor) if len(item.code.split('\n')) != 1: cursor.insertText('\n') target.insert_ansi_text(de_comment(item.code), item.ansi_codes and target.use_ansi, cursor) target.ansi_processor.reset_sgr() else: before_prompt = cursor.position() in_prompt = _make_in_prompt(target.in_prompt, item.execution_count) target.insert_html(in_prompt, cursor) after_prompt = cursor.position() target.highlighter.enable(after_prompt-before_prompt) if item.code: target.insert_ansi_text(item.code, item.ansi_codes and target.use_ansi, cursor) target.ansi_processor.reset_sgr() target.highlighter.disable() if item.code and item.code[-1] != '\n': cursor.insertText('\n')
def test_is2(self): res = is_comment(self.u) self.assertEqual(res, False)
def test_is1(self): res = is_comment(self.t) self.assertEqual(res, True)