Skip to main content

PrettyPy

PyPI - Python Version PyPI version PyPI - Downloads

PrettyPy is a Python library that simplifies printing colored and styled messages in CLI applications. With PrettyPy, you can easily print status updates, error messages, and other types of messages with colored indicators that help them stand out.

The library offers a straightforward API for creating custom layouts, as well as a range of pre-built layouts that you can use to enhance the readability of your CLI applications.

PrettyPy uses ANSI escape codes to provide its coloring functionality, which is supported by most terminals. If your terminal does not support ANSI escape codes, you can set the no-color flag to disable the coloring functionality.

By using PrettyPy, you can create user-friendly CLI applications that are easier to read and more engaging.

Features

  • Print messages with colors and styles
  • Create custom layouts
  • No color mode
  • Table output
  • Updating messages
  • Progress bars
  • Spinners
  • Desktop notifications

Installation

pip install prettypy

Getting Started

The PrettyPy package is a Python library that provides an easy-to-use API for printing colored and styled messages in CLI applications. With the help of PrettyPy, you can quickly and easily print status updates, error messages, and other types of messages with colored indicators that help them stand out and improve the readability of your CLI applications.

To start using PrettyPy, you need to create an instance of the Pretty class. Once you have done this, you can use the Pretty class methods for each mode to print your messages. You can also use the Pretty class as a dictionary to access its modes, and you can even reassign Python's built-in print function to one of PrettyPy's modes.

If you need to create your own layouts, you can use the Composer class to customize the output even further. The Composer allows you to add new layouts, change the padding of the layout to align all your messages and improve the readability of your output.

Here's a code example that demonstrates how to use the PrettyPy package:

from prettypy import Pretty

# Create an instance of the Pretty class
pretty = Pretty()

# Use the Pretty class methods for each mode to print messages
pretty.info("This is an info message.")
pretty.success("This is a success message.")

# Access Pretty class modes as a dictionary
for mode in pretty:
    pretty.__getattribute__(mode.name)(f"This is a {mode} message.")

# Reassign Python's built-in print function to one of PrettyPy's modes
print = pretty.neutral
print("This is a neutral message printed using the print function.")

# Use the Composer class to create new layouts
composer = pretty.get_composer()
pretty.add("test", "[TEST]", "red", text_format="bold")

# Use new layout created by the composer print method
pretty.test("This is a test message printed using the composer print method.")

# Change the padding of the layout with the Composer
composer.set_padding()

# Print messages again to demonstrate the padding
pretty.info("This is an info message.")
pretty.success("This is a success message.")
pretty.test("This is a test message printed using the composer print method.")

[i] This is an info message.
[✓] This is a success message.
[X] This is a error message.
...

With the PrettyPy package, you can make your CLI applications more user-friendly, readable, and engaging. The package is easy to use, and it allows you to quickly and easily create custom layouts to suit your needs.


GitHub repo size GitHub commit activity

GitHub issues GitHub closed issues GitHub pull requests

GitHub contributors

Release files for prettypy 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prettypy 0.2.1
File Size Uploaded
prettypy-0.2.1.tar.gz 8.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prettypy 0.2.1
File Interpreter ABI Platform
prettypy-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.4 kB

Release files / prettypy-0.2.1.tar.gz

Download URL prettypy-0.2.1.tar.gz
Size 8.2 kB
Tags Source
SHA-256 checksum
How to use checksums
f889bf98c573c3e8d01aaffc5133dd292c983b8508236c614f6899f1fef4a50e
BLAKE2b-256 checksum
How to use checksums
cd8eff8dc6584fd6506478089a0692f5063da69c7b4f6e3a2c4878693e44fb3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release files / prettypy-0.2.1-py3-none-any.whl

Download URL prettypy-0.2.1-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
801a8af878e33fca3416e9160f0195a87bc212f68ffcae987cb94b013ec01449
BLAKE2b-256 checksum
How to use checksums
91fe8a11bf7b4bbd2f111dc2d9d225ec2029cdd6705720472eda7380baccf615
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.16

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page