Metadata-Version: 2.4
Name: printcolorpt
Version: 0.2.0
Summary: Handy ANSI color and text-style helpers for beautiful Python terminal output.
Author: Parasky
License: MIT
Project-URL: Homepage, https://pypi.org/project/printcolorpt/
Project-URL: Repository, https://pypi.org/project/printcolorpt/
Project-URL: Issues, https://pypi.org/project/printcolorpt/
Keywords: print,color,ansi,terminal,logging,debug,console,pretty-print
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Environment :: Console
Classifier: Topic :: Utilities
Requires-Python: >=3.6
Description-Content-Type: text/markdown

# printcolorpt

[![PyPI version](https://img.shields.io/pypi/v/printcolorpt.svg)](https://pypi.org/project/printcolorpt/)
[![Python](https://img.shields.io/pypi/pyversions/printcolorpt.svg)](https://pypi.org/project/printcolorpt/)

**printcolorpt** is a handy ANSI styling helper for Python.

It gives you short, memorable functions for colored terminal output:

```python
from pt import *

printR("error")
printG("success")
printY("warning")
printB("info")
printO("orange")
printC("cyan")
printD("debug")
```

Version **0.2.0** expands the public API from 10 helpers to **17 helpers**:

- 7 full-line print helpers
- 7 inline color wrappers
- 3 raw text-style constants (NEW)

---

## Installation

```bash
pip install printcolorpt
```

## Quick start

```python
from pt import *

printR("failed", bold=True)
printG("completed", underline=True)
printY("check this value", italic=True)
printD("debug log", bold=True, italic=True)
```

The `print*` helpers behave like Python's built-in `print()` for common arguments such as `sep`, `end`, `file`, and `flush`.

```python
from pt import *

printB("x", "y", "z", sep=" -> ")
printC("loading", end="... ", flush=True)
printG("done")
```

---

## Full-line color printing

Use these when the entire output line should have one color.

```python
from pt import *

printR("red")
printG("green")
printY("yellow")
printB("blue")
printO("orange")
printC("cyan")
printD("dark gray debug")
```

Each print helper supports the same three style flags:

```python
from pt import *

printR("bold red", bold=True)
printG("italic green", italic=True)
printB("underlined blue", underline=True)
printO("bold italic underlined orange", bold=True, italic=True, underline=True)
```

---

## Inline color composition

Use uppercase color wrappers when one line needs multiple colors.

```python
from pt import *

print(
    RED("ERROR")
    + " | "
    + YELLOW("retrying")
    + " | "
    + GREEN("recovered")
)
```

A practical status line:

```python
from pt import *

filename = "records.parquet"
rows = 1_240_000
seconds = 3.82

print(
    BLUE("READ")
    + " "
    + filename
    + " | "
    + GREEN(f"{rows:,} rows")
    + " | "
    + DEBUG(f"{seconds:.2f}s")
)
```

A clean validation summary:

```python
from pt import *

passed = 132
failed = 1
skipped = 4

print(
    BOLD + "TEST "
    + GREEN(f"PASS={passed}")
    + "  "
    + RED(f"FAIL={failed}")
    + "  "
    + YELLOW(f"SKIP={skipped}")
)
```

---

## Text styles

`BOLD`, `ITALIC`, and `UNDERLINE` are raw ANSI style constants.

```python
from pt import *

print(BOLD + RED("bold red"))
print(ITALIC + BLUE("italic blue"))
print(UNDERLINE + CYAN("underlined cyan"))
```

When composing several styled segments, remember that every color wrapper resets the style at the end of its own text. Re-apply a style before the next segment when needed.

```python
from pt import *

print(
    ITALIC + RED("italic red")
    + "  "
    + ITALIC + UNDERLINE + BLUE("italic underlined blue")
)
```

---

## Debugging recipes

### Compact debug markers

```python
from pt import *

printD("[1/4] load input")
printB("[2/4] normalize columns")
printY("[3/4] validate missing values")
printG("[4/4] export completed")
```

### Loop progress

```python
from pt import *

items = ["address", "geometry", "date", "score"]

for i, name in enumerate(items, start=1):
    printB(f"[{i}/{len(items)}] processing {name}")
    # do something here

printG("all steps completed", bold=True)
```

### Exception-friendly output

```python
from pt import *

try:
    value = int("not-a-number")
except ValueError as e:
    printR("ValueError:", e, bold=True)
    printD("hint: check the input type before conversion")
```

### Data pipeline style

```python
from pt import *

print(BOLD + BLUE("PIPELINE START"))
printD("reading source file")
printY("missing values detected in 2 columns")
printG("geometry validation passed")
print(BOLD + GREEN("PIPELINE DONE"))
```

---

## Public API

### Print helpers

| Function | Color | Typical use |
|---|---:|---|
| `printR(...)` | red | errors, failures |
| `printG(...)` | green | success, completion |
| `printY(...)` | yellow | warnings, checkpoints |
| `printB(...)` | blue | information, steps |
| `printO(...)` | orange | highlights, attention |
| `printC(...)` | cyan | secondary information |
| `printD(...)` | dark gray | debug messages |

### Inline color wrappers

| Function | Color |
|---|---:|
| `RED(text)` | red |
| `GREEN(text)` | green |
| `YELLOW(text)` | yellow |
| `BLUE(text)` | blue |
| `ORANGE(text)` | orange |
| `CYAN(text)` | cyan |
| `DEBUG(text)` | dark gray |

### Style constants

| Constant | Meaning |
|---|---|
| `BOLD` | bold text |
| `ITALIC` | italic text |
| `UNDERLINE` | underlined text |

---

## 0.2.0 highlights

- Added `printO()` and `ORANGE()`.
- Added `printC()` and `CYAN()`.
- Added `BOLD`, `ITALIC`, and `UNDERLINE`.
- Added style flags to print helpers: `bold`, `italic`, `underline`.
- Keeps the original simple import style: `from pt import *`.
- Still no external dependencies.

---

## Notes

This package uses ANSI escape sequences. Color rendering depends on the terminal or notebook frontend. It works best in modern terminals, VS Code terminals, and Jupyter environments that support ANSI colors.
