Skip to main content

enrich

Enriched extends rich library functionality with a set of changes that were not accepted to rich itself.

Console with redirect support

Our Console class adds one additional option to rich.Console in order to redirect sys.stdout and sys.stderr streams using a FileProxy.

from enrich.console import Console
import sys

console = Console(
    redirect=True,  # <-- not supported by rich.cosole.Console
    record=True)
sys.write("foo")

# this assert would have passed without redirect=True
assert console.export_text() == "foo"

Console with implicit soft wrapping

If you want to produce fluid terminal output, one where the client terminal decides where to wrap the text instead of the application, you can now tell the Console constructor the soft_wrap preference.

from enrich.console import Console
import sys

console = Console(soft_wrap=True)
console.print(...)  # no longer need to pass soft_wrap to each print

Console.print can also deal with ANSI escapes

Extends Rich Console to detect if original text already had ANSI escapes and decodes it before processing it. This solves the case where printing output captured from other processes that contained ANSI escapes would brake. upstream-404

Soft-wrapping logger

Rich logger assumes that you always have a fixed width console and it does wrap logged output according to it. Our alternative logger does exactly the opposite: it ignores the columns of the current console and prints output using a Console with soft wrapping enabled.

The result are logged lines that can be displayed on any terminal or web page as they will allow the client to decide when to perform the wrapping.

import logging
from enrich.logging import RichHandler

FORMAT = "%(message)s"
logging.basicConfig(
    level="NOTSET", format=FORMAT, datefmt="[%X]", handlers=[RichHandler()]
)

log = logging.getLogger("rich")
log.info("Text that we do not want pre-wrapped by logger: %s", 100 * "x")

Release files for enrich 1.2.7

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

Source distribution (sdist)

Source distribution for enrich 1.2.7
File Size Uploaded
enrich-1.2.7.tar.gz 16.9 kB Details

Built distribution (wheel)

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

Total release size: 25.6 kB

Release files / enrich-1.2.7.tar.gz

Download URL enrich-1.2.7.tar.gz
Size 16.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0a2ab0d2931dff8947012602d1234d2a3ee002d9a355b5d70be6bf5466008893
BLAKE2b-256 checksum
How to use checksums
bb77cb9b3d6f2e2e5f8104e907ea4c4d575267238f52c51cf9f864b865a99710
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / enrich-1.2.7-py3-none-any.whl

Download URL enrich-1.2.7-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f29b2c8c124b4dbd7c975ab5c3568f6c7a47938ea3b7d2106c8a3bd346545e4f
BLAKE2b-256 checksum
How to use checksums
7667aecd1d435dbbdcea21a197d708e9ff0bcc7306c2847c6c87cc1a91e2cca4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

This release

1.2.7 This release

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2

2 release files

1.1

2 release files

1.0

2 release files

0.1

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