Skip to main content

enrich

Project description

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

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")

Project details


Download files

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

Source Distribution

enrich-1.1.tar.gz (14.4 kB view details)

Uploaded Source

Built Distribution

enrich-1.1-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file enrich-1.1.tar.gz.

File metadata

  • Download URL: enrich-1.1.tar.gz
  • Upload date:
  • Size: 14.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for enrich-1.1.tar.gz
Algorithm Hash digest
SHA256 13498eaaded3dec5f15e49749c55dc94d6b93eba1f20d183eca4e76aded7908c
MD5 5683112f5599729dc1284552a40ab78a
BLAKE2b-256 90ff6b3e4d7788c0add0a97dc8f95f96f9bdca3f57888ec37e9a54ccc68797ab

See more details on using hashes here.

File details

Details for the file enrich-1.1-py3-none-any.whl.

File metadata

  • Download URL: enrich-1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.52.0 CPython/3.8.6

File hashes

Hashes for enrich-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3caf19c3881aec26b17b43092b2ddf408c76593b457fa18b7143de867eceb828
MD5 df5af598ef1dc8602fb841fafd60fd2b
BLAKE2b-256 6f1cc306704426595679de25959dd40657340bd30b8e403d1b03e5ce3fa476c7

See more details on using hashes here.

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