pycolorecho


Namepycolorecho JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/coldsofttech/pycolorecho
SummarySimple Python package for colorized terminal output
upload_time2024-05-05 06:12:33
maintainerNone
docs_urlNone
authorcoldsofttech
requires_pythonNone
licenseMIT
keywords color text-color text-background-color text-effect text-case terminal colorization style text
VCS
bugtrack_url
requirements pytest setuptools
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # `pycolorecho`

Welcome to **pycolorecho** - your go-to Python package for effortlessly colorizing text within terminals, enhancing the
visual appeal and readability of your console applications.

## Features

The **pycolorecho** package offers a plethora of features to style your text:

- **Text Colorization**: Easily change the foreground color of your text to catch attention or categorize information.
- **Background Colorization**: Make your text pop by adding vibrant background colors, ensuring it stands out against
  the terminal background.
- **Text Styles**: From bold to underline, add emphasis and structure to your text with various styling options.
- **Text Cases**: Optimize readability by converting text to different cases like sentence case, title case, or all
  caps.

## Standard and True Color ANSI Formats

With **pycolorecho**, you have the flexibility to choose between standard and true color ANSI formats:

### Standard Colors

Enjoy a classic color palette including black, green, red, yellow, blue, magenta, cyan, and white. These colors are
universally supported across terminals, ensuring consistency across different operating systems.

### True Colors (24-bit)

Step into the vibrant world of true colors, boasting millions of distinct shades for unparalleled visual richness. True
colors, also known as 24-bit color, offer a more accurate representation of images and graphics. However, please note
that support for true colors may vary depending on your terminal and operating system capabilities.

## Getting Started

- Install **pycolorecho** via pip:

```bash
pip install pycolorecho
```

- Import the package in your Python script:

```python
import pycolorecho
```

## Usage

```python
from pycolorecho import echo, TextColor, TextBackgroundColor, TextEffect, ColorMapper

# Colorizing entire message
echo('This is a test message', text_color=TextColor.RED)  # Standard color
echo('This is a test message', text_color=TextColor.ACID_GREEN)  # True color

# Colorizing by regex pattern
echo('This is a test message', regex_pattern=r'test', text_color=TextColor.RED,
     text_background_color=TextBackgroundColor.ACID_GREEN)

# Colorizing by mappings
color_mappings = ColorMapper()
color_mappings.add_mapping('error', [r'error'], text_color=TextColor.RED, text_effect=TextEffect.UNDERLINE)
echo('This is a test error message', mappings=color_mappings)
```

# Documentation

## pycolorecho

#### Constants

- `RESET`: This is a constant ANSI code variable to reset the text styles.

#### Methods

- `echo(message: str, regex_pattern: Optional[str] = None, mappings: Optional[ColorMapper] = None, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False)` -
  Printstext colorized within the terminal based on the provided inputs. Supports the following scenarios:
    1) Colorizing a message by specifying text foreground color, text background color, text effect, and text case.
    2) Colorizing a message by matching it with a regex pattern and specifying text foreground color, text background
       color, text effect, text case, ignore case, and color match.
    3) Colorizing a message by matching it with mappings (utilizing a ColorMapper) and specifying text foreground.
- `get_colorized_message(message: str, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE) -> str` -
  Generates a colorized message based on the provided inputs.
- `get_colorized_message_by_regex_pattern(message: str, regex_pattern: str, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False) -> str` -
  Generates a colorized message based on the provided regex pattern and inputs.
- `get_colorized_message_by_mappings(message: str, mappings: Optional[ColorMapper] = None) -> str` - Generates a
  colorized message based on the provided mappings.
- `is_colorization_supported() -> bool` - Checks if the current operating system supports colorization. Returns True if
  colorization is supported, False otherwise.
- `is_true_color_supported() -> bool` - Verifies whether the true color format is supported by the current operating
  system and terminal. Returns True if true color format is supported, False otherwise.

#### Usage

```python
from pycolorecho import is_colorization_supported, is_true_color_supported, get_colorized_message, get_colorized_message_by_regex_pattern, get_colorized_message_by_mappings, TextColor, TextBackgroundColor, TextEffect, ColorMapper

print(is_colorization_supported())  # Prints True if colorization is supported, False otherwise
print(is_true_color_supported())  # Prints True if true color format is supported, False otherwise

# Retrieving colorized message
print(get_colorized_message('This is a test message', text_color=TextColor.RED))

# Retrieving colorized message by regex pattern
print(get_colorized_message_by_regex_pattern('This is a test message', regex_pattern=r'test', text_color=TextColor.RED,
                                             text_background_color=TextBackgroundColor.ACID_GREEN))

# Retrieving colorized message by mappings
color_mappings = ColorMapper()
color_mappings.add_mapping('error', [r'error'], text_color=TextColor.RED, text_effect=TextEffect.UNDERLINE)
print(get_colorized_message_by_mappings('This is a test error message', mappings=color_mappings))
```

