Skip to main content

piecolor

Series of tools for python3, releasing to PyPi.

# Install for Testing
# System
/usr/bin/python3 -m pip install -e .
# brew
python3 -m pip install -e .

This package currently includes 4 different libraries: - A text coloring library, along with argparse colorization (counts as 2). - A process listing library (ala ps which does NOT work in Windows). - A set of routines to pull methods and instance variables from one class into another.

Terminal Colors

Probably most of most interest: the text coloring and color argparse libraries.

import  piecolor.term.colors as c
import  piecolor.script.argparse_color as ColorArgparse

The focus here is on simplicity and readability. Instead of cumbersome escape codes, cumbersome color names and the overall cumbersomeness of using color, it's as easy as the proverbial pie.

The colors library includes five palettes. They can be used individually, or mixed and matched in the same code.

The first three palettes provide different common naming conventions for the xterm 256 color palette.

The first 8 base colors all have single-letter counterparts from RGB and CMYK. The delimiter, system and solarized palettes include similarly abbreviated color names. This makes coloring text a lot nicer looking in code.

R - red G - green B - blue C - cyan M - magenta Y - yellow K - black W - white N - reset to system normal

Preceding each with 'X' (for "extended" colors) takes us to the 16-color palette.

XR - extended red XG - extended green etc.

The Solarized palette includes the exact same 16-color naming, though each color name represents an different actual color. It also includes the violet, orange and the special names invented for Solarized itself. Solarized has a mild, Matrix-like green tint.

V - violet O - orange b03 - base03 b02 - base02 b01 - base01 b00 - base00 b0 - base0 b1 - base1 b3 - base3 b2 - base2

Note that we can code coloring in two ways: with methods or with instance variables. The methods use lower case names while the variables use upper_case names. The methods always reset the color back to "normal" (no color), while the instance variables work better when setting multiple colors in text.

Palettes

  • ANSI The common "ANSI" standard color names.
import  piecolor.term.colors as c

print("I'm so mad, I'm seeing", c.ansi.r("red!"))
print("Better than being," c.ansi.y("yellow"), "with envy")

ca = c.ansi # a bit of abbreviating
print(ca.R + "Happy", ca.W + "Fourth", ca.B + "of July" + ca.N)
  • SOLARIZED
import  piecolor.term.colors as c

print(c.sol.b01("A greyscale-ish color named base01!"))
  • X11 These names come from the X11 'rgb.txt' file found on many systems. They overlap heavily with the ANSI palette, but some names may appear only one or the other, and some which do match may actually have slightly different color values.
import  piecolor.term.colors as c

print(c.x11.chocolate("I love chocolate!"))
  • SYSTEM Colorization for common system terms, akin to color ls.

e - exe cmd - command f - file d - dir or even directory l - link mp - mount h - hostname u - username

  • Delimiters A word of wisdom: colorizing delimiters looks really great, but are a huge hassle. This palette doesn't just change the color: it inserts the actual colorized delimiters as well. These only exist as functions, and typically work best for double-delimiaters like '()' etc.
print("We use the html tag", c.dlm.angle("p"), "for paragraphs)
print("A graph starting at", c.dlm.coord(1, 2))

Release files for piecolor 3.2.0

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

Source distribution (sdist)

Source distribution for piecolor 3.2.0
File Size Uploaded
piecolor-3.2.0.tar.gz 96.8 kB Details

Built distribution (wheel)

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

Total release size: 201.0 kB

Release files / piecolor-3.2.0.tar.gz

Download URL piecolor-3.2.0.tar.gz
Size 96.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f1e26d7ed8ab379ac67b655e07af50e212e4fd7e38a8d2d793307bf1021a710c
BLAKE2b-256 checksum
How to use checksums
6ed214e4ceb8dffde6fd00b54c6d8fea37bcda546e1c2ff465072c109f41878b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release files / piecolor-3.2.0-py3-none-any.whl

Download URL piecolor-3.2.0-py3-none-any.whl
Size 104.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bfc26fcb710515b160dc54ecbc7778a74da12d14eec85f6da2afb9974bb179bf
BLAKE2b-256 checksum
How to use checksums
95968fd07059766a6766538265c8348cd2325b78ffa1b750b158f6f482950521
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.10.21

Release history Release notifications | RSS feed

3.2.2

2 release files

3.2.1

2 release files

This release

3.2.0 This release

2 release files

3.1.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