def flush_stdout(self): """ Empties """ try: contents = self.stdout_interceptor.flush_all() except Exception: return if len(contents) > 0: self.body.append(render_texts.preformatted_text(contents)) self._last_update_time = time.time() return contents
def flush_stdout(self): """ Empties the standard out redirect buffer and renders the contents to the body as a preformatted text box. """ try: contents = self.stdout_interceptor.flush_all() except Exception: return if len(contents) > 0: self.body.append(render_texts.preformatted_text(contents)) self._last_update_time = time.time() return contents
def read_stdout(self): """ Reads the current state of the print buffer (if it exists) and returns a body-ready dom object of those contents without adding them to the actual report body. This is useful for creating intermediate body values for display while the method is still executing. :return: A dom string for the current state of the print buffer contents """ try: contents = self.stdout_interceptor.read_all() except Exception as err: contents = '' return render_texts.preformatted_text(contents)
def text(value: str, preformatted: bool = False): """ Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: Whether or not to preserve the whitespace display of the text. """ if preformatted: result = render_texts.preformatted_text(value) else: result = render_texts.text(value) r = _get_report() r.append_body(result) r.stdout_interceptor.write_source('{}\n'.format(textwrap.dedent(value)))
def text(value: str, preformatted: bool = False): """ Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display :param preformatted: Whether or not to preserve the whitespace display the text """ if preformatted: result = render_texts.preformatted_text(value) else: result = render_texts.text(value) r = _get_report() r.append_body(result)
def text(value: str, preformatted: bool = False): """ Adds text to the display. If the text is not preformatted, it will be displayed in paragraph format. Preformatted text will be displayed inside a pre tag with a monospace font. :param value: The text to display. :param preformatted: Whether or not to preserve the whitespace display of the text. """ if preformatted: result = render_texts.preformatted_text(value) else: result = render_texts.text(value) r = _get_report() r.append_body(result) r.stdout_interceptor.write_source( '{}\n'.format(textwrap.dedent(value)) )