### Layer

Supplies enum-based options for different color layers within a terminal, such as Foreground and Background.

#### Options

- `Foreground` - To colorize the text foreground color.
- `Background` - To colorize the text background color.

### TextBackgroundColor

Enhance your text styling further with the TextBackgroundColor class, which offers a wide range of background color
options for console text within the terminal. This class encompasses both standard and true colors, providing
versatility and customization options to suit your preferences.

#### Constants

Maintained within this class are constants representing both standard and true color codes.

#### Methods

Explore the functionality provided by the TextBackgroundColor class:

- `add_color(name: str, ansi_code: str, true_color: Optional[bool] = True)`: Add a custom background color, supporting
  both standard and true color formats. Note that true colors can only be added if the terminal supports them.
- `get_colors(true_color: Optional[bool] = True) -> dict`: Generate a dictionary containing a list of all colors based
  on the provided input.
- `get_color(name: str, true_color: Optional[bool] = True) -> str`: Obtain the color code corresponding to the provided
  input.
- `is_standard_color(name: str) -> bool`: Check whether the provided color name corresponds to a standard color.
- `is_true_color(name: str) -> bool`: Check whether the provided color name corresponds to a true color.
- `is_valid_color(name: str, true_color: Optional[bool] = True) -> bool`: Check whether the provided color name
  corresponds to either a standard or true color.
- `remove_color(name: str, true_color: Optional[bool] = True)`: Delete the custom background color specified by name
  from the dictionary.

#### Usage

Here's how you can utilize the TextBackgroundColor class:

```python
from pycolorecho import TextBackgroundColor

# Accessing standard color
print(TextBackgroundColor.RED)

# Accessing true color
print(TextBackgroundColor.ACID_GREEN)

# Adding new custom true color
TextBackgroundColor.add_color(name='CUSTOM_1', ansi_code='\033[48;2;255;255;255m', true_color=True)

# Adding new custom standard color
TextBackgroundColor.add_color(name='CUSTOM_2', ansi_code='\033[107m', true_color=False)

# Printing all true colors
print(TextBackgroundColor.get_colors(true_color=True))

# Printing all standard colors
print(TextBackgroundColor.get_colors(true_color=False))

# Retrieving true color code
print(TextBackgroundColor.get_color(name='CUSTOM_1', true_color=True))

# Retrieving standard color code
print(TextBackgroundColor.get_color(name='CUSTOM_2', true_color=False))

# Checking standard color
print(TextBackgroundColor.is_standard_color('CUSTOM_2'))

# Checking true color
print(TextBackgroundColor.is_true_color('CUSTOM_1'))

# Checking color
print(TextBackgroundColor.is_valid_color(name='CUSTOM_1', true_color=True))

# Removing custom true color
print(TextBackgroundColor.remove_color(name='CUSTOM_1', true_color=True))

# Removing custom standard color
print(TextBackgroundColor.remove_color(name='CUSTOM_2', true_color=False))
```

### TextColor

Elevate your text styling with the TextColor class, providing an extensive range of foreground color options for console
text within the terminal. This class encompasses both standard and true colors, offering flexibility and customization
to suit your visual preferences.

#### Constants

Within this class, constants representing both standard and true color codes are maintained.

#### Methods

Explore the capabilities of the TextColor class:

- `add_color(name: str, ansi_code: str, true_color: Optional[bool] = True)`: Add a custom foreground color, supporting
  both standard and true color formats. Please note that true colors can only be added if the terminal supports them.
- `get_colors(true_color: Optional[bool] = True) -> dict`: Generate a dictionary containing a list of all colors based
  on the provided input.
- `get_color(name: str, true_color: Optional[bool] = True) -> str`: Obtain the color code corresponding to the provided
  input.
- `is_standard_color(name: str) -> bool`: Check whether the provided color name corresponds to a standard color.
- `is_true_color(name: str) -> bool`: Check whether the provided color name corresponds to a true color.
- `is_valid_color(name: str, true_color: Optional[bool] = True) -> bool`: Check whether the provided color name
  corresponds to either a standard or true color.
- `remove_color(name: str, true_color: Optional[bool] = True)`: Delete the custom foreground color specified by name
  from the dictionary.

#### Usage

Here's how you can utilize the TextColor class:

