All Projects → pycontribs → enrich

pycontribs / enrich

Licence: MIT license
Enrich adds few missing features to the wonderful rich library.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to enrich

Huepy
Print awesomely in terminals.
Stars: ✭ 1,421 (+7005%)
Mutual labels:  colorama, terminal-colors
tidalRPC
Discord Rich Presence for Tidal
Stars: ✭ 15 (-25%)
Mutual labels:  rich
TermColor
🎨 Effortlessly generate color-schemes for terminal emulators by a single drop of an image!
Stars: ✭ 40 (+100%)
Mutual labels:  terminal-colors
ugly-todo
Just an Ugly To-Do app that I wanted to develop.
Stars: ✭ 35 (+75%)
Mutual labels:  rich
pystyle
The source of my Python library, pystyle.
Stars: ✭ 158 (+690%)
Mutual labels:  colorama
hook-slinger
A generic service to send, retry, and manage webhooks.
Stars: ✭ 88 (+340%)
Mutual labels:  rich
tamcolors
tamcolors is a terminal game library which supports multiplayer and audio. tamcolors gives a buffer which lets the user set the character, foreground color and background color which can draw at a stable FPS of 25 on all supported console.
Stars: ✭ 24 (+20%)
Mutual labels:  terminal-colors
Braft Editor
美观易用的React富文本编辑器,基于draft-js开发
Stars: ✭ 4,310 (+21450%)
Mutual labels:  rich
markdown-it-editor
a markdown rich text editor base on markdown-it and vue2
Stars: ✭ 59 (+195%)
Mutual labels:  rich
samp-discord-plugin
SA:MP Discord Rich Presence plugin
Stars: ✭ 63 (+215%)
Mutual labels:  rich
pypi-command-line
A powerful, colorful, beautiful command-line-interface for pypi.org
Stars: ✭ 32 (+60%)
Mutual labels:  rich
vulpw
A Password Vulnerability checker
Stars: ✭ 14 (-30%)
Mutual labels:  colorama
rich input
Rich input box, implement @Someone and subject with color highlighting
Stars: ✭ 58 (+190%)
Mutual labels:  rich
Indicators
Activity Indicators for Modern C++
Stars: ✭ 1,838 (+9090%)
Mutual labels:  terminal-colors
csgo richpresence
Discord Rich Presence support for Counter-Strike: Global Offensive!
Stars: ✭ 16 (-20%)
Mutual labels:  rich
go-windows-terminal-sequences
Enable support for Windows Terminal Colors
Stars: ✭ 27 (+35%)
Mutual labels:  terminal-colors
textual
Textual is a TUI (Text User Interface) framework for Python inspired by modern web development.
Stars: ✭ 16,180 (+80800%)
Mutual labels:  rich
Rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 31,664 (+158220%)
Mutual labels:  rich
v-oogle
Google.com, reVued. 🔎
Stars: ✭ 40 (+100%)
Mutual labels:  rich
rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
Stars: ✭ 36,988 (+184840%)
Mutual labels:  rich

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.console.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")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].