Muscat.Helpers.TextFormatHelper module

CheckIntegrity(GUI: bool = False)[source]
class TFormat[source]

Bases: object

Format Helper class (indentation, color and justification)

static Center(text: str, fill: str = '*', width: int = 60)[source]

Return a text (text) centered with width (width) and filling the empty spaces with the fill char.

Parameters:
  • text (str) – the test to justified

  • fill (str, optional) – the filling char, by default “*”

  • width (int, optional) – the width of the justification, by default 60

Returns:

the input string centered

Return type:

str

static CleanFormat() str[source]

Return the ANSI string for clean forma. Return an empty string if the current console does not support ANSI codes

Returns:

Clean format string

Return type:

str

static DI() None[source]

Decrease indentation level by

static GetIndent()[source]

Generate a string with the correct number on spaces

static GoodBad(text: Any, test: bool) str[source]

Return a string in color depending on the test variable

Parameters:
  • text (Any) – text to add color

  • test (bool) – test value

Returns:

a ANSI green string if test is True a ANSI red string if test is False

Return type:

str

static II() None[source]

Increase indentation level by one level

static InBlue(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InBlueBackGround(text='')[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static InGreen(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InGreenBackGround(text: str = '') str[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static InGrey(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InGreyBackGround(text='')[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static InIPython() bool[source]

Function to try to detect if console is a IPython console

Returns:

true if variable __IPYTHON__ is defined (in locals())

Return type:

bool

static InPurple(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InPurpleBackGround(text='')[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static InRed(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InRedBackGround(text: str = '') str[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static InYellow(text: str = '') str[source]

Return the string in color

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text in color

Return type:

str

static InYellowBackGround(text: str = '') str[source]

Return the string with a color background

Parameters:

text (str, optional) – the string to add color, by default ‘’

Returns:

the text with colored background

Return type:

str

static Left(text: str, fill: str = '*', width: int = 60) str[source]

Return a text (text) left justified with width (width) and filling the empty spaces with the fill char.

Parameters:
  • text (str) – the test to justified

  • fill (str, optional) – the filling char, by default “*”

  • width (int, optional) – the width of the justification, by default 60

Returns:

the input string left justified

Return type:

str

static Reset() None[source]

Reset the indentation state

static SupportsColor() bool[source]

Try to detect the color support of the current console

Returns:

Returns True if the running system’s terminal supports color, and False otherwise.

Return type:

bool

static WithColor(text: str, color: str) str[source]

Add color to a string usings ANSI code

Parameters:
  • text (str) – the text to add color

  • color (str) – ANSI color in str

Returns:

the text in color

Return type:

str

static WithItalic(text: str = '') str[source]

Return the text in italic font (ANSI code)

Parameters:

text (str, optional) – the test to treat, by default ‘’

Returns:

the text in italic

Return type:

str

static WithUnderline(text: str = '') str[source]

return the text with ANSI underline

Parameters:

text (str;) – the text to add underline

Returns:

underlined text

Return type:

str

strip_ANSI_escape_sequences_sub(repl, string, count=0)

Return the string obtained by replacing the leftmost non-overlapping occurrences of pattern in string by the replacement repl.