Beispiel #1
0
    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
Beispiel #2
0
    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
Beispiel #3
0
    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
Beispiel #4
0
    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)
Beispiel #5
0
    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)
Beispiel #6
0
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)))
Beispiel #7
0
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)
Beispiel #8
0
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))
    )