Terminal colored text.
Attributes
| Attribute | Type | Description |
|---|
| s | tuple[object, ...] | A collection of objects to be formatted and displayed as colored terminal text. |
| enabled | bool | A flag that determines whether ANSI color escape sequences are applied to the output. |
| op | string | The ANSI escape sequence string used to apply specific text styles or colors. |
| names | dict[str, Any] | A mapping of color names to their corresponding formatting methods for dynamic attribute access. |
Constructor
Signature
def colored(
*s: object,
**kwargs: Any
) - > None
Parameters
| Name | Type | Description |
|---|
| *s | object | Variable length argument list of objects to be colored. |
| **kwargs | Any | Keyword arguments including 'enabled' (bool) to toggle coloring and 'op' (str) for the ANSI escape sequence. |
Signature
def colored(
*s: object,
**kwargs: Any
)
Parameters
| Name | Type | Description |
|---|
| *s | object | The content to be wrapped or colored. |
| **kwargs | Any | Configuration options including 'enabled' to toggle coloring and 'op' for the ANSI escape sequence. |
Methods
no_color()
@classmethod
def no_color() - > str
Recursively removes all ANSI color sequences from the stored content.
Returns
| Type | Description |
|---|
str | The raw text content without any terminal formatting. |
embed()
@classmethod
def embed() - > str
Wraps the content with the current ANSI operation sequence if coloring is enabled.
Returns
| Type | Description |
|---|
str | The content prefixed with an ANSI escape code, or raw content if disabled. |
node()
@classmethod
def node(
s: tuple[object, ...],
op: str
) - > [colored](colored.md?sid=celery_utils_term_colored)
Creates a new colored instance inheriting the current enabled state but applying a new ANSI operation.
Parameters
| Name | Type | Description |
|---|
| s | tuple[object, ...] | The content to be contained within the new node. |
| op | str | The ANSI escape sequence to apply to the content. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A new instance of the colored class with the specified operation applied. |
black()
@classmethod
def black(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a black foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored black. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the black foreground ANSI code. |
red()
@classmethod
def red(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a red foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored red. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the red foreground ANSI code. |
green()
@classmethod
def green(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a green foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored green. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the green foreground ANSI code. |
yellow()
@classmethod
def yellow(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a yellow foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored yellow. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the yellow foreground ANSI code. |
blue()
@classmethod
def blue(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a blue foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored blue. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the blue foreground ANSI code. |
magenta()
@classmethod
def magenta(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a magenta foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored magenta. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the magenta foreground ANSI code. |
cyan()
@classmethod
def cyan(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a cyan foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored cyan. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the cyan foreground ANSI code. |
white()
@classmethod
def white(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a white foreground color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored white. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the white foreground ANSI code. |
bold()
@classmethod
def bold(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a bold text style to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be made bold. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the bold ANSI code. |
underline()
@classmethod
def underline(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an underline text style to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be underlined. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the underline ANSI code. |
blink()
@classmethod
def blink(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a blinking text style to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be made blinking. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the blink ANSI code. |
reverse()
@classmethod
def reverse(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a reverse video (swap foreground/background) style to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to have colors reversed. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the reverse ANSI code. |
bright()
@classmethod
def bright(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies a bright or high-intensity style to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be made bright. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the bright ANSI code. |
ired()
@classmethod
def ired(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background red color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense red. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense red ANSI code. |
igreen()
@classmethod
def igreen(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background green color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense green. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense green ANSI code. |
iyellow()
@classmethod
def iyellow(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background yellow color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense yellow. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense yellow ANSI code. |
iblue()
@classmethod
def iblue(
*s: [colored](colored.md?sid=celery_utils_term_colored)
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background blue color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | [colored](colored.md?sid=celery_utils_term_colored) | The text or objects to be colored intense blue. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense blue ANSI code. |
imagenta()
@classmethod
def imagenta(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background magenta color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense magenta. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense magenta ANSI code. |
icyan()
@classmethod
def icyan(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background cyan color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense cyan. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense cyan ANSI code. |
iwhite()
@classmethod
def iwhite(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Applies an intense or background white color to the provided content.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to be colored intense white. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance configured with the intense white ANSI code. |
reset()
@classmethod
def reset(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)
Wraps the content with a reset sequence to clear all previous terminal formatting.
Parameters
| Name | Type | Description |
|---|
| *s | object | The text or objects to follow the reset sequence. |
Returns
| Type | Description |
|---|
[colored](colored.md?sid=celery_utils_term_colored) | A colored instance that explicitly resets terminal styles. |