Skip to main content

Python package and CLI tool for creating and interpreting ANSI escape codes

Project description

ansiscape

CircleCI codecov

ansiscape is a Python package for interpreting and creating ANSI escape codes.

Highlights

Create formatted text, with support for nested colours and custom RGB:

from ansiscape import Sequence, green, foreground

text = Sequence(
    green("This is ", foreground((1.0, 0.5, 0.0, 1.0), "heavy"), ", Doc,"),
    " said Marty.",
)
print(text)

Convert a string with embedded escape codes into a list of strings and explanatory dictionaries:

from ansiscape import Sequence

Sequence("Hello world, and \033[3myou\033[23m in particular!").resolved
[
  "Hello world, and ",
  {"calligraphy": Calligraphy.ITALIC},
  "you",
  {"calligraphy": Calligraphy.NONE},
  " in particular!",
]

Installation

ansiscape requires Python 3.8 or later.

pip install ansiscape

Discovering terminal support

To see examples of the formatting supported by your terminal, run:

ansiscape

The project

The source for ansiscape is available at github.com/cariad/ansiscape under the MIT licence.

And, hello! I'm Cariad Eccleston and I'm an independent/freelance software engineer. If my work has value to you, please consider sponsoring.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

ansiscape-1.0.0a2-py3-none-any.whl (31.0 kB view hashes)

Uploaded Python 3

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