enrich


Nameenrich JSON
Version 1.2.7 PyPI version JSON
download
home_pagehttps://github.com/pycontribs/enrich
Summaryenrich
upload_time2022-01-10 15:30:33
maintainerSorin Sbarnea
docs_urlNone
authorSorin Sbarnea
requires_python>=3.6
licenseMIT
keywords console logging rich
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # enrich

Enriched extends [rich](https://pypi.org/project/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.

```python
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.

```python
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](https://github.com/willmcgugan/rich/discussions/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.

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



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pycontribs/enrich",
    "name": "enrich",
    "maintainer": "Sorin Sbarnea",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "sorin.sbarnea@gmail.com",
    "keywords": "console,logging,rich",
    "author": "Sorin Sbarnea",
    "author_email": "sorin.sbarnea@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/bb/77/cb9b3d6f2e2e5f8104e907ea4c4d575267238f52c51cf9f864b865a99710/enrich-1.2.7.tar.gz",
    "platform": "",
    "description": "# enrich\n\nEnriched extends [rich](https://pypi.org/project/rich/) library functionality\nwith a set of changes that were not accepted to rich itself.\n\n## Console with redirect support\n\nOur Console class adds one additional option to rich.Console in order to\nredirect `sys.stdout` and `sys.stderr` streams using a FileProxy.\n\n```python\nfrom enrich.console import Console\nimport sys\n\nconsole = Console(\n    redirect=True,  # <-- not supported by rich.cosole.Console\n    record=True)\nsys.write(\"foo\")\n\n# this assert would have passed without redirect=True\nassert console.export_text() == \"foo\"\n```\n\n## Console with implicit soft wrapping\n\nIf you want to produce fluid terminal output, one where the client terminal\ndecides where to wrap the text instead of the application, you can now\ntell the Console constructor the soft_wrap preference.\n\n```python\nfrom enrich.console import Console\nimport sys\n\nconsole = Console(soft_wrap=True)\nconsole.print(...)  # no longer need to pass soft_wrap to each print\n```\n\n## Console.print can also deal with ANSI escapes\n\nExtends Rich Console to detect if original text already had ANSI escapes and\ndecodes it before processing it. This solves the case where printing\noutput captured from other processes that contained ANSI escapes would brake.\n[upstream-404](https://github.com/willmcgugan/rich/discussions/404)\n\n## Soft-wrapping logger\n\nRich logger assumes that you always have a fixed width console and it does\nwrap logged output according to it. Our alternative logger does exactly the\nopposite: it ignores the columns of the current console and prints output\nusing a Console with soft wrapping enabled.\n\nThe result are logged lines that can be displayed on any terminal or web\npage as they will allow the client to decide when to perform the wrapping.\n\n```python\nimport logging\nfrom enrich.logging import RichHandler\n\nFORMAT = \"%(message)s\"\nlogging.basicConfig(\n    level=\"NOTSET\", format=FORMAT, datefmt=\"[%X]\", handlers=[RichHandler()]\n)\n\nlog = logging.getLogger(\"rich\")\nlog.info(\"Text that we do not want pre-wrapped by logger: %s\", 100 * \"x\")\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "enrich",
    "version": "1.2.7",
    "split_keywords": [
        "console",
        "logging",
        "rich"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7667aecd1d435dbbdcea21a197d708e9ff0bcc7306c2847c6c87cc1a91e2cca4",
                "md5": "8c64e63731fb9dc9862b7b8a53f5c1a2",
                "sha256": "f29b2c8c124b4dbd7c975ab5c3568f6c7a47938ea3b7d2106c8a3bd346545e4f"
            },
            "downloads": -1,
            "filename": "enrich-1.2.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8c64e63731fb9dc9862b7b8a53f5c1a2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8717,
            "upload_time": "2022-01-10T15:30:32",
            "upload_time_iso_8601": "2022-01-10T15:30:32.723269Z",
            "url": "https://files.pythonhosted.org/packages/76/67/aecd1d435dbbdcea21a197d708e9ff0bcc7306c2847c6c87cc1a91e2cca4/enrich-1.2.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bb77cb9b3d6f2e2e5f8104e907ea4c4d575267238f52c51cf9f864b865a99710",
                "md5": "272588dcb826a71e1745596514c11354",
                "sha256": "0a2ab0d2931dff8947012602d1234d2a3ee002d9a355b5d70be6bf5466008893"
            },
            "downloads": -1,
            "filename": "enrich-1.2.7.tar.gz",
            "has_sig": false,
            "md5_digest": "272588dcb826a71e1745596514c11354",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 16918,
            "upload_time": "2022-01-10T15:30:33",
            "upload_time_iso_8601": "2022-01-10T15:30:33.873785Z",
            "url": "https://files.pythonhosted.org/packages/bb/77/cb9b3d6f2e2e5f8104e907ea4c4d575267238f52c51cf9f864b865a99710/enrich-1.2.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-01-10 15:30:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "pycontribs",
    "github_project": "enrich",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "enrich"
}
        
Elapsed time: 0.06108s