Skip to main content

outta

A tool for parsing terminal control codes and escape sequences from a stream of text.

Outta was born out of a need to learn more about the control codes sent from terminal programs to the terminals that host them. The Parser class can parse a stream of text and produce a sequence of Elements that tell you what codes (and regular text) were in it.

Here’s a quick example:

from outta.parser import Parser

# Here's the text to be parsed
text = "\x1b[4COut of\x1b[3Dta control!"

# Construct a Parser and feed the text in.
parser = Parser()
elements = tuple(parser.feed(text))

# Print each of the elements
for element in elements:
    print(">", element)

# Reconstruct the input text from the elements and print it
full_text = "".join(e.text for e in elements)
assert full_text == text
print(full_text)

and here’s how that look if you run it:

% python docs/example.py
> CursorForward(parameters=(4,), keywords={}, text='\x1b[4C')
> Out of
> CursorBack(parameters=(3,), keywords={}, text='\x1b[3D')
> ta control!
    Outta control!

Metadata

Release files for outta 0.3.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 outta 0.3.1
File Size Uploaded
outta-0.3.1.tar.gz 10.8 kB Details

Built distribution (wheel)

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

Total release size: 22.0 kB

Release files / outta-0.3.1.tar.gz

Download URL outta-0.3.1.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
a3be11bd2aa81d54db753c969fccf7043463626ff5ca6ad62598b0d42b622f01
BLAKE2b-256 checksum
How to use checksums
9f0ab1830365d0d5525d75742b76408a26c304b5ba702fed87461c551b1d319c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release files / outta-0.3.1-py3-none-any.whl

Download URL outta-0.3.1-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a99821716f438e544f5e6655b933643aca570963b50571de9f1ce057b696ce43
BLAKE2b-256 checksum
How to use checksums
49a834aeaddbc389a6af2ea1bf1775b565dfda27d2cb7c5a0066a885d502ab04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.2

2 release files

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