Skip to main content

A lightweight Python package for adding customizable terminal colors.

Project description

tcolors Repository

tcolors is a lightweight Python package designed to add vibrant, customizable colors to your terminal output with minimal effort. Whether you’re building command-line applications, scripts, or simply want to enhance the readability of your terminal messages, tcolors provides an easy-to-use interface to bring your text to life.

With tcolors, you can apply a wide range of colors and styles to your terminal text, making it more engaging and visually appealing. It's perfect for developers who want to add a splash of color to their terminal without dealing with the complexities of ANSI escape codes.

Project Status

Here's the current status of our workflows:

Workflow Status
Continuous Integration Continuous-Integration
Continuous Deployment Continuous-Deployment
Documentation Docs
Guard Main Branch Guard Main Branch
Lint Codebase Lint Code Base
Release Log Release Log

Components

The tcolors's codebase structure is as shown below:

.
├── LICENSE
├── README.md
├── VERSION
├── build_docs
│   ├── Makefile
│   ├── __init__.py
│   ├── build
│   ├── make.bat
│   └── src
│       ├── __init__.py
│       ├── _static
│       ├── _templates
│       ├── conf.py
│       ├── index.rst
│       └── tcolors.rst
├── environments
│   ├── development.env
│   ├── production.env
│   ├── staging.env
│   └── testing.env
├── requirements.txt
├── setup.py
└── src
    ├── tcolors
    │   ├── __init__.py
    │   └── tcolors.py
    └── tests
        ├── __init__.py
        └── test_tcolors.py

Example

Here's an example of how to use tcolors:

# test_import.py
from tcolors.tcolors import TColors

tcolors = TColors()
tcolors.headermsg("This is a header message.")
tcolors.okmsg("This is a success message.")
tcolors.warnmsg("This is a warning message.")
tcolors.failmsg("This is a failure message.")
tcolors.infomsg("This is an info message.")

Here’s an example of using a context manager to handle resources, like managing messages during a function’s execution. Context managers in Python, typically implemented with the with statement, allow you to control resource allocation and release efficiently.

msg = wu.TColors()

def __call__(self):
    """Run the target sequence."""
    # The context manager is entered here, and the messages are set up.
    with self.msg.messages(
        f"Starting {self.name()}...",  # Message displayed at the start
        f"{self.name()} complete.",    # Message displayed on successful completion
        f"{self.name()} failed.",      # Message displayed on failure
        self.config["function"],       # The function to be executed
        *self.config["function-arguments"],  # Positional arguments for the function
        **self.config,                 # Keyword arguments for the function
    ) as status:
        # The status is set based on the outcome of the context manager block
        self.status = status

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ptcolors-0.1.0.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

ptcolors-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file ptcolors-0.1.0.tar.gz.

File metadata

  • Download URL: ptcolors-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ptcolors-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f56b26ca14f7695c8db911c82affd53a87d7d269b87a589fece0d0ee41cce0f0
MD5 91ea31fe30f448598e1f2e980f345f17
BLAKE2b-256 9b0df19b4eeb5faf416264ead307355cd136f2154bec3306b8afcc8f4da9b114

See more details on using hashes here.

File details

Details for the file ptcolors-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ptcolors-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for ptcolors-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ea2111cd88252a4b16df31397a3605f24b8f42e8d895844ba10c1df52e3f0781
MD5 465e6bf4c46364c6df2c236dccaa7c74
BLAKE2b-256 259dea6dbb5027cdf63d85ef11d297096c3c8c8ef0d5fd5a581610834e9770fd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page