pycontribs / enrich Goto Github PK
View Code? Open in Web Editor NEWEnrich adds few missing features to the wonderful rich library.
License: MIT License
Enrich adds few missing features to the wonderful rich library.
License: MIT License
I will name this feature FluidLogger as it is supposed to produce log lines that are not wrapped to the terminal width.
The reasoning behind this feature are the same as described on #1
Some users do not want to take in consideration the width of the terminal but still make use of most of the features provides by Rich library.
At this moment this is not possible and a change to add this to Rich was refused, so we will have to add it here.
This is a common use case for tools running in CI/CD pipelines, where they would still want to produce colorful output but where there is not real fixed width terminal, as the produced log would endup being visualized inside the browser, where browser will decide where to wrap the lines or if to wrap them at all.
A soft wrapped console is also useful for normal terminals output as it allows user to resize its terminal window without having too see weird wrappings. Terminals do soft-wrapping by default.
Hello. Would it make sense to do a new release? There are some important changes since the last one.
Hi! I'm packaging this project on Arch Linux.
I noticed that the test files are installed alongside the files of this project, but they are not required during runtime and should therefore end up on a user system.
rich >= 9.5.0 appears to have some changes that break enrich. This in turn is breaking molecule, as seen in ansible/molecule#3010.
The following test (test_rich_console_ex) fails with:
========================================================================
src/enrich/test/test_console.py::test_rich_console_ex
____________________________ test_rich_console_ex _____________________________
def test_rich_console_ex() -> None:
"""Validate that ConsoleEx can capture output from print() calls."""
console = Console(record=True, redirect=True)
console.print("alpha")
print("beta")
sys.stdout.write("gamma\n")
sys.stderr.write("delta\n")
# While not supposed to happen we want to be sure that this will not raise
# an exception. Some libraries may still sometimes send bytes to the
# streams, notable example being click.
# sys.stdout.write(b"epsilon\n") # type: ignore
text = console.export_text()
assert text == "alpha\nbeta\ngamma\ndelta\n"
E AssertionError: assert 'alpha\nbeta...elta\ndelta\n' == 'alpha\nbeta\ngamma\ndelta\n'
E alpha
E beta
E + beta
E + gamma
E gamma
E delta
E + delta
src/enrich/test/test_console.py:23: AssertionError
----------------------------- Captured stdout call -----------------------------
alpha
beta
gamma
delta
========================================================================
It seems the FluidLogRender doesn't work well with messages containing newlines:
import logging
from enrich.logging import RichHandler
logging.basicConfig(level="INFO", handlers=[RichHandler()])
log = logging.getLogger("rich")
log.info("Text that we\ndo not want\npre-wrapped by logger: %s", 100 * "x")
While testing enrich in an environment with rich 12.5.1 installed, I'm seeing duplicated text in the console buffer, and I'm struggling to work out how this happens. Test failure is below:
[ 4s] def test_rich_console_ex() -> None:
[ 4s] """Validate that ConsoleEx can capture output from print() calls."""
[ 4s] console = Console(record=True, redirect=True)
[ 4s] console.print("alpha")
[ 4s] print("beta")
[ 4s] sys.stdout.write("gamma\n")
[ 4s] sys.stderr.write("delta\n")
[ 4s] # While not supposed to happen we want to be sure that this will not raise
[ 4s] # an exception. Some libraries may still sometimes send bytes to the
[ 4s] # streams, notable example being click.
[ 4s] # sys.stdout.write(b"epsilon\n") # type: ignore
[ 4s] text = console.export_text()
[ 4s] > assert text == "alpha\nbeta\ngamma\ndelta\n"
[ 4s] E AssertionError: assert 'alpha\nbeta\...elta\ndelta\n' == 'alpha\nbeta\ngamma\ndelta\n'
[ 4s] E alpha
[ 4s] E beta
[ 4s] E + beta
[ 4s] E + gamma
[ 4s] E gamma
[ 4s] E delta
[ 4s] E + delta
[ 4s]
[ 4s] src/enrich/test/test_console.py:23: AssertionError
I found that https://github.com/pycontribs/enrich/releases/tag/v1.3.0 newly released for python >= 3.9
, but couldn't check out with pip list --outdated
.
Shall we also upload the package to https://pypi.org/project/enrich/1.3.0 accordingly?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.