```python
from pycolorecho import TextColor

# Accessing standard color
print(TextColor.RED)

# Accessing true color
print(TextColor.ACID_GREEN)

# Adding new custom true color
TextColor.add_color(name='CUSTOM_1', ansi_code='\033[38;2;255;255;255m', true_color=True)

# Adding new custom standard color
TextColor.add_color(name='CUSTOM_2', ansi_code='\033[97m', true_color=False)

# Printing all true colors
print(TextColor.get_colors(true_color=True))

# Printing all standard colors
print(TextColor.get_colors(true_color=False))

# Retrieving true color code
print(TextColor.get_color(name='CUSTOM_1', true_color=True))

# Retrieving standard color code
print(TextColor.get_color(name='CUSTOM_2', true_color=False))

# Checking standard color
print(TextColor.is_standard_color('CUSTOM_2'))

# Checking true color
print(TextColor.is_true_color('CUSTOM_1'))

# Checking color
print(TextColor.is_valid_color(name='CUSTOM_1', true_color=True))

# Removing custom true color
print(TextColor.remove_color(name='CUSTOM_1', true_color=True))

# Removing custom standard color
print(TextColor.remove_color(name='CUSTOM_2', true_color=False))
```

### TextEffect

Enhance your text styling with the TextEffect class, providing a variety of effects for console text within the
terminal. This class allows you to add custom effects, offering further versatility in text presentation.

#### Constants

Supported effects are maintained as constants within this class.

#### Methods

Discover the functionality offered by the TextEffect class:

- `add_effect(name: str, ansi_code: str)`: Add a custom effect to the dictionary.
- `get_effects() -> dict`: Generate a dictionary containing a list of all effects.
- `get_effect(name: str) -> str`: Obtain the effect code corresponding to the provided input.
- `is_valid_effect(name: str) -> bool`: Check whether the provided effect name exists within the dictionary.
- `remove_effect(name: str)`: Delete the custom effect specified by name from the dictionary.

#### Usage

Here's how you can utilize the TextEffect class:

```python
from pycolorecho import TextEffect

# Accessing effect
print(TextEffect.BOLD)

# Adding new custom effect
TextEffect.add_effect(name='CUSTOM_1', ansi_code='\033[5m')

# Printing all effects
print(TextEffect.get_effects())

# Retrieving effect code
print(TextEffect.get_effect('CUSTOM_1'))

# Checking effect
print(TextEffect.is_valid_effect('CUSTOM_1'))

# Removing custom effect
print(TextEffect.remove_effect('CUSTOM_1'))
```

### TextCase

Refine your text styling with the TextCase class, offering options for transforming text cases within the terminal.

#### Constants

Supported text cases are maintained as constants within this class.

#### Methods

Explore the functionalities provided by the TextCase class:

- `convert_text(message: str, text_case: int) -> str`: Convert the provided message to the specified text case.
- `get_cases() -> dict`: Generate a dictionary containing a list of all supported text cases.

#### Usage

Here's how you can utilize the TextCase class:

```python
from pycolorecho import TextCase

# Accessing case
print(TextCase.ALL_CAPS)

# Printing all cases
print(TextCase.get_cases())

# Converts the message
print(TextCase.convert_text(message='This is a test message', text_case=TextCase.ALL_CAPS))
```

### ColorMapper

Empower your text styling with the ColorMapper class, offering functionality to create and manage mappings for text
styles within the terminal. These mappings enable dynamic styling based on keywords, including text color, background
color, effects, and case transformations.

#### Methods

Discover the capabilities provided by the ColorMapper class:

- `add_mapping(name: str, keywords: str | list[str], text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False)`:
  Add a mapping to the dictionary for styling text based on specified keywords.
- `get_mapping(name: str) -> dict`: Retrieve the mapping associated with the provided input name.
- `get_mappings() -> dict`: Generate a dictionary containing a list of all mappings.
- `is_valid_mapping(name: str) -> bool`: Check whether the provided mapping name exists within the dictionary.
- `remove_mapping(name: str)`: Delete the mapping specified by name from the dictionary.

#### Usage

Here's how you can utilize the ColorMapper class:

```python
from pycolorecho import ColorMapper, TextColor

# Initialize ColorMapper
color_mappings = ColorMapper()

# Adding new custom mapping
color_mappings.add_mapping(name='error', keywords=[r'error'], text_color=TextColor.RED)

# Retrieving custom mapping
print(color_mappings.get_mapping('error'))

# Retrieving all mappings
print(color_mappings.get_mappings())

# Checking mapping
print(color_mappings.is_valid_mapping('error'))

# Removing custom mapping
color_mappings.remove_mapping('error')
```

### Color

The Color class provides versatile methods for handling various color format conversions, empowering you to seamlessly
manage color representations within terminal applications.

#### Methods

Explore the functionalities offered by the Color class:

- `hex_to_rgb(hex_code: str) -> tuple[int, int, int]`: Convert the given color HEX code to RGB format.
- `rgb_to_hex(r: int, g: int, b: int) -> str`: Convert the provided RGB (red, green, blue) color values to HEX code
  format.
- `cmyk_to_rgb(c: float, m: float, y: float, k: float) -> tuple[int, int, int]`: Convert the given CMYK (cyan, magenta,
  yellow, key) color values to RGB (red, green, blue) format.
- `rgb_to_cmyk(r: int, g: int, b: int) -> tuple[float, float, float, float]`: Convert the given RGB (red, green, blue)
  color values to CMYK (cyan, magenta, yellow, key) format.
