Skip to main content

A lightweight Python package for adding customizable terminal colors.

Project description

ptcolors Repository

ptcolors 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, ptcolors provides an easy-to-use interface to bring your text to life.

With ptcolors, 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 ptcolors'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
│       └── ptcolors.rst
├── environments
│   ├── development.env
│   ├── production.env
│   ├── staging.env
│   └── testing.env
├── requirements
│   ├── testing.txt
├── requirements.txt
├── setup.py
└── src
    ├── ptcolors
    │   ├── __init__.py
    │   └── ptcolors.py
    └── tests
        ├── __init__.py
        └── test_ptcolors.py

Example

Here's an example of how to use ptcolors:

from ptcolors.ptcolors import TColors

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

This should create a terminal output similar to the one below.

2024-08-21 10:33:39 [ NOTICE ] This is a header message.
2024-08-21 10:33:39 [ SUCCESS ] This is a success message.
2024-08-21 10:33:39 [ WARNING ] This is a warning message.
2024-08-21 10:33:39 [ FAILURE ] This is a failure message.
2024-08-21 10:33:39 [ INFORMATION ] 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.

from ptcolors.ptcolors import TColors

msg = 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.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

ptcolors-0.1.2-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ptcolors-0.1.2.tar.gz
  • Upload date:
  • Size: 8.0 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.2.tar.gz
Algorithm Hash digest
SHA256 0985ef5939d6c88304b7f5a44de57d8efd06f74ffb25c8e2e2f5dc7b5309fc90
MD5 4100ce2ba68142a3cac376e0a9d1af16
BLAKE2b-256 52f8199d6f02a28e8f981aa1ef6c6eee52d38492ac36a8ce50e8377a0b0b96f1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ptcolors-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 46b6bbed07e5c33d60b17fa07a1b3c570b5fb31a373c9f3eb2f6845684574b57
MD5 4003fe815667e003a8df53ebce65217d
BLAKE2b-256 e1c22beb460e27ecbe29ba84d8dd6ac81f13e3f73a23bc89da4334e5348e5651

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