Skip to main content

colored

Terminal colored text.

Attributes

AttributeTypeDescription
stuple[object, ...]A collection of objects to be formatted and displayed as colored terminal text.
enabledboolA flag that determines whether ANSI color escape sequences are applied to the output.
opstringThe ANSI escape sequence string used to apply specific text styles or colors.
namesdict[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

NameTypeDescription
*sobjectVariable length argument list of objects to be colored.
**kwargsAnyKeyword arguments including 'enabled' (bool) to toggle coloring and 'op' (str) for the ANSI escape sequence.

Signature

def colored(
*s: object,
**kwargs: Any
)

Parameters

NameTypeDescription
*sobjectThe content to be wrapped or colored.
**kwargsAnyConfiguration 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

TypeDescription
strThe 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

TypeDescription
strThe 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

NameTypeDescription
stuple[object, ...]The content to be contained within the new node.
opstrThe ANSI escape sequence to apply to the content.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored black.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored red.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored green.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored yellow.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored blue.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored magenta.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored cyan.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored white.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be made bold.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be underlined.

Returns

TypeDescription
[colored](colored.md?sid=celery_utils_term_colored)A colored instance configured with the underline ANSI code.

@classmethod
def blink(
*s: object
) - > [colored](colored.md?sid=celery_utils_term_colored)

Applies a blinking text style to the provided content.

Parameters

NameTypeDescription
*sobjectThe text or objects to be made blinking.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to have colors reversed.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be made bright.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense red.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense green.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense yellow.

Returns

TypeDescription
[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

NameTypeDescription
*s[colored](colored.md?sid=celery_utils_term_colored)The text or objects to be colored intense blue.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense magenta.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense cyan.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to be colored intense white.

Returns

TypeDescription
[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

NameTypeDescription
*sobjectThe text or objects to follow the reset sequence.

Returns

TypeDescription
[colored](colored.md?sid=celery_utils_term_colored)A colored instance that explicitly resets terminal styles.