- `hex_to_ansi(hex_code: str, layer: Layer, true_color: Optional[bool] = True) -> str`: Convert a given HEX code color
  value to ANSI code format.
- `ansi_to_hex(ansi: str) -> str`: Convert the provided ANSI code color value to the HEX code color format.
- `rgb_to_ansi(r: int, g: int, b: int, layer: Layer, true_color: Optional[bool] = True) -> str`: Convert the given RGB (
  red, green, blue) color values to the corresponding ANSI code color format.
- `ansi_to_rgb(ansi: str) -> tuple[int, int, int]`: Convert the provided ANSI code color value to the RGB (red, green,
  blue) color format.
- `cmyk_to_ansi(c: float, m: float, y: float, k: float, layer: Layer, true_color: Optional[bool] = True) -> str`:
  Convert the given CMYK (cyan, magenta, yellow, key) color values to the corresponding ANSI code color format.
- `ansi_to_cmyk(ansi: str) -> tuple[float, float, float, float]`: Convert the provided ANSI code color value to the
  CMYK (cyan, magenta, yellow, key) color format.

#### Usage

Here's how you can utilize the methods provided by the Color class:

```python
from pycolorecho import Color, Layer

# Convert HEX code to RGB format
print(Color.hex_to_rgb('#FFFFFF'))

# Convert RGB color values to HEX code format
print(Color.rgb_to_hex(255, 255, 255))

# Convert CMYK color values to RGB format
print(Color.cmyk_to_rgb(0.0, 0.0, 0.0, 0.0))

# Convert RGB color values to CMYK format
print(Color.rgb_to_cmyk(255, 255, 255))

# Convert HEX code color value to ANSI code format
print(Color.hex_to_ansi('#FFFFFF', Layer.Foreground, true_color=True))

# Convert ANSI code color value to HEX code color format
print(Color.ansi_to_hex('\033[48;2;255;255;255m'))

# Convert RGB color values to corresponding ANSI code color format
print(Color.rgb_to_ansi(255, 255, 255, Layer.Background, true_color=True))

# Convert ANSI code color value to RGB color format
print(Color.ansi_to_rgb('\033[38;2;255;255;255m'))

# Convert CMYK color values to corresponding ANSI code color format
print(Color.cmyk_to_ansi(0.0, 0.0, 0.0, 0.0, Layer.Background, true_color=True))

# Convert ANSI code color value to CMYK color format
print(Color.ansi_to_cmyk('\033[107m'))
```

### HEXCodes

The HEXCodes class serves as a supporting class encapsulating constants representing HEX code formats for various
colors, sourced from Wikipedia. For licensing information regarding the colors, please refer to the appropriate sources.

# License

Please refer to the [MIT license](LICENSE) within the project for more information. Additionally, refer to
the [ADDITIONAL LICENSES](ADDITIONAL%20LICENSES.md) file for licensing information related to components used within
this package.

# Contributing

