Skip to main content

ansiformat

ANSI Formatted Text for Terminals.

AnsiFormat for Custom Formatting

Colors

from zycelium.ansiformat import AnsiFormat

af = AnsiFormat()

print(af("Red text on default background").red)
print(af("Default text on lime background").on.lime)
print(af("Black text on yellow background").black.on.yellow)
print(af("Black text on cyan background").black.on.color("#00ffff"))
print(af("Red text on yellow background").color("#ff0000").on.color("#ffff00"))

Effects

from zycelium.ansiformat import AnsiFormat

af = AnsiFormat()

print(af("Bold").bold)
print(af("Dim").dim)
print(af("Italic").italic)
print(af("Underline").underline)
print(af("Blink").blink)
print(af("Inverse").inverse)
print(af("Hidden").hidden)
print(af("Strike").strike)

Using Colors and Effects Together

from zycelium.ansiformat import AnsiFormat

af = AnsiFormat()

print(af("Red text on default background, bold").red.bold)
print(af("Same, but with shortcut (b) for bold").red.b)
print(af("Same, but with shortcut (i) for italic").red.i)
print(af("Default text on lime background, with strike-through").on.lime.strike)
print(af("Black text on yellow background, underlined").black.on.yellow.underline)
print(af("Black text on cyan background, blinking").black.on.color("#00ffff").blink)
print(af("Red text on yellow background, inversed").color("#ff0000").on.color("#ffff00").inverse)

AnsiMarkup for Quick Formatting

from zycelium.ansiformat import AnsiMarkup, palette

m = AnsiMarkup(palette=palette.midnight_ablaze)

print(m.debug("debug"))
print(m.info("info"))
print(m.ok("ok"))
print(m.warning("warning"))
print(m.error("error"))
print(m.critical("critical"))

print(m.p("paragraph"))
print(m.aside("aside"))
print(m.note("note"))
print(m.alert("alert"))

print(m.h1("heading one"))
print(m.h2("heading two"))
print(m.h3("heading three"))
print(m.h4("heading four"))
print(m.h5("heading five"))
print(m.h6("heading six"))

with m.indent():
    print(m.li("list item 1"))
    print(m.li("list item 2"))
    with m.indent():
        print(m.li("list item 2.1"))
        print(m.li("list item 2.2"))

Metadata

Release files for zycelium.ansiformat 0.1.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 zycelium.ansiformat 0.1.1
File Size Uploaded
zycelium.ansiformat-0.1.1.tar.gz 7.7 kB Details

Built distribution (wheel)

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

Total release size: 16.4 kB

Release files / zycelium.ansiformat-0.1.1.tar.gz

Download URL zycelium.ansiformat-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
8443b6769372134c1e5b76772ecc416331e4e4b97db6178c83d738ee68ecaf09
BLAKE2b-256 checksum
How to use checksums
b6796319e843061f763c2114035ff6d06a6295972cfcce2dcf918af166d61c21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

Release files / zycelium.ansiformat-0.1.1-py3-none-any.whl

Download URL zycelium.ansiformat-0.1.1-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f1db9003d3c5bca556ba9ddf80bda00f35681d2623f4f6570544fb9c0eff21c
BLAKE2b-256 checksum
How to use checksums
4b1644f24edcdf3d1f565585442d27f9ac42bdab9b0ed68a235f8adda5e57ca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.7.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

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