{ "info": { "author": "Michael Brennan", "author_email": "brennan.brisad@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Operating System :: POSIX", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7" ], "description": "===============================\ngrec\n===============================\n\n.. image:: https://badge.fury.io/py/grec.png\n :target: http://badge.fury.io/py/grec\n\n.. image:: https://travis-ci.org/brisad/grec.png?branch=master\n :target: https://travis-ci.org/brisad/grec\n\n.. image:: https://pypip.in/d/grec/badge.png\n :target: https://pypi.python.org/pypi/grec\n\n\nColorize terminal text with regular expressions.\n\n* Free software: GPL version 3\n* Documentation: https://grec.readthedocs.org.\n\nFeatures\n--------\n\n`grec` is similar to `grep`; the difference being that instead of\nprinting matching lines in a file, `grec` colorizes lines. Lines that\ndo not match any pattern are still printed, but without color.\n\nThe key feature that separates this utility from other similar ones is\nthat it's possible to colorize a matching string several times without\nletting previously matched colors mess up following regular expression\nmatches.\n\n\nQuick Start\n-----------\n\nInstall with `pip`::\n\n pip install grec\n\nPrint the contents of `log_file.txt` in its entirety but also colorize\nany occurrences of errors and warnings::\n\n grec -m ERROR red -m WARN yellow log_file.txt\n\nOr use a pipe::\n\n cat log_file.txt | grec -m ERROR red -m WARN yellow -\n\nTo colorize strings in Python code, use the `Matcher` class from the\n`grec` package::\n\n >>> from grec import Matcher\n >>> m = Matcher()\n >>> m.add_pattern('ERROR', 'red')\n >>> m.add_pattern('WARN', 'yellow')\n >>> print m.match('ERROR WARN INFO')\n ERROR WARN INFO (with color)\n\nCommand line\n------------\n\nThe command line interface is the following::\n\n grec [-m PATTERN COLOR_INFO] [-g PATTERN [COLOR_INFO ...]] -- file\n\nThe `-m` argument\n~~~~~~~~~~~~~~~~~\n\nThis argument takes a regular expression and color information.\nHere's an example that will make all lines starting with the character\n\"#\" have a green color with white background::\n\n -m '^#.*' green_on_white\n\nWhenever a line matches the regular expression, the part of the line\nthat matched is colorized with the color information. Any number of\n`-m` arguments can be specified, and colorization will be applied in\nthe order specified on the command line.\n\nThe regular expression will be matched by the `re` module. So for\neach regular expression, only non-overlapping matches will be\ncolorized. To get overlapping matches use several patterns by adding\nmore `-m` arguments.\n\nColor information consists of a foreground and optionally a\nbackground. Colorization is performed with the `termcolor` package\nand thus the following colors are supported: *grey*, *red*, *green*,\n*yellow*, *blue*, *magenta*, *cyan*, *white*.\n\nTo only set the foreground color, simply specify the name of the\ncolor. To also set a background color, add it to the foreground\ncolor. Use quotes or underlines to prevent the shell from\ninterpreting it as several arguments. Examples::\n\n -m blue_on_yellow\n -m blue_yellow\n -m 'blue on yellow'\n -m 'blue yellow'\n\nThe `-g` argument\n~~~~~~~~~~~~~~~~~\n\nThis argument is similar to `-m` but with the difference that instead\nof colorizing the whole match, this creates a group pattern that only\ncolorizes matched groups of the regular expression.\n\nBecause one can have multiple groups within a regular expression, this\nargument accepts multiple colors. Here's an example which will\ncolorize the first group with green color on white background and the\nsecond with yellow foreground::\n\n -g '^(#)(.*)' green_on_white yellow\n\nIf more colors than there are groups in the regular expression are\nspecified, they will be ignored. If the number of colors is less than\nthe groups, the last color specified for the pattern will be used to\ncolorize all of the remaining group matches.\n\nThe file argument\n~~~~~~~~~~~~~~~~~\n\nThis is the file to colorize. If \"-\" is specified, `stdin` will be\nread instead and can be used to colorize the output of a pipe.\n\nIf no file is given, `stdin` will be used as the default.\n\nTODO\n----\n\n* Add support for attributes like blinking\n* Add support for only changing background color from CLI\n* Python 3 support\n\n\n\n\nHistory\n-------\n\n0.2.0 (2014-10-14)\n------------------\n\n* Added support for colorizing groups in regular expressions\n\n0.1.0 (2014-09-26)\n------------------\n\n* First release on PyPI.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/brisad/grec", "keywords": "grec", "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "grec", "package_url": "https://pypi.org/project/grec/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/grec/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/brisad/grec" }, "release_url": "https://pypi.org/project/grec/0.2.0/", "requires_dist": null, "requires_python": null, "summary": "Colorize terminal text with regular expressions.", "version": "0.2.0" }, "last_serial": 1270021, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "3ac93c2d692cb1e622d4117648e3b388", "sha256": "50e520eef86d18e5ccc28f65a9bbf409395b63538dbffe0eeacaa14906f2bd19" }, "downloads": -1, "filename": "grec-0.1.0.tar.gz", "has_sig": false, "md5_digest": "3ac93c2d692cb1e622d4117648e3b388", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 29345, "upload_time": "2014-09-28T17:51:37", "url": "https://files.pythonhosted.org/packages/09/0a/d3841b59782b3dc49fbe4c4ef37cd4b60203d853df02977c03786fef8105/grec-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c1e1ad8f6244c045640c2bf5910a6780", "sha256": "ebcefa0888e52ba1cd3103d1216f1a2bbbd51a369920518bd99460f564b614b3" }, "downloads": -1, "filename": "grec-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c1e1ad8f6244c045640c2bf5910a6780", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31311, "upload_time": "2014-10-14T13:50:38", "url": "https://files.pythonhosted.org/packages/7a/fd/bd22942443b629fcd4dad3fd6907e405b59682cfd822cb1e125657fcc0f4/grec-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c1e1ad8f6244c045640c2bf5910a6780", "sha256": "ebcefa0888e52ba1cd3103d1216f1a2bbbd51a369920518bd99460f564b614b3" }, "downloads": -1, "filename": "grec-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c1e1ad8f6244c045640c2bf5910a6780", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 31311, "upload_time": "2014-10-14T13:50:38", "url": "https://files.pythonhosted.org/packages/7a/fd/bd22942443b629fcd4dad3fd6907e405b59682cfd822cb1e125657fcc0f4/grec-0.2.0.tar.gz" } ] }