We welcome contributions from the community! Whether you have ideas for new features, bug fixes, or enhancements, feel
free to open an issue or submit a pull request on [GitHub](https://github.com/coldsofttech/pycolorecho).

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/coldsofttech/pycolorecho",
    "name": "pycolorecho",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "color, text-color, text-background-color, text-effect, text-case, terminal, colorization, style, text",
    "author": "coldsofttech",
    "author_email": null,
    "download_url": null,
    "platform": null,
    "description": "# `pycolorecho`\n\nWelcome to **pycolorecho** - your go-to Python package for effortlessly colorizing text within terminals, enhancing the\nvisual appeal and readability of your console applications.\n\n## Features\n\nThe **pycolorecho** package offers a plethora of features to style your text:\n\n- **Text Colorization**: Easily change the foreground color of your text to catch attention or categorize information.\n- **Background Colorization**: Make your text pop by adding vibrant background colors, ensuring it stands out against\n  the terminal background.\n- **Text Styles**: From bold to underline, add emphasis and structure to your text with various styling options.\n- **Text Cases**: Optimize readability by converting text to different cases like sentence case, title case, or all\n  caps.\n\n## Standard and True Color ANSI Formats\n\nWith **pycolorecho**, you have the flexibility to choose between standard and true color ANSI formats:\n\n### Standard Colors\n\nEnjoy a classic color palette including black, green, red, yellow, blue, magenta, cyan, and white. These colors are\nuniversally supported across terminals, ensuring consistency across different operating systems.\n\n### True Colors (24-bit)\n\nStep into the vibrant world of true colors, boasting millions of distinct shades for unparalleled visual richness. True\ncolors, also known as 24-bit color, offer a more accurate representation of images and graphics. However, please note\nthat support for true colors may vary depending on your terminal and operating system capabilities.\n\n## Getting Started\n\n- Install **pycolorecho** via pip:\n\n```bash\npip install pycolorecho\n```\n\n- Import the package in your Python script:\n\n```python\nimport pycolorecho\n```\n\n## Usage\n\n```python\nfrom pycolorecho import echo, TextColor, TextBackgroundColor, TextEffect, ColorMapper\n\n# Colorizing entire message\necho('This is a test message', text_color=TextColor.RED)  # Standard color\necho('This is a test message', text_color=TextColor.ACID_GREEN)  # True color\n\n# Colorizing by regex pattern\necho('This is a test message', regex_pattern=r'test', text_color=TextColor.RED,\n     text_background_color=TextBackgroundColor.ACID_GREEN)\n\n# Colorizing by mappings\ncolor_mappings = ColorMapper()\ncolor_mappings.add_mapping('error', [r'error'], text_color=TextColor.RED, text_effect=TextEffect.UNDERLINE)\necho('This is a test error message', mappings=color_mappings)\n```\n\n# Documentation\n\n## pycolorecho\n\n#### Constants\n\n- `RESET`: This is a constant ANSI code variable to reset the text styles.\n\n#### Methods\n\n- `echo(message: str, regex_pattern: Optional[str] = None, mappings: Optional[ColorMapper] = None, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False)` -\n  Printstext colorized within the terminal based on the provided inputs. Supports the following scenarios:\n    1) Colorizing a message by specifying text foreground color, text background color, text effect, and text case.\n    2) Colorizing a message by matching it with a regex pattern and specifying text foreground color, text background\n       color, text effect, text case, ignore case, and color match.\n    3) Colorizing a message by matching it with mappings (utilizing a ColorMapper) and specifying text foreground.\n- `get_colorized_message(message: str, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE) -> str` -\n  Generates a colorized message based on the provided inputs.\n- `get_colorized_message_by_regex_pattern(message: str, regex_pattern: str, text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False) -> str` -\n  Generates a colorized message based on the provided regex pattern and inputs.\n- `get_colorized_message_by_mappings(message: str, mappings: Optional[ColorMapper] = None) -> str` - Generates a\n  colorized message based on the provided mappings.\n- `is_colorization_supported() -> bool` - Checks if the current operating system supports colorization. Returns True if\n  colorization is supported, False otherwise.\n- `is_true_color_supported() -> bool` - Verifies whether the true color format is supported by the current operating\n  system and terminal. Returns True if true color format is supported, False otherwise.\n\n#### Usage\n\n```python\nfrom pycolorecho import is_colorization_supported, is_true_color_supported, get_colorized_message, get_colorized_message_by_regex_pattern, get_colorized_message_by_mappings, TextColor, TextBackgroundColor, TextEffect, ColorMapper\n\nprint(is_colorization_supported())  # Prints True if colorization is supported, False otherwise\nprint(is_true_color_supported())  # Prints True if true color format is supported, False otherwise\n\n# Retrieving colorized message\nprint(get_colorized_message('This is a test message', text_color=TextColor.RED))\n\n# Retrieving colorized message by regex pattern\nprint(get_colorized_message_by_regex_pattern('This is a test message', regex_pattern=r'test', text_color=TextColor.RED,\n                                             text_background_color=TextBackgroundColor.ACID_GREEN))\n\n# Retrieving colorized message by mappings\ncolor_mappings = ColorMapper()\ncolor_mappings.add_mapping('error', [r'error'], text_color=TextColor.RED, text_effect=TextEffect.UNDERLINE)\nprint(get_colorized_message_by_mappings('This is a test error message', mappings=color_mappings))\n```\n\n### Layer\n\nSupplies enum-based options for different color layers within a terminal, such as Foreground and Background.\n\n#### Options\n\n- `Foreground` - To colorize the text foreground color.\n- `Background` - To colorize the text background color.\n\n### TextBackgroundColor\n\nEnhance your text styling further with the TextBackgroundColor class, which offers a wide range of background color\noptions for console text within the terminal. This class encompasses both standard and true colors, providing\nversatility and customization options to suit your preferences.\n\n#### Constants\n\nMaintained within this class are constants representing both standard and true color codes.\n\n#### Methods\n\nExplore the functionality provided by the TextBackgroundColor class:\n\n- `add_color(name: str, ansi_code: str, true_color: Optional[bool] = True)`: Add a custom background color, supporting\n  both standard and true color formats. Note that true colors can only be added if the terminal supports them.\n- `get_colors(true_color: Optional[bool] = True) -> dict`: Generate a dictionary containing a list of all colors based\n  on the provided input.\n- `get_color(name: str, true_color: Optional[bool] = True) -> str`: Obtain the color code corresponding to the provided\n  input.\n- `is_standard_color(name: str) -> bool`: Check whether the provided color name corresponds to a standard color.\n- `is_true_color(name: str) -> bool`: Check whether the provided color name corresponds to a true color.\n- `is_valid_color(name: str, true_color: Optional[bool] = True) -> bool`: Check whether the provided color name\n  corresponds to either a standard or true color.\n- `remove_color(name: str, true_color: Optional[bool] = True)`: Delete the custom background color specified by name\n  from the dictionary.\n\n#### Usage\n\nHere's how you can utilize the TextBackgroundColor class:\n\n```python\nfrom pycolorecho import TextBackgroundColor\n\n# Accessing standard color\nprint(TextBackgroundColor.RED)\n\n# Accessing true color\nprint(TextBackgroundColor.ACID_GREEN)\n\n# Adding new custom true color\nTextBackgroundColor.add_color(name='CUSTOM_1', ansi_code='\\033[48;2;255;255;255m', true_color=True)\n\n# Adding new custom standard color\nTextBackgroundColor.add_color(name='CUSTOM_2', ansi_code='\\033[107m', true_color=False)\n\n# Printing all true colors\nprint(TextBackgroundColor.get_colors(true_color=True))\n\n# Printing all standard colors\nprint(TextBackgroundColor.get_colors(true_color=False))\n\n# Retrieving true color code\nprint(TextBackgroundColor.get_color(name='CUSTOM_1', true_color=True))\n\n# Retrieving standard color code\nprint(TextBackgroundColor.get_color(name='CUSTOM_2', true_color=False))\n\n# Checking standard color\nprint(TextBackgroundColor.is_standard_color('CUSTOM_2'))\n\n# Checking true color\nprint(TextBackgroundColor.is_true_color('CUSTOM_1'))\n\n# Checking color\nprint(TextBackgroundColor.is_valid_color(name='CUSTOM_1', true_color=True))\n\n# Removing custom true color\nprint(TextBackgroundColor.remove_color(name='CUSTOM_1', true_color=True))\n\n# Removing custom standard color\nprint(TextBackgroundColor.remove_color(name='CUSTOM_2', true_color=False))\n```\n\n### TextColor\n\nElevate your text styling with the TextColor class, providing an extensive range of foreground color options for console\ntext within the terminal. This class encompasses both standard and true colors, offering flexibility and customization\nto suit your visual preferences.\n\n#### Constants\n\nWithin this class, constants representing both standard and true color codes are maintained.\n\n#### Methods\n\nExplore the capabilities of the TextColor class:\n\n- `add_color(name: str, ansi_code: str, true_color: Optional[bool] = True)`: Add a custom foreground color, supporting\n  both standard and true color formats. Please note that true colors can only be added if the terminal supports them.\n- `get_colors(true_color: Optional[bool] = True) -> dict`: Generate a dictionary containing a list of all colors based\n  on the provided input.\n- `get_color(name: str, true_color: Optional[bool] = True) -> str`: Obtain the color code corresponding to the provided\n  input.\n- `is_standard_color(name: str) -> bool`: Check whether the provided color name corresponds to a standard color.\n- `is_true_color(name: str) -> bool`: Check whether the provided color name corresponds to a true color.\n- `is_valid_color(name: str, true_color: Optional[bool] = True) -> bool`: Check whether the provided color name\n  corresponds to either a standard or true color.\n- `remove_color(name: str, true_color: Optional[bool] = True)`: Delete the custom foreground color specified by name\n  from the dictionary.\n\n#### Usage\n\nHere's how you can utilize the TextColor class:\n\n```python\nfrom pycolorecho import TextColor\n\n# Accessing standard color\nprint(TextColor.RED)\n\n# Accessing true color\nprint(TextColor.ACID_GREEN)\n\n# Adding new custom true color\nTextColor.add_color(name='CUSTOM_1', ansi_code='\\033[38;2;255;255;255m', true_color=True)\n\n# Adding new custom standard color\nTextColor.add_color(name='CUSTOM_2', ansi_code='\\033[97m', true_color=False)\n\n# Printing all true colors\nprint(TextColor.get_colors(true_color=True))\n\n# Printing all standard colors\nprint(TextColor.get_colors(true_color=False))\n\n# Retrieving true color code\nprint(TextColor.get_color(name='CUSTOM_1', true_color=True))\n\n# Retrieving standard color code\nprint(TextColor.get_color(name='CUSTOM_2', true_color=False))\n\n# Checking standard color\nprint(TextColor.is_standard_color('CUSTOM_2'))\n\n# Checking true color\nprint(TextColor.is_true_color('CUSTOM_1'))\n\n# Checking color\nprint(TextColor.is_valid_color(name='CUSTOM_1', true_color=True))\n\n# Removing custom true color\nprint(TextColor.remove_color(name='CUSTOM_1', true_color=True))\n\n# Removing custom standard color\nprint(TextColor.remove_color(name='CUSTOM_2', true_color=False))\n```\n\n### TextEffect\n\nEnhance your text styling with the TextEffect class, providing a variety of effects for console text within the\nterminal. This class allows you to add custom effects, offering further versatility in text presentation.\n\n#### Constants\n\nSupported effects are maintained as constants within this class.\n\n#### Methods\n\nDiscover the functionality offered by the TextEffect class:\n\n- `add_effect(name: str, ansi_code: str)`: Add a custom effect to the dictionary.\n- `get_effects() -> dict`: Generate a dictionary containing a list of all effects.\n- `get_effect(name: str) -> str`: Obtain the effect code corresponding to the provided input.\n- `is_valid_effect(name: str) -> bool`: Check whether the provided effect name exists within the dictionary.\n- `remove_effect(name: str)`: Delete the custom effect specified by name from the dictionary.\n\n#### Usage\n\nHere's how you can utilize the TextEffect class:\n\n```python\nfrom pycolorecho import TextEffect\n\n# Accessing effect\nprint(TextEffect.BOLD)\n\n# Adding new custom effect\nTextEffect.add_effect(name='CUSTOM_1', ansi_code='\\033[5m')\n\n# Printing all effects\nprint(TextEffect.get_effects())\n\n# Retrieving effect code\nprint(TextEffect.get_effect('CUSTOM_1'))\n\n# Checking effect\nprint(TextEffect.is_valid_effect('CUSTOM_1'))\n\n# Removing custom effect\nprint(TextEffect.remove_effect('CUSTOM_1'))\n```\n\n### TextCase\n\nRefine your text styling with the TextCase class, offering options for transforming text cases within the terminal.\n\n#### Constants\n\nSupported text cases are maintained as constants within this class.\n\n#### Methods\n\nExplore the functionalities provided by the TextCase class:\n\n- `convert_text(message: str, text_case: int) -> str`: Convert the provided message to the specified text case.\n- `get_cases() -> dict`: Generate a dictionary containing a list of all supported text cases.\n\n#### Usage\n\nHere's how you can utilize the TextCase class:\n\n```python\nfrom pycolorecho import TextCase\n\n# Accessing case\nprint(TextCase.ALL_CAPS)\n\n# Printing all cases\nprint(TextCase.get_cases())\n\n# Converts the message\nprint(TextCase.convert_text(message='This is a test message', text_case=TextCase.ALL_CAPS))\n```\n\n### ColorMapper\n\nEmpower your text styling with the ColorMapper class, offering functionality to create and manage mappings for text\nstyles within the terminal. These mappings enable dynamic styling based on keywords, including text color, background\ncolor, effects, and case transformations.\n\n#### Methods\n\nDiscover the capabilities provided by the ColorMapper class:\n\n- `add_mapping(name: str, keywords: str | list[str], text_color: Optional[str] = None, text_background_color: Optional[str] = None, text_effect: Optional[str] = None, text_case: Optional[int] = TextCase.NONE, color_match: Optional[bool] = False, ignore_case: Optional[bool] = False)`:\n  Add a mapping to the dictionary for styling text based on specified keywords.\n- `get_mapping(name: str) -> dict`: Retrieve the mapping associated with the provided input name.\n- `get_mappings() -> dict`: Generate a dictionary containing a list of all mappings.\n- `is_valid_mapping(name: str) -> bool`: Check whether the provided mapping name exists within the dictionary.\n- `remove_mapping(name: str)`: Delete the mapping specified by name from the dictionary.\n\n#### Usage\n\nHere's how you can utilize the ColorMapper class:\n\n```python\nfrom pycolorecho import ColorMapper, TextColor\n\n# Initialize ColorMapper\ncolor_mappings = ColorMapper()\n\n# Adding new custom mapping\ncolor_mappings.add_mapping(name='error', keywords=[r'error'], text_color=TextColor.RED)\n\n# Retrieving custom mapping\nprint(color_mappings.get_mapping('error'))\n\n# Retrieving all mappings\nprint(color_mappings.get_mappings())\n\n# Checking mapping\nprint(color_mappings.is_valid_mapping('error'))\n\n# Removing custom mapping\ncolor_mappings.remove_mapping('error')\n```\n\n### Color\n\nThe Color class provides versatile methods for handling various color format conversions, empowering you to seamlessly\nmanage color representations within terminal applications.\n\n#### Methods\n\nExplore the functionalities offered by the Color class:\n\n- `hex_to_rgb(hex_code: str) -> tuple[int, int, int]`: Convert the given color HEX code to RGB format.\n- `rgb_to_hex(r: int, g: int, b: int) -> str`: Convert the provided RGB (red, green, blue) color values to HEX code\n  format.\n- `cmyk_to_rgb(c: float, m: float, y: float, k: float) -> tuple[int, int, int]`: Convert the given CMYK (cyan, magenta,\n  yellow, key) color values to RGB (red, green, blue) format.\n- `rgb_to_cmyk(r: int, g: int, b: int) -> tuple[float, float, float, float]`: Convert the given RGB (red, green, blue)\n  color values to CMYK (cyan, magenta, yellow, key) format.\n- `hex_to_ansi(hex_code: str, layer: Layer, true_color: Optional[bool] = True) -> str`: Convert a given HEX code color\n  value to ANSI code format.\n- `ansi_to_hex(ansi: str) -> str`: Convert the provided ANSI code color value to the HEX code color format.\n- `rgb_to_ansi(r: int, g: int, b: int, layer: Layer, true_color: Optional[bool] = True) -> str`: Convert the given RGB (\n  red, green, blue) color values to the corresponding ANSI code color format.\n- `ansi_to_rgb(ansi: str) -> tuple[int, int, int]`: Convert the provided ANSI code color value to the RGB (red, green,\n  blue) color format.\n- `cmyk_to_ansi(c: float, m: float, y: float, k: float, layer: Layer, true_color: Optional[bool] = True) -> str`:\n  Convert the given CMYK (cyan, magenta, yellow, key) color values to the corresponding ANSI code color format.\n- `ansi_to_cmyk(ansi: str) -> tuple[float, float, float, float]`: Convert the provided ANSI code color value to the\n  CMYK (cyan, magenta, yellow, key) color format.\n\n#### Usage\n\nHere's how you can utilize the methods provided by the Color class:\n\n```python\nfrom pycolorecho import Color, Layer\n\n# Convert HEX code to RGB format\nprint(Color.hex_to_rgb('#FFFFFF'))\n\n# Convert RGB color values to HEX code format\nprint(Color.rgb_to_hex(255, 255, 255))\n\n# Convert CMYK color values to RGB format\nprint(Color.cmyk_to_rgb(0.0, 0.0, 0.0, 0.0))\n\n# Convert RGB color values to CMYK format\nprint(Color.rgb_to_cmyk(255, 255, 255))\n\n# Convert HEX code color value to ANSI code format\nprint(Color.hex_to_ansi('#FFFFFF', Layer.Foreground, true_color=True))\n\n# Convert ANSI code color value to HEX code color format\nprint(Color.ansi_to_hex('\\033[48;2;255;255;255m'))\n\n# Convert RGB color values to corresponding ANSI code color format\nprint(Color.rgb_to_ansi(255, 255, 255, Layer.Background, true_color=True))\n\n# Convert ANSI code color value to RGB color format\nprint(Color.ansi_to_rgb('\\033[38;2;255;255;255m'))\n\n# Convert CMYK color values to corresponding ANSI code color format\nprint(Color.cmyk_to_ansi(0.0, 0.0, 0.0, 0.0, Layer.Background, true_color=True))\n\n# Convert ANSI code color value to CMYK color format\nprint(Color.ansi_to_cmyk('\\033[107m'))\n```\n\n### HEXCodes\n\nThe HEXCodes class serves as a supporting class encapsulating constants representing HEX code formats for various\ncolors, sourced from Wikipedia. For licensing information regarding the colors, please refer to the appropriate sources.\n\n# License\n\nPlease refer to the [MIT license](LICENSE) within the project for more information. Additionally, refer to\nthe [ADDITIONAL LICENSES](ADDITIONAL%20LICENSES.md) file for licensing information related to components used within\nthis package.\n\n# Contributing\n\nWe welcome contributions from the community! Whether you have ideas for new features, bug fixes, or enhancements, feel\nfree to open an issue or submit a pull request on [GitHub](https://github.com/coldsofttech/pycolorecho).\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Simple Python package for colorized terminal output",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/coldsofttech/pycolorecho"
    },
    "split_keywords": [
        "color",
        " text-color",
        " text-background-color",
        " text-effect",
        " text-case",
        " terminal",
        " colorization",
        " style",
        " text"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8d3e1f1a11b95bc2659ff4a1b0c903915bde47db4a9328f8c42e3cda7f784b38",
                "md5": "7f69cbb7a2d8b6845be0390f181b077b",
                "sha256": "7e9f1b7cd8faf22d915c7b88624a434a8d27136a55b7a1722b03be61e4d9097f"
            },
            "downloads": -1,
            "filename": "pycolorecho-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7f69cbb7a2d8b6845be0390f181b077b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 57046,
            "upload_time": "2024-05-05T06:12:33",
            "upload_time_iso_8601": "2024-05-05T06:12:33.675387Z",
            "url": "https://files.pythonhosted.org/packages/8d/3e/1f1a11b95bc2659ff4a1b0c903915bde47db4a9328f8c42e3cda7f784b38/pycolorecho-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-05 06:12:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "coldsofttech",
    "github_project": "pycolorecho",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "pytest",
            "specs": [
                [
                    "~=",
                    "7.4.0"
                ]
            ]
        },
        {
            "name": "setuptools",
            "specs": [
                [
                    "~=",
                    "69.2.0"
                ]
            ]
        }
    ],
    "lcname": "pycolorecho"
}
        
Elapsed time: 3.28943s