{ "info": { "author": "Michel Albert", "author_email": "michel@albert.lu", "bugtrack_url": null, "classifiers": [], "description": "Generic Colorizer\n=================\n\n.. note:: Inspired by http://kassiopeia.juls.savba.sk/~garabik/software/grc.html\n\n``grc`` allows you to colorize (even transform) shell output.\n\nAlternatives\n============\n\nThe original ``grc``\n--------------------\n\nAvailable at http://kassiopeia.juls.savba.sk/~garabik/software/grc.html\n\nWhile the original ``grc`` is a bit smarter with subprocesses, this rewrite\nfocuses on ease of use (including `Installation`_, `Configuration`_ and\n`source-code access`_).\n\nInstallation should also honour the `Linux FHS`_\n\n``sed`` or ``awk``\n------------------\n\n``sed`` and ``awk`` are extremely powerful tools, and can certainly do what\n``grc`` does. They will certainly perform better on large streams. It's their\nintended use afterall. *However*, they both use an archaic and arcane syntax\nfor their scripts. Additionally, if you would like to colorize your output\nwith these, you need to work with ANSI escape sequences. ``grc`` aims to\nsimplify this by having a more readable `Configuration`_ syntax, and by hiding\nthe ANSI escape sequences.\n\n.. include:: INSTALL.rst\n\nUsage\n=====\n\nRead lines from ``stdin`` and emit modified/colorized lines on ``stdout``\n-------------------------------------------------------------------------\n\n.. note:: This is the best supported mode of operation.\n\nSynopsis\n~~~~~~~~\n\n::\n\n | grc -c \n\nExample\n~~~~~~~\n\n::\n\n tail -f /var/log/apache2/access.log | grc -c apache_access\n\n**Advantages**\n * Only the stream you are sending to ``grc`` is affected.\n * No known side-effects\n\n**Disadvantages**\n * As ``grc`` only sees a stream, it cannot determine what application is\n emitting the stream. You have to specify the config manually.\n\nSpawn a subprocess, capture it's output\n---------------------------------------\n\n.. note:: Use this if you don't care about the downsides, and are lazy to\n type.\n\nSynopsis\n~~~~~~~~\n\n::\n\n grc \n\nExample\n~~~~~~~\n\n::\n\n grc aptitude search python\n\n**Advantages**\n * Much less to type\n * Can auto-detect the config by using the sub-process application name.\n\n**Disadvantages**\n * Spawning a subprocess and interacting with it's IO is non-trivial on a\n TTY/PTY. To simplify the code, ``grc`` uses ``pexpect`` to do the IO\n magic.\n * ``stdout`` and ``stderr`` of the subprocess are combined into one\n stream, which is then emitten on grc's ``stdout``. [1]_\n * The output may not use all of the available terminal width. [1]_\n\n\nConfiguration\n=============\n\n``grc`` searches three locations for configuration files in order:\n\n* ``~/.grc/conf.d/.yml``\n* ``/etc/grc/conf.d/.yml``\n* ``/usr/share/grc/conf.d/.yml``\n\nThe first matching config file wins. This means, you can override any\nsystem-wide configs with your own concoctions.\n\nSyntax\n------\n\n``grc`` uses YAML_ as config syntax. Comparing to ``.ini`` and ``json`` files\n(both included in the Python stdlib), this syntax lends itself much better to\nthe requirements of this application.\n\nBasic structure\n---------------\n\n* The config file is separated into sections (contexts). It has to have at least\n the ``root`` context.\n* Each context has a list of rules. These rules fire if a line contains a\n given regular expresssion. The first matching rule wins.\n* The line will then be replaced with the string contained in the ``replace``\n value. You can use back-refs if you used capture groups in your regular\n expressions. Colours can be insterted using ``${COLOR_NAME}``. You should\n always insert a ``${NORMAL}`` after using a color, to reset to the terminal\n default.\n* Rules may define, that processing should *not* stop using the ``continue:\n yes`` flag. In that case, the same line will be matched with the following\n rule as well.\n* Additionally, rules may \"push\" another context onto the stack. If that's the\n case, the rule will be processed, and all following lines will be matched\n against rules contained in the context named by the ``push`` value.\n* If in a non-root context, a rule may \"pop\" the current context from the\n stack using the ``pop: yes`` action.\n\nSee `Config Reference`_ for more details.\n\nAnnotated Example\n-----------------\n\n::\n\n # the primary context. This section must exist!\n root:\n - match: '^(running)(.*)'\n # demonstrating replacements /and/ colorizing\n replace: '*** ${GREEN}\\1${NORMAL}\\2'\n\n - match: '^(writing)(.*)'\n replace: '>>> ${YELLOW}\\1${NORMAL}\\2'\n\n - match: '^(reading)(.*)'\n replace: '<<< ${BLUE}\\1${NORMAL}\\2'\n\n - match: '^(Processing dependencies for)(.*)'\n replace: '${GREEN}\\1${NORMAL}\\2'\n # switch to the \"dependencies\" context\n push: dependencies\n\n - match: '^(Installing.*)'\n replace: '>>> ${GREEN}\\1${NORMAL}'\n\n # the \"dependencies\" context\n dependencies:\n - match: '^(Finished processing dependencies for)(.*)'\n replace: '${GREEN}\\1${NORMAL}\\2'\n # Revert back to the \"root\" context\n pop: yes\n\n - match: '^(Searching for )(.*)$'\n replace: '\\1${BLUE}\\2${NORMAL}'\n # switch to the \"dependency\" context\n push: dependency\n\n # the \"dependency\" context\n dependency:\n # Let's prepend all lines with a small indent and pipe.\n # To do this, we specify a \"match-all\" regex, replace the line, and\n # specify that we will continue with the next matching rule using\n # \"continue\"\n - match: '(.*)'\n replace: ' | \\1'\n continue: yes\n\n # Note that after the above rule, all lines are prepended with\n # additional text. We need to include this in the regex!\n - match: '^ \\| (Installing.*)'\n replace: ' | >>> ${GREEN}\\1${NORMAL}'\n\n - match: '^ \\| (Running.*)'\n replace: ' | ${GREEN}\\1${NORMAL}'\n\n - match: '^ \\| (Best match.*)'\n replace: ' | ${GREEN}\\1${NORMAL}'\n\n - match: '^ \\| (WARNING|warning)'\n replace: ' | ${YELLOW}\\1${NORMAL}'\n\n - match: '^ \\| Installed(.*)'\n replace: ' | Installed\\1\\n'\n pop: yes\n\nConfig Reference\n================\n\nMain Level\n----------\n\n**root**\n Specifies the primary context\n\nAll other keys represent a context you ``pushed`` somewhere.\n\n\nContexts\n--------\n\nA context is simply a list of rules\n\nRules\n-----\n\n**match**\n *Type*: ``string``\n\n A `python regular expression`_. If this matches somewhere in the input\n line, all occurrences will be replaced with the string specified in\n ``replace``.\n\n .. note:: While YAML does not enforce you to enclose strings in quotes, I\n is strongly recommend you use **single** quotes for regexps to\n avoid trouble with string escapes (backslashes).\n\n**replace**\n *Type*: ``string``\n\n If ``continue`` is false (the default), this string will be emitted to\n ``stdout``. Otherwise, this string will be passed to the next matching\n rule. Not that the following rule sees the *modified* string!\n\n .. note:: While YAML does not enforce you to enclose strings in quotes, I\n is recommend using **single** quotes if using backreferences\n (backslashes).\n\n**continue**\n *Type*: ``boolean``\n\n If true, don't write the string yet to ``stdout``. Instead, pass it on to\n the next matching rule.\n\n**push**\n *Type*: ``string``\n\n Pushes a new context onto the stack. All following lines from ``stdin``\n will be matched agains rules in the new context.\n\n .. note:: This may change in a future release to give you yet more control\n\n**pop**\n *Type*: ``boolean``\n\n If this is set to true, then return to the previous context after this\n rule has been processed. If in the ``root`` context, this is a no-op.\n\n .. note:: This may change in a future release to give you yet more control\n\nScreenshots\n===========\n\n================ ================\nA python setup session\n---------------------------------\nBefore After\n================ ================\n|pysetup-shot-b| |pysetup-shot-a|\n================ ================\n\n================= =================\nSimple aptitude search\n-----------------------------------\nBefore After\n================= =================\n|aptitude-shot-b| |aptitude-shot-a|\n================= =================\n\n====================== ======================\nApache access_log\n---------------------------------------------\nBefore After\n====================== ======================\n|apache_access-shot-b| |apache_access-shot-a|\n====================== ======================\n\nFootnotes\n=========\n\n.. [1] ``grc`` uses ``pyexpect`` to deal with TTY pecularities. This will\n however have two side-effects. First, ``stdout`` will be combined with\n ``stderr``. And second, terminal width may not be well respected.\n\n.. |pysetup-shot-b| image:: /screenshots/pysetup_before.png\n.. |pysetup-shot-a| image:: /screenshots/pysetup_after.png\n.. |aptitude-shot-b| image:: /screenshots/aptitude_before.png\n.. |aptitude-shot-a| image:: /screenshots/aptitude_after.png\n.. |apache_access-shot-b| image:: /screenshots/apache_access_before.png\n.. |apache_access-shot-a| image:: /screenshots/apache_access_after.png\n\n.. _Linux FHS: http://www.pathname.com/fhs/\n.. _source-code access: https://github.com/exhuma/grc\n.. _YAML: http://www.yaml.org\n.. _python regular expression: http://docs.python.org/library/re.html#regular-expression-syntax", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "UNKNOWN", "keywords": null, "license": "GPL", "maintainer": null, "maintainer_email": null, "name": "grc", "package_url": "https://pypi.org/project/grc/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/grc/", "project_urls": { "Download": "UNKNOWN", "Homepage": "UNKNOWN" }, "release_url": "https://pypi.org/project/grc/1.0b4/", "requires_dist": null, "requires_python": null, "summary": "Generic Colorizer", "version": "1.0b4" }, "last_serial": 792682, "releases": { "1.0b1": [ { "comment_text": "", "digests": { "md5": "7c3a31918559fd9cab6e5c990e2d80e6", "sha256": "7b11f9d5896e092534fb2596326c841aff8852a96e785acfbe53d22884d8af97" }, "downloads": -1, "filename": "grc-1.0b1.tar.gz", "has_sig": false, "md5_digest": "7c3a31918559fd9cab6e5c990e2d80e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 32392, "upload_time": "2011-12-11T14:00:26", "url": "https://files.pythonhosted.org/packages/0e/18/857ee8d1310a038468a8de0f76d4ad1a5eeea579344f188161b75ccf05c7/grc-1.0b1.tar.gz" } ], "1.0b2": [ { "comment_text": "", "digests": { "md5": "8c436f63db3ed28165f47a1cb0db4d37", "sha256": "9b455298eacdd21bee977b415a38a915210b3761c4543835449bfe0e0fcf99cd" }, "downloads": -1, "filename": "grc-1.0b2.tar.gz", "has_sig": false, "md5_digest": "8c436f63db3ed28165f47a1cb0db4d37", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 332459, "upload_time": "2011-12-11T21:21:20", "url": "https://files.pythonhosted.org/packages/11/47/474f887a2e47459b927f2e1905846e57fbf4b78be8308eb85ea778654cea/grc-1.0b2.tar.gz" } ], "1.0b3": [ { "comment_text": "", "digests": { "md5": "6fd7065b45aa8b5fe67fa09a633156bd", "sha256": "d570ec309d85cba01ff81d0b1a6f3a94905c10ffa79e0eb2342621c44f9c1dca" }, "downloads": -1, "filename": "grc-1.0b3.tar.gz", "has_sig": false, "md5_digest": "6fd7065b45aa8b5fe67fa09a633156bd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 332350, "upload_time": "2011-12-11T21:57:45", "url": "https://files.pythonhosted.org/packages/a9/14/86e4158a3ea7afb6fcadedb84e488ca10dd5990c559c429e8f6bbe5a0fab/grc-1.0b3.tar.gz" } ], "1.0b4": [ { "comment_text": "", "digests": { "md5": "bce2db6b22c45807a38d6bb6506b7553", "sha256": "f7283cb28b0d2e953e3d122d9c993253959d25cdeb7f93d1ec8eb653d06c8077" }, "downloads": -1, "filename": "grc-1.0b4.tar.gz", "has_sig": false, "md5_digest": "bce2db6b22c45807a38d6bb6506b7553", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 330245, "upload_time": "2011-12-12T15:25:59", "url": "https://files.pythonhosted.org/packages/f1/79/7b1f93c589f9965eb0b0b05db6df8adfac1ab837b291eed8c3a26c193176/grc-1.0b4.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "bce2db6b22c45807a38d6bb6506b7553", "sha256": "f7283cb28b0d2e953e3d122d9c993253959d25cdeb7f93d1ec8eb653d06c8077" }, "downloads": -1, "filename": "grc-1.0b4.tar.gz", "has_sig": false, "md5_digest": "bce2db6b22c45807a38d6bb6506b7553", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 330245, "upload_time": "2011-12-12T15:25:59", "url": "https://files.pythonhosted.org/packages/f1/79/7b1f93c589f9965eb0b0b05db6df8adfac1ab837b291eed8c3a26c193176/grc-1.0b4.tar.gz" } ] }