Skip to content

Formatting

Jordan Welsman edited this page Feb 17, 2023 · 2 revisions

This sub-module contains classes and functionality which enables users to enrich their terminal output with text color, background color and formatting.

Table of Contents

Background()

This data class enables the user to decorate terminal output with background color. It is simply a class which holds the formatting codes for background color and a test method for testing the terminal color output.

Usage

from jutl.formatting import Background

print(Background.colors["BLUE"] + "Hello, there!" + Background.colors["DEFAULT"]) # prints "Hello, there!" with a blue           
                                                                                    background and then resets it.

Note Using apply() to apply formatting instead of directly using the data classes is highly recommended for a better experience.

Methods

Background.test()

This method lets users test the

Reset()

This data class lets the user reset individual types of formatting or all types simultaneously. It is simply a class which holds the formatting codes for resetting formatting.

Usage

from jutl.formatting import Reset

Note Using apply() to apply formatting instead of directly using the data classes is highly recommended for a better experience.

Methods

Text()

This data class enables the user to decorate terminal output with text color. It is simply a class which holds the formatting codes for text color and a test method for testing the terminal color output.

Usage

from jutl.formatting import Text

Note Using apply() to apply formatting instead of directly using the data classes is highly recommended for a better experience.

Methods

Text.test()

Typography()

This data class enables the user to decorate terminal output with background color. It is simply a class which holds the formatting codes for typography formatting and a test method for testing the terminal formatting output.

Usage

from jutl.formatting import Typography

Note Using apply() to apply formatting instead of directly using the data classes is highly recommended for a better experience.

Methods

Typography.test()

apply()

This function lets the user easily format their terminal output with optional formatting types.

Usage

from jutl.formatting import apply

print(apply(text="Hello, World!",
            text_color="red",
            background_color="white",
            typography="bold"
     )
) # prints "Hello, World!" in bold, red text with
    a white background and resets the styling.

Arguments

Argument Data type Default Description
text string The text to be formatted
text_color string None The desired color of the text
background_color string None The desired color of the background
typography string None The desired typography formatting

Argument details

Accepted arguments

Argument Required Accepted values
``

Returns

This class/function/method returns/does not return

Side-effects

This class/object/method does/does not have

test()

This class lets the user test how their chosen terminal handles formatting.

Usage

from jutl.formatting import test

test()

Arguments

Note This function does not take any arguments.

Accepted arguments

Note This function does not take any arguments.

Returns

This function does not return anything.

Side-effects

This function calls the test methods in , , and ``, so the side-effects of this function are the side-effects of those methods collectively.