Showing preview only (1,502K chars total). Download the full file or copy to clipboard to get everything.
Repository: nicoulaj/rainbow
Branch: master
Commit: 379c9b0333df
Files: 150
Total size: 1.4 MB
Directory structure:
gitextract_f35q6phd/
├── .codeclimate.yml
├── .coveragerc
├── .editorconfig
├── .github/
│ ├── dependabot.yml
│ └── workflows/
│ ├── benchmarks.yml
│ ├── lint.yml
│ ├── packages.yml
│ └── tests.yml
├── .gitignore
├── CONTRIBUTING.md
├── COPYING
├── MANIFEST.in
├── README.rst
├── rainbow/
│ ├── __init__.py
│ ├── __main__.py
│ ├── ansi.py
│ ├── build.py
│ ├── cli.py
│ ├── command/
│ │ ├── __init__.py
│ │ ├── execute.py
│ │ ├── noop.py
│ │ ├── print_config_names.py
│ │ ├── print_path.py
│ │ └── stdin.py
│ ├── config/
│ │ ├── __init__.py
│ │ ├── builtin/
│ │ │ ├── df.cfg
│ │ │ ├── diff.cfg
│ │ │ ├── env.cfg
│ │ │ ├── host.cfg
│ │ │ ├── ifconfig.cfg
│ │ │ ├── java-stack-trace.cfg
│ │ │ ├── jboss.cfg
│ │ │ ├── md5sum.cfg
│ │ │ ├── mvn.cfg
│ │ │ ├── ping.cfg
│ │ │ ├── tcpdump.cfg
│ │ │ ├── tomcat.cfg
│ │ │ └── traceroute.cfg
│ │ ├── loader.py
│ │ ├── locator.py
│ │ └── parser.py
│ ├── filter.py
│ └── transformer.py
├── scripts/
│ └── rainbow
├── setup.cfg
├── setup.py
├── templates/
│ ├── completion.bash
│ ├── completion.zsh
│ └── rainbow.man
├── tests/
│ ├── __init__.py
│ ├── command/
│ │ ├── __init__.py
│ │ ├── test_execute.py
│ │ ├── test_noop.py
│ │ ├── test_print_config_names.py
│ │ ├── test_print_path.py
│ │ └── test_stdin.py
│ ├── config/
│ │ ├── __init__.py
│ │ ├── test_builtin.py
│ │ ├── test_loader.py
│ │ ├── test_locator.py
│ │ └── test_parser.py
│ ├── data/
│ │ ├── UTF-8-test.txt
│ │ ├── cfg/
│ │ │ ├── config001.cfg
│ │ │ ├── config002.cfg
│ │ │ ├── config003.cfg
│ │ │ ├── config004.cfg
│ │ │ ├── config005.cfg
│ │ │ ├── config006.cfg
│ │ │ ├── config007.cfg
│ │ │ ├── config008.cfg
│ │ │ ├── config009.cfg
│ │ │ ├── config010.cfg
│ │ │ ├── config011.cfg
│ │ │ ├── config012.cfg
│ │ │ ├── config013.cfg
│ │ │ ├── config014.cfg
│ │ │ ├── config015.cfg
│ │ │ ├── config016.cfg
│ │ │ ├── config017.cfg
│ │ │ ├── config018.cfg
│ │ │ ├── config019.cfg
│ │ │ ├── config020.cfg
│ │ │ ├── config021.cfg
│ │ │ ├── config022.cfg
│ │ │ ├── config023.cfg
│ │ │ ├── config024.cfg
│ │ │ ├── config025.cfg
│ │ │ ├── config026.cfg
│ │ │ ├── config027.cfg
│ │ │ ├── config028.cfg
│ │ │ ├── config029.cfg
│ │ │ ├── config030.cfg
│ │ │ └── config031.cfg
│ │ └── ref/
│ │ ├── df-001.log
│ │ ├── df-001.log.out
│ │ ├── df-002.log
│ │ ├── df-002.log.out
│ │ ├── diff-001.log
│ │ ├── diff-001.log.out
│ │ ├── diff-002.log
│ │ ├── diff-002.log.out
│ │ ├── diff-003.log
│ │ ├── diff-003.log.out
│ │ ├── env-001.log
│ │ ├── env-001.log.out
│ │ ├── host-001.log
│ │ ├── host-001.log.out
│ │ ├── host-002.log
│ │ ├── host-002.log.out
│ │ ├── ifconfig-001.log
│ │ ├── ifconfig-001.log.out
│ │ ├── ifconfig-002.log
│ │ ├── ifconfig-002.log.out
│ │ ├── java-stack-trace-001.log
│ │ ├── java-stack-trace-001.log.out
│ │ ├── jboss-001.log
│ │ ├── jboss-001.log.out
│ │ ├── md5sum-001.log
│ │ ├── md5sum-001.log.out
│ │ ├── md5sum-002.log
│ │ ├── md5sum-002.log.out
│ │ ├── mvn-001.log
│ │ ├── mvn-001.log.out
│ │ ├── mvn-002.log
│ │ ├── mvn-002.log.out
│ │ ├── mvn-003.log
│ │ ├── mvn-003.log.out
│ │ ├── mvn-004.log
│ │ ├── mvn-004.log.out
│ │ ├── ping-001.log
│ │ ├── ping-001.log.out
│ │ ├── ping-002.log
│ │ ├── ping-002.log.out
│ │ ├── tcpdump-001.log
│ │ ├── tcpdump-001.log.out
│ │ ├── tomcat-001.log
│ │ ├── tomcat-001.log.out
│ │ ├── traceroute-001.log
│ │ ├── traceroute-001.log.out
│ │ ├── traceroute-002.log
│ │ └── traceroute-002.log.out
│ ├── test_build.py
│ ├── test_cli.py
│ ├── test_filters.py
│ ├── test_main.py
│ ├── test_performance.py
│ ├── test_rainbow.py
│ ├── test_transformer.py
│ └── test_utils.py
└── tox.ini
================================================
FILE CONTENTS
================================================
================================================
FILE: .codeclimate.yml
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
---
engines:
duplication:
enabled: true
config:
languages:
- python
fixme:
enabled: true
radon:
enabled: true
config:
python_version: 2
ratings:
paths:
- "**.py"
exclude_paths:
- tests/
================================================
FILE: .coveragerc
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
[report]
exclude_lines =
no cover
if __name__ == .__main__.:
def __repr__
================================================
FILE: .editorconfig
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
root = true
[*]
charset = UTF-8
end_of_line = lf
max_line_length=120
insert_final_newline = true
trim_trailing_whitespace = true
[*.py]
indent_style = space
indent_size = 4
[tox.ini]
indent_size = 1
================================================
FILE: .github/dependabot.yml
================================================
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
- package-ecosystem: pip
directory: "/"
schedule:
interval: weekly
================================================
FILE: .github/workflows/benchmarks.yml
================================================
name: Benchmarks
on: [push, pull_request]
jobs:
benchmark:
name: 'benchmarks'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run benchmarks
run: tox -e benchmarks
================================================
FILE: .github/workflows/lint.yml
================================================
name: Lint
on: [push, pull_request]
jobs:
lint:
name: 'lint'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run checks
run: tox -e lint
================================================
FILE: .github/workflows/packages.yml
================================================
name: Packages
on:
push:
pull_request:
release:
types: [released]
jobs:
python-packages:
name: 'wheel'
runs-on: 'ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install wheel
- name: Build source distribution and wheel package
run: python setup.py sdist bdist_wheel
- name: Publish on PyPI repository
if: github.event_name == 'release' && github.event.action == 'released'
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
================================================
FILE: .github/workflows/tests.yml
================================================
name: Tests
on: [push, pull_request]
jobs:
test:
strategy:
fail-fast: false
matrix:
os: [ 'ubuntu-latest', 'macos-latest' ]
python: [ '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.6', 'pypy-3.7', 'pypy-3.8' ]
runs-on: ${{ matrix.os }}
name: ${{ matrix.os }} - python ${{ matrix.python }}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python }}
- name: Set up pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ matrix.os }}-pip
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install tox tox-gh-actions
- name: Run tests
run: tox
- name: Publish code coverage to CodeClimate
uses: paambaati/codeclimate-action@v3.0.0
if: matrix.os == 'ubuntu-latest' && matrix.python == '3.10'
continue-on-error: true
with:
coverageLocations: ${{github.workspace}}/build/tests/*/reports/coverage.xml:coverage.py
env:
CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }}
================================================
FILE: .gitignore
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
*.pyc
*.pyo
*.pyd
*$py.class
__pycache__/
build/
dist/
MANIFEST
*.egg-info/
*.egg/
.tox/
.cache/
.idea/
*.ipr
*.iws
.coverage
.benchmarks
.coverage.*
out/
.pytest_cache/
*.rpm
*.deb
*.tar.*
================================================
FILE: CONTRIBUTING.md
================================================
Contributing
============
Contributions are welcome, please take a look at the [issues list](https://github.com/nicoulaj/rainbow/issues).
Development environment
-----------------------
This project uses a standard layout. Here are some example steps to setup
your development environment using [pew](https://github.com/berdario/pew):
1. Checkout project sources:
git clone https://github.com/nicoulaj/rainbow.git
cd rainbow
2. To run tests, rainbow uses [tox](https://tox.readthedocs.io):
tox
This will run all the tests, for all python versions. To run tests for
one specific version:
tox -e py27
After you run tests, results (test, coverage and benchmark HTML reports) will be available in the `build/tests` directory.
Commands wishlist
-----------------
This table contains an inventory of commands we could potentially support in rainbow, with their current status.
If you want to request and/or plan to working on one, please send a pull request to update this table.
| command / format | rainbow support | third party support | status |
| -------------------- | -------------------- | ---------------------------------------- | ------------------------------------ |
| acpi | :x: | cope | |
| ant | :x: | builtin color support, colorlogs | :ok: |
| apm | :x: | ccze | |
| arp | :x: | cope, cwrapper | |
| arping | :x: | cwrapper | |
| auth.log | :x: | cwrapper | |
| blockdev | :x: | cwrapper | |
| cal | :x: | cwrapper | |
| cc | :x: | cope | rainbow config needed |
| cksum | :x: | cwrapper | rainbow config needed |
| clock | :x: | cwrapper | |
| configure | :x: | cwrapper, grc | rainbow config needed |
| cpuinfo | :x: | cwrapper | rainbow config needed |
| crontab | :x: | cwrapper | |
| cvs | :x: | colorcvs, grc | |
| date | :x: | cwrapper | |
| df | :heavy_check_mark: | dfc, cope, cwrapper, grc | :ok: |
| diff | :heavy_check_mark: | colordiff, grc, cwrapper | :ok: |
| dig | :x: | cwrapper | rainbow config needed |
| distcc | :x: | ccze | |
| dmesg | :x: | cwrapper | |
| dpkg | :x: | ccze | |
| dprofpp | :x: | cope | |
| du | :x: | cwrapper | |
| env | :heavy_check_mark: | cwrapper | :ok: |
| esperanto | :x: | grc | |
| example | :x: | colorlogs | |
| exim | :x: | ccze | |
| fdisk | :x: | cope | |
| fetchmail | :x: | ccze | |
| figlet | :x: | cwrapper | |
| file | :x: | cwrapper | |
| find | :x: | cwrapper | rainbow config needed |
| finger | :x: | cwrapper | |
| free | :x: | cwrapper, cope | rainbow config needed |
| fstab | :x: | cwrapper | |
| ftpstats | :x: | ccze | |
| fuser | :x: | cwrapper | |
| gcc | :x: | colorgcc, cope, cwrapper, grc | |
| g++ | :x: | cwrapper, cope | |
| git | :x: | partial builtin color support, colorlogs | |
| group | :x: | cwrapper | |
| groups | :x: | cwrapper | |
| hdparm | :x: | cwrapper | |
| hexdump | :x: | cwrapper | |
| host | :heavy_check_mark: | cwrapper | :ok: |
| hosts | :x: | cwrapper | |
| httpd | :x: | ccze | |
| icecast | :x: | ccze | |
| id | :x: | cope, cwrapper | rainbow config needed |
| ifconfig | :heavy_check_mark: | cwrapper, cope | :ok: |
| inittab | :x: | cwrapper | |
| iptables | :x: | cwrapper | |
| irclog | :x: | grc | |
| java stack traces | :heavy_check_mark: | | :ok: |
| last | :x: | cwrapper | |
| lastlog | :x: | cwrapper | |
| ldap | :x: | grc | |
| log | :x: | grc | |
| lsattr | :x: | cwrapper | |
| ls | :x: | dircolors, cope | |
| lsmod | :x: | cwrapper | |
| lsof | :x: | cwrapper | rainbow config needed |
| lspci | :x: | cope | |
| lsusb | :x: | cope | |
| ltrace-color | :x: | cwrapper | |
| make | :x: | colormake, cwrapper, cope | rainbow config needed |
| md5sum | :heavy_check_mark: | cwrapper, cope | :ok: |
| meminfo | :x: | cwrapper | |
| messages | :x: | cwrapper | |
| mount | :x: | grc, cwrapper | rainbow config needed |
| mpc | :x: | cope | |
| mpg123 | :x: | cwrapper | |
| mvn | :heavy_check_mark: | colorslogs | :ok: |
| netstat | :x: | grc, cope, cwrapper | rainbow config needed |
| nfsstat | :x: | cwrapper | rainbow config needed |
| nmap | :x: | cwrapper, cope | |
| nm | :x: | cope | |
| nocope | :x: | cope | |
| nslookup | :x: | cwrapper | |
| objdump | :x: | cwrapper | |
| oops | :x: | ccze | |
| passwd | :x: | cwrapper | |
| php | :x: | ccze | |
| ping | :heavy_check_mark: | grc, cwrapper, cope | :ok: |
| pmap | :x: | cwrapper, cope | |
| pmap_dump | :x: | cwrapper | |
| postfix | :x: | ccze | |
| praliases | :x: | cwrapper | |
| procmail | :x: | ccze | |
| proftpd | :x: | grc, ccze | |
| ps | :x: | cwrapper, cope | rainbow config needed |
| pstree | :x: | cwrapper | rainbow config needed |
| quota | :x: | cwrapper | |
| quotastats | :x: | cwrapper | |
| readelf | :x: | cope | |
| resolv | :x: | cwrapper | |
| route | :x: | cwrapper, cope | |
| routel | :x: | cwrapper | |
| screen | :x: | cope | |
| sdiff | :x: | cwrapper | |
| services | :x: | cwrapper | |
| sha1sum | :x: | cope | rainbow config needed |
| sha224sum | :x: | cope | rainbow config needed |
| sha256sum | :x: | cope | rainbow config needed |
| sha384sum | :x: | cope | rainbow config needed |
| sha512sum | :x: | cope | rainbow config needed |
| shasum | :x: | cope | rainbow config needed |
| showmount | :x: | cwrapper | |
| smbstatus | :x: | cwrapper | |
| socklist | :x: | cope | |
| squid | :x: | ccze | |
| stat | :x: | cwrapper, cope | |
| strace | :x: | cope | rainbow config needed |
| sulog | :x: | ccze | |
| super | :x: | ccze | |
| svn | :x: | colorsvn | |
| sysctl | :x: | cwrapper | |
| syslog | :x: | cwrapper, ccze | |
| tar | :x: | cwrapper | |
| tcpdump | :x: | cwrapper, cope | |
| tomcat | :heavy_check_mark: | | :ok: |
| tracepath | :x: | cwrapper, cope | |
| traceroute | :heavy_check_mark: | cope, grc, cwrapper | :ok: |
| ulogd | :x: | ccze | |
| umount | :x: | cwrapper | |
| uname | :x: | cwrapper | |
| uptime | :x: | cwrapper | |
| users | :x: | cwrapper | |
| vmstat | :x: | cwrapper | |
| vsftpd | :x: | ccze | |
| wc | :x: | cwrapper | |
| w | :x: | cwrapper, cope | |
| wdiff | :x: | grc | |
| wget | :x: | cope | |
| whereis | :x: | cwrapper | |
| who | :x: | cwrapper, cope | |
| xferlog | :x: | cwrapper, ccze | |
| xrandr | :x: | cope | |
================================================
FILE: COPYING
================================================
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
================================================
FILE: MANIFEST.in
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
include README.rst
include COPYING
include templates/*
include scripts/*
include rainbow/config/builtin/*
================================================
FILE: README.rst
================================================
rainbow
=======
.. image:: https://img.shields.io/github/tag/nicoulaj/rainbow.svg
:target: https://pypi.org/project/rainbow
:alt: last release
.. image:: https://pepy.tech/badge/rainbow
:target: https://pypi.org/project/rainbow
:alt: downloads
.. image:: https://img.shields.io/pypi/pyversions/rainbow.svg
:target: https://pypi.org/project/rainbow
:alt: python versions
.. image:: https://github.com/nicoulaj/rainbow/actions/workflows/tests.yml/badge.svg
:target: https://github.com/nicoulaj/rainbow/actions
:alt: continuous integration
.. image:: https://api.codeclimate.com/v1/badges/724f29330eb898c7516b/test_coverage
:target: https://codeclimate.com/github/nicoulaj/rainbow/test_coverage
:alt: test Coverage
.. image:: https://badges.gitter.im/nicoulaj/rainbow.svg
:target: https://gitter.im/nicoulaj/rainbow
:alt: gitter chat
----
**Easily colorize commands output using patterns.**
::
rainbow [ --COLOR=PATTERN ... | --conf CONF ] COMMAND
Examples
--------
Using the command line
~~~~~~~~~~~~~~~~~~~~~~
Prepend ``rainbow`` with ``--COLOR=PATTERN`` associations to your
command, for example:
- Tail some log file with lines containing ``ERROR`` in red:
::
rainbow --red=ERROR tail -f /var/log/my.log
- You can also pipe commands output into rainbow:
::
tail -f /var/log/my.log | rainbow --red=ERROR
Using configs
~~~~~~~~~~~~~
Rainbow can load configuration for each command from files, which is the most convenient way to use it. When running ``rainbow mycommand``, rainbow will automatically look for a config named ``mycommand.cfg`` in ``~/.config/rainbow``, ``~/.rainbow``, ``/etc/rainbow``, or builtin configs:
- Colorize the ``diff`` command output using the builtin config:
::
rainbow diff file1 file2
- Start my custom command, using ``~/.rainbow/mycommand.cfg``:
::
rainbow mycommand
The syntax for writing configs is straightforward, see the
`builtin configs <https://github.com/nicoulaj/rainbow/blob/master/rainbow/config/builtin>`_
for examples. See also the `commands support table <https://github.com/nicoulaj/rainbow/blob/master/CONTRIBUTING.md>`_.
Installation
------------
Using packages
~~~~~~~~~~~~~~
============================================ ============================================
System Installation instructions
============================================ ============================================
Debian / RPM based `rainbow repository <https://software.opensuse.org/download.html?project=home%3Anicoulaj%3Arainbow&package=rainbow>`_ (`sources here <https://build.opensuse.org/package/show/home:nicoulaj:rainbow/rainbow>`_)
Arch Linux `AUR/rainbow <https://aur.archlinux.org/packages/rainbow>`_ / `AUR/rainbow-git <https://aur.archlinux.org/packages/rainbow-git>`_
pip `PyPI: rainbow <https://pypi.org/project/rainbow>`_
============================================ ============================================
Building from sources
~~~~~~~~~~~~~~~~~~~~~
You can build from sources this way:
::
git clone git://github.com/nicoulaj/rainbow.git
cd rainbow
python setup.py build install --user
Contributing
------------
Contributions are welcome, please see `CONTRIBUTING <https://github.com/nicoulaj/rainbow/blob/master/CONTRIBUTING.md>`_.
License
-------
This project is a fork of `Linibou's colorex <http://bitbucket.org/linibou/colorex>`_.
It is is released under the terms of the `GNU General Public
License <http://www.gnu.org/licenses/gpl.html>`_. See ``COPYING`` for
details.
================================================
FILE: rainbow/__init__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import sys
import logging
import os
__prog__ = __name__
__author__ = 'Julien Nicoulaud'
__email__ = 'julien.nicoulaud@gmail.com'
__url__ = 'https://github.com/nicoulaj/rainbow'
__copyright__ = 'copyright 2010-2018 rainbow contributors'
__license__ = 'GPLv3'
__description__ = 'Colorize commands output using patterns.'
__version__ = '3.0.0-dev'
LOGGER = logging.getLogger(__prog__)
DEFAULT_PATH = [
os.environ.get('RAINBOW_CONFIGS'),
os.path.join(os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser('~/.config'), __prog__),
os.path.join(os.path.expanduser('~'), '.' + __prog__),
os.path.join(os.sep, 'etc', __prog__),
os.path.join(os.sep, os.path.dirname(__file__), 'config', 'builtin')
]
ENABLE_STDOUT = bool(os.environ.get('RAINBOW_ENABLE_STDOUT', sys.stdout.isatty()))
ENABLE_STDERR = bool(os.environ.get('RAINBOW_ENABLE_STDERR', sys.stderr.isatty()))
================================================
FILE: rainbow/__main__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import sys
import logging
from logging import Formatter
import rainbow
from . import LOGGER, DEFAULT_PATH
from .cli import CommandLineParser
from .transformer import DummyTransformerBuilder
def main(args=None):
logger_console_handler = logging.StreamHandler(sys.stderr)
try:
logger_console_handler.setFormatter(Formatter("%(levelname)s %(message)s"))
logging.addLevelName(logging.CRITICAL, 'rainbow error:')
logging.addLevelName(logging.FATAL, 'rainbow error:')
logging.addLevelName(logging.ERROR, 'rainbow error:')
logging.addLevelName(logging.WARNING, 'rainbow warning:')
logging.addLevelName(logging.INFO, 'rainbow:')
logging.addLevelName(logging.DEBUG, 'rainbow:')
logging.addLevelName(logging.NOTSET, 'rainbow:')
LOGGER.addHandler(logger_console_handler)
LOGGER.setLevel(logging.WARNING)
errors = []
parser = CommandLineParser(
paths=DEFAULT_PATH,
stdout_builder=None if rainbow.ENABLE_STDOUT else DummyTransformerBuilder(),
stderr_builder=None if rainbow.ENABLE_STDERR else DummyTransformerBuilder(),
error_handler=errors.append
)
command = parser.parse_args(args)
if command:
for message in errors:
LOGGER.warning(message)
return command.run()
else:
for message in errors:
LOGGER.error(message)
LOGGER.setLevel(logging.INFO)
LOGGER.info(parser.get_usage())
return 1
except Exception as e:
LOGGER.exception(e)
return 1
finally:
LOGGER.removeHandler(logger_console_handler)
LOGGER.setLevel(logging.INFO)
================================================
FILE: rainbow/ansi.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
ANSI_FOREGROUND_RED = chr(27) + '[31m'
ANSI_FOREGROUND_LIGHT_RED = chr(27) + '[91m'
ANSI_FOREGROUND_GREEN = chr(27) + '[32m'
ANSI_FOREGROUND_LIGHT_GREEN = chr(27) + '[92m'
ANSI_FOREGROUND_YELLOW = chr(27) + '[33m'
ANSI_FOREGROUND_LIGHT_YELLOW = chr(27) + '[93m'
ANSI_FOREGROUND_BLUE = chr(27) + '[34m'
ANSI_FOREGROUND_LIGHT_BLUE = chr(27) + '[94m'
ANSI_FOREGROUND_MAGENTA = chr(27) + '[35m'
ANSI_FOREGROUND_CYAN = chr(27) + '[36m'
ANSI_FOREGROUND_LIGHT_CYAN = chr(27) + '[96m'
ANSI_FOREGROUND_RESET = chr(27) + '[39m'
ANSI_BACKGROUND_RED = chr(27) + '[41m'
ANSI_BACKGROUND_LIGHT_RED = chr(27) + '[101m'
ANSI_BACKGROUND_GREEN = chr(27) + '[42m'
ANSI_BACKGROUND_LIGHT_GREEN = chr(27) + '[102m'
ANSI_BACKGROUND_YELLOW = chr(27) + '[43m'
ANSI_BACKGROUND_LIGHT_YELLOW = chr(27) + '[103m'
ANSI_BACKGROUND_BLUE = chr(27) + '[44m'
ANSI_BACKGROUND_LIGHT_BLUE = chr(27) + '[104m'
ANSI_BACKGROUND_MAGENTA = chr(27) + '[45m'
ANSI_BACKGROUND_CYAN = chr(27) + '[46m'
ANSI_BACKGROUND_LIGHT_CYAN = chr(27) + '[106m'
ANSI_BACKGROUND_RESET = chr(27) + '[49m'
ANSI_BOLD = chr(27) + '[1m'
ANSI_FAINT = chr(27) + '[2m'
ANSI_ITALIC = chr(27) + '[3m'
ANSI_UNDERLINE = chr(27) + '[4m'
ANSI_UNDERLINE_DOUBLE = chr(27) + '[21m'
ANSI_BLINK = chr(27) + '[5m'
ANSI_BLINK_RAPID = chr(27) + '[6m'
ANSI_NEGATIVE = chr(27) + '[7m'
ANSI_HIDE = chr(27) + '[8m'
ANSI_RESET_INTENSITY = chr(27) + '[22m'
ANSI_RESET_ITALIC = chr(27) + '[23m'
ANSI_RESET_UNDERLINE = chr(27) + '[24m'
ANSI_RESET_BLINK = chr(27) + '[25m'
ANSI_RESET_NEGATIVE = chr(27) + '[27m'
ANSI_RESET_HIDE = chr(27) + '[28m'
ANSI_RESET_ALL = chr(27) + '[0m'
================================================
FILE: rainbow/build.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import errno
import gzip
import logging
import os
import shutil
from distutils.command.build import build
from distutils.command.clean import clean
from distutils.core import Command
from distutils.dir_util import remove_tree
from distutils.errors import DistutilsOptionError
from .filter import FILTERS, FILTER_GROUPS
class Build(build): # no cover
def run(self):
self.run_command("build_completion_bash")
self.run_command("build_completion_zsh")
self.run_command("build_man_page")
build.run(self)
class Clean(clean): # no cover
def __init__(self, dist):
clean.__init__(self, dist)
self.user_options += [
('paths=', 'p', 'paths'),
]
def initialize_options(self):
super(clean, self).initialize_options()
self.paths = None
def finalize_options(self):
clean.finalize_options(self)
if self.paths is None: # no cover
raise DistutilsOptionError('"paths" option is required')
def run(self):
clean.run(self)
if self.all:
for path in [path.strip() for path in self.paths.split(',')]:
if os.path.isdir(path):
remove_tree(path)
elif os.path.isfile(path):
self.announce("removing '%s'" % path)
os.remove(path)
else:
self.announce("'%s' does not exist -- can't clean it" % path)
class GenerateCompletion(Command):
description = 'Generate shell completion script.'
user_options = [
('shell=', 'S', 'shell (bash or zsh)'),
('output=', 'O', 'output file')
]
def initialize_options(self):
self.shell = None
self.output = None
def finalize_options(self):
if self.shell is None: # no cover
raise DistutilsOptionError('"shell" option is required')
if self.output is None: # no cover
raise DistutilsOptionError('"output" option is required')
def run(self):
self.announce('generating %s completion -> %s' % (self.shell, self.output))
makeparentdirs(self.output)
try:
from jinja2 import Environment, FileSystemLoader
Environment(loader=FileSystemLoader('templates')) \
.get_template('completion.%s' % self.shell) \
.stream(filters=FILTERS) \
.dump(self.output)
except ImportError:
logging.warning('Jinja is not installed, skipping %s completion generation' % self.shell)
class GenerateManPage(Command):
description = 'Generate man page.'
user_options = [
('output=', 'O', 'output file')
]
def initialize_options(self):
self.output = None
def finalize_options(self):
if self.output is None: # no cover
raise DistutilsOptionError('"output" option is required')
def run(self):
self.announce('generating man page -> %s' % self.output)
makeparentdirs(self.output)
try:
from jinja2 import Environment, FileSystemLoader
Environment(loader=FileSystemLoader('templates')) \
.get_template('rainbow.man') \
.stream(filter_groups=FILTER_GROUPS) \
.dump(self.output)
file_in = None
file_out = None
try:
file_in = open(self.output, 'rb')
file_out = gzip.open(self.output + '.gz', 'wb')
shutil.copyfileobj(file_in, file_out)
finally:
if file_in:
file_in.close()
if file_out:
file_out.close()
except ImportError:
logging.warning('Jinja is not installed, skipping man page generation')
def makeparentdirs(path):
directory = os.path.dirname(path)
if not os.path.exists(directory): # no cover
try:
os.makedirs(directory)
except OSError as e:
if e.errno != errno.EEXIST:
raise
================================================
FILE: rainbow/cli.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import sys
from optparse import OptionParser, OptionGroup, BadOptionError, AmbiguousOptionError
from . import __version__, __description__, LOGGER, DEFAULT_PATH
from .command.execute import ExecuteCommand
from .command.noop import NoOpCommand
from .command.print_config_names import PrintConfigNamesCommand
from .command.print_path import PrintPathCommand
from .command.stdin import STDINCommand
from .config.loader import ConfigLoader
from .filter import FILTER_GROUPS, FILTERS_BY_LONG_OPTION
from .transformer import TransformerBuilder, IdentityTransformer
class CommandLineParser(OptionParser):
def __init__(self,
paths=None,
stdout_builder=None,
stderr_builder=None,
error_handler=lambda error: None):
OptionParser.__init__(self,
usage='%prog [options] -- command [args...] ',
version='%prog ' + __version__,
description=__description__)
self.disable_interspersed_args()
self.formatter.max_help_position = 50
self.formatter.width = 150
self.command = None
self.stdout_builder = stdout_builder or TransformerBuilder()
self.stderr_builder = stderr_builder or TransformerBuilder()
self.error_handler = error_handler
self.config_loader = ConfigLoader(self.stdout_builder, self.stderr_builder, paths, error_handler)
self.add_option('-f',
'--config',
action='callback',
callback=self.handle_config_option,
type='string',
help='Load a config file defining patterns. '
'This option can be called several times.')
self.add_option('-v',
'--verbose',
action='callback',
callback=self.handle_verbosity_option,
help='Turn on verbose mode. '
'This option can be called several times to increase the verbosity level.')
self.add_option('--print-path',
action='callback',
callback=self.handle_print_path_option,
help='Print config paths.')
self.add_option('--print-config-names',
action='callback',
callback=self.handle_print_config_names_option,
help='Print config names.')
self.add_option('--disable-stderr-filtering',
action='store_false',
dest='enable_stderr_filtering',
default=True,
help='Disable STDERR filtering, which can have unexpected effects on command directly '
'using tty.')
for group in FILTER_GROUPS:
option_group = OptionGroup(self, group.name, group.help)
for f in group.filters:
if f.short_option:
option_group.add_option('-' + f.short_option,
'--' + f.long_option,
action='callback',
callback=self.handle_pattern_option,
type='string',
help=f.help)
else:
option_group.add_option('--' + f.long_option,
action='callback',
callback=self.handle_pattern_option,
type='string',
help=f.help)
self.add_option_group(option_group)
def parse_args(self, args=None, values=None):
try:
(values, remaining_args) = OptionParser.parse_args(self, args=args)
except SystemExit:
return self.command
if remaining_args:
if not self.stdout_builder.transformers:
self.config_loader.load_config_from_command_line(remaining_args)
stdout_transformer = self.stdout_builder.build()
stderr_transformer = self.stderr_builder.build() if values.enable_stderr_filtering else IdentityTransformer
return ExecuteCommand(remaining_args, stdout_transformer, stderr_transformer)
return STDINCommand(self.stdout_builder.build())
def _process_args(self, largs, rargs, values):
while rargs:
remaining = len(rargs)
try:
OptionParser._process_args(self, largs, rargs, values)
if remaining == len(rargs):
break
except (BadOptionError, AmbiguousOptionError) as e:
largs.append(e.opt_str)
def exit(self, status=0, msg=None):
if msg:
self.error_handler(msg)
sys.exit(status)
def error(self, msg):
self.exit(1, msg)
def handle_config_option(self, option, opt, value, parser):
self.config_loader.load_config_by_name(value)
def handle_pattern_option(self, option, opt, value, parser):
filter_name = option.get_opt_string()[2:]
filter = FILTERS_BY_LONG_OPTION[filter_name]
self.stdout_builder.add_mapping(value, filter)
self.stderr_builder.add_mapping(value, filter)
@staticmethod
def handle_verbosity_option(option, opt, value, parser):
LOGGER.setLevel(LOGGER.level - 10)
def handle_print_path_option(self, option, opt, value, parser):
self.command = PrintPathCommand(DEFAULT_PATH)
parser.exit(0)
def handle_print_config_names_option(self, option, opt, value, parser):
self.command = PrintConfigNamesCommand(DEFAULT_PATH)
parser.exit(0)
def print_help(self, file=None):
self.command = NoOpCommand()
return OptionParser.print_help(self, file)
def print_version(self, file=None):
self.command = NoOpCommand()
return OptionParser.print_version(self, file)
================================================
FILE: rainbow/command/__init__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
================================================
FILE: rainbow/command/execute.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import errno
import os
import pty
import re
import signal
import subprocess
import sys
from select import select
from rainbow.ansi import ANSI_RESET_ALL
from rainbow.transformer import IdentityTransformer
NEW_LINE = re.compile("\n|\r\n")
class ExecuteCommand(object):
def __init__(self,
args,
stdout_transformer=IdentityTransformer(),
stderr_transformer=IdentityTransformer(),
encoding=sys.getdefaultencoding()):
self.args = args
self.stdout_transformer = stdout_transformer
self.stderr_transformer = stderr_transformer
self.encoding = encoding
def encode(self, string):
return string.encode(self.encoding, 'replace')
def decode(self, bytes):
return bytes.decode(self.encoding, 'replace')
def run(self):
stdin_fd = sys.stdin.fileno()
stdout_fd = sys.stdout.fileno()
stderr_fd = sys.stderr.fileno()
in_master, in_slave = pty.openpty() if sys.stdin.isatty() else os.pipe()
out_master, out_slave = pty.openpty() if sys.stdout.isatty() else os.pipe()
err_master, err_slave = pty.openpty() if sys.stderr.isatty() else os.pipe()
p = subprocess.Popen(args=self.args, stdin=in_master, stdout=out_slave, stderr=err_slave)
readables = [stdin_fd, out_master, err_master]
writables = {stdin_fd: in_slave, out_master: stdout_fd, err_master: stderr_fd}
buffers = {out_master: '', err_master: ''}
transformers = {out_master: self.stdout_transformer, err_master: self.stderr_transformer}
try:
os.close(out_slave)
os.close(err_slave)
while True:
for read_fd in select(readables, [], [])[0]:
try:
data = os.read(read_fd, 4096)
except OSError as e:
if e.errno != errno.EIO:
raise # no cover
data = None
write_fd = writables[read_fd]
if data:
data_str = self.decode(data)
if read_fd == stdin_fd:
os.write(write_fd, self.encode(data_str))
for read_fd in buffers:
buffers[read_fd] = ''
else:
lines = NEW_LINE.split(buffers[read_fd] + data_str)
transformer = transformers[read_fd]
if lines[0] and buffers[read_fd]:
os.write(write_fd, self.encode('\r'))
for line in lines[:-1]:
os.write(write_fd, self.encode(transformer.transform(line) + '\n'))
if lines[-1]:
os.write(write_fd, self.encode(transformer.transform(lines[-1])))
buffers[read_fd] = lines[-1]
else:
buffers[read_fd] = ''
else:
if read_fd == stdin_fd:
os.close(write_fd)
else:
os.write(write_fd, self.encode(ANSI_RESET_ALL))
os.close(read_fd)
readables.remove(read_fd)
if out_master not in readables and err_master not in readables:
return p.wait()
except KeyboardInterrupt:
os.kill(p.pid, signal.SIGINT)
return p.wait()
================================================
FILE: rainbow/command/noop.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
class NoOpCommand(object):
def __init__(self, exit_code=0):
self.exit_code = exit_code
def run(self):
return self.exit_code
================================================
FILE: rainbow/command/print_config_names.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
class PrintConfigNamesCommand(object):
def __init__(self, paths=None):
self.paths = paths or []
def run(self):
for path in self.paths:
if path and os.path.isdir(path):
for file in os.listdir(path):
if os.path.isfile(os.path.join(path, file)):
print(os.path.splitext(file)[0])
return 0
================================================
FILE: rainbow/command/print_path.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
class PrintPathCommand(object):
def __init__(self, paths=None):
self.paths = paths or []
def run(self):
for path in self.paths:
if path:
print(os.path.abspath(path))
return 0
================================================
FILE: rainbow/command/stdin.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import codecs
import os
import sys
from rainbow.ansi import ANSI_RESET_ALL
from rainbow.transformer import IdentityTransformer
class STDINCommand(object):
def __init__(self,
transformer=IdentityTransformer(),
encoding=sys.getdefaultencoding()):
self.transformer = transformer
self.encoding = encoding
def run(self):
stdin_fd = sys.stdin.fileno()
stdout_fd = sys.stdout.fileno()
reader = codecs.getreader(self.encoding)(os.fdopen(stdin_fd, 'rb'), errors='replace')
try:
while True:
line = reader.readline()
if line:
os.write(stdout_fd, self.transformer.transform(line).encode(self.encoding, 'replace'))
else:
return 0
except KeyboardInterrupt:
return 1
finally:
os.write(stdout_fd, ANSI_RESET_ALL.encode(self.encoding, 'replace'))
================================================
FILE: rainbow/config/__init__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
================================================
FILE: rainbow/config/builtin/df.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for df.
#
# Usage:
# $ rainbow df
# ----------------------------------------------------------------------
[filters]
red: (9\d|100)%%
================================================
FILE: rainbow/config/builtin/diff.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for the 'diff' command.
#
# Usage:
# $ rainbow diff file1 file2
# ----------------------------------------------------------------------
[filters]
green: ^\+.*
red: ^\-.*
faint: ^\s.*
bold: Index:\s.*|^=+
magenta: ^@@.*
================================================
FILE: rainbow/config/builtin/env.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for env.
#
# Usage:
# $ rainbow env
# ----------------------------------------------------------------------
[filters]
reset-all: (?<==).*
bold: ^[^=]+=|[:;,]
blue: ^[^=]+|[:;,]
================================================
FILE: rainbow/config/builtin/host.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for host.
#
# Usage:
# $ rainbow host www.google.com
# ----------------------------------------------------------------------
[filters]
bold: ^.*\ has\ address\ [0-9.]*$|^.*\ mail\ is\ handled\ by\ .*$
================================================
FILE: rainbow/config/builtin/ifconfig.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for ifconfig.
#
# Usage:
# $ rainbow ifconfig
# ----------------------------------------------------------------------
[filters]
underline: ^([^\ ]+)
bold: ^\ *inet\ ad{1,2}r:[0-9.]+
================================================
FILE: rainbow/config/builtin/java-stack-trace.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Displays Java stack traces in red.
# ----------------------------------------------------------------------
[filters]
red: ^[a-zA-Z\.]*Exception.*|^\s+at\s.*|^Caused\ by:.*|^\s+\.\.\.\ [0-9]+\smore
================================================
FILE: rainbow/config/builtin/jboss.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for JBoss (4,5,6) output.
#
# Usage:
# $ rainbow --config=jboss -- jboss/bin/run.sh run
# ----------------------------------------------------------------------
[general]
imports: java-stack-trace
[filters]
bold: ^=+
faint: ^\d+:\d+:\d+,\d+
red: \s+ERROR\s+.*|DEPLOYMENTS\sMISSING\sDEPENDENCIES:|DEPLOYMENTS\sIN\sERROR:
yellow: \s+WARN\s+.*|\s+ATTENTION\s+.*
green: \[Server\].*Started\sin\s.*|\[ServerImpl\].*Started\sin\s.*|\[AbstractServer\]\sStopped:.*\sin\s.*|\[Server\]\sShutdown\scomplete|\[ServerImpl\]\sShutdown\scomplete|^Shutdown\scomplete|^Halting\sVM
================================================
FILE: rainbow/config/builtin/md5sum.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for md5sum.
#
# Usage:
# $ rainbow md5sum some-file
# ----------------------------------------------------------------------
[filters]
faint: ^([^\ ]+)
================================================
FILE: rainbow/config/builtin/mvn.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for Maven 3.
#
# Usage:
# $ rainbow mvn clean install
# ----------------------------------------------------------------------
[filters]
bold: \[INFO\]\s-+$|\[ERROR\]\s.*|\[INFO\]\sBuilding\s[^jar\s].*|\[INFO\]\s+task-segment:\s.*|^Results.*
faint: \[INFO\]\s(---|<<<|>>>)\s[a-z-]+:[0-9\.a-z-]+:.*\s@\s.*\s(---|<<<|>>>)|\[INFO\]\sTotal\stime:\s.*|\[INFO\]\sFinished\sat:\s.*|\[INFO\]\sFinal\sMemory:\s.*
yellow: \[WARNING\]\s.*|^NOTE:\sMaven\sis\sexecuting\sin\soffline\smode\.|^-+$|^\sT\sE\sS\sT\sS$|^Tests\srun:.*Failures:\s0.*Errors:\s0.*Skipped:\s[^0].*
red: \[ERROR\]\s.*|\[INFO\]\sBUILD\sFAILURE|^Tests\srun:.*Failures:\s[^0].*|^Tests\srun:.*Errors:\s[^0].*
magenta: ^Downloading:\s.*
green: \[INFO\]\sBUILD\sSUCCESS|\[INFO\]\sScanning\sfor\sprojects|^Tests\srun:.*Failures:\s0.*Errors:\s0.*Skipped:\s0.*
================================================
FILE: rainbow/config/builtin/ping.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for the 'ping' command.
#
# Usage:
# $ rainbow ping www.google.fr
# ----------------------------------------------------------------------
[filters]
magenta: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
yellow: time=\d+(\.\d+)*\sms
red: .+unknown\shost\s.+
bold: PING.*|^---.*|.+unknown\shost\s.+|\d+(\.\d+)*\sms
================================================
FILE: rainbow/config/builtin/tcpdump.cfg
================================================
[filters]
# IPv4 address+port:
reset-all-after: (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,5}|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})
magenta-before: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
blue-after: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\.
reset-after: \d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
# MAC address:
yellow: ([0-9a-f]{2}\:){5}[0-9a-f]{2}
# TCP/UDP flags:
# 1. TCP Flags
# 2. UDP indicator
# 3. UDP indicator with checksum indicator
# Note: Bare "[udp sum ok]" is highlighted because tcpdump will
# sometimes omit the "UDP"
cyan: (?<=Flags )\[[SP\.RFU]+\]
(?<=\: )UDP
(?<=\: )\[udp sum ok\]( UDP)?
# error conditions (UDP, TCP, IPv4):
red: (?<=\: )\[bad udp cksum.*?\]
cksum \S+ \(incorrect.*?\)
bad cksum .*?!
# Network-layer Description (e.g. "IP")
# 1. With -e flag
# 2. With -e flag where no link layer addresses exist (e.g. VPN interface)
# 3. Without -e flag
bold: (?<=ethertype )\S+ \S+(?=,)
(?<=^\d{2}\:\d{2}\:\d{2}\.\d{6} AF )[^\s\:]+\s
(?<=^\d{2}\:\d{2}\:\d{2}\.\d{6} )[^\s\:]+\s
# Time stamp:
faint: \d{2}\:\d{2}\:\d{2}\.\d{6}
================================================
FILE: rainbow/config/builtin/tomcat.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for Tomcat (5,6,7) output.
#
# Usage:
# $ rainbow tomcat/bin/catalina.sh run
# ----------------------------------------------------------------------
[general]
imports: java-stack-trace
[filters]
faint: ^[A-Z][a-z]+\s\d+,\s\d+\s\d+:\d+:\d+|^\d+\s[a-z]+\s\d+\s\d+:\d+:\d+
red: ^GRAVE:\s.*|^SEVERE:\s.*
yellow: ^ATTENTION:\s.*|^WARNING:\s.*
bold: ^Using\s.*
================================================
FILE: rainbow/config/builtin/traceroute.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
# Description:
# Example Rainbow configuration for the 'traceroute' command.
#
# Usage:
# $ rainbow traceroute www.google.com
# ----------------------------------------------------------------------
[filters]
underline: ^traceroute\sto\s.+
bold: ^\s*\d+
================================================
FILE: rainbow/config/loader.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
from rainbow import LOGGER
from rainbow.config.locator import ConfigLocator
from rainbow.config.parser import ConfigParser
PRECOMMANDS = [
'sudo',
'strace',
'record',
'builtin',
'command',
'exec',
'nocorrect',
'noglob',
'pkexec',
'sh',
'bash',
'csh',
'ksh',
'fish',
'zsh'
]
class ConfigLoader(object):
def __init__(self,
stdout_builder,
stderr_builder,
paths=None,
error_handler=lambda error: None):
self.locator = ConfigLocator(paths)
self.parser = ConfigParser(stdout_builder, stderr_builder, paths, error_handler)
self.error_handler = error_handler
def load_config_by_name(self, config):
config_file = self.locator.locate_config_file(config)
if config_file:
self.parser.parse_file(config_file)
else:
self.error_handler('Could not resolve config "%s"' % config)
def load_config_from_command_line(self, command_line_args):
LOGGER.debug('Trying to load config from command line "%s".', command_line_args)
config_name = self.find_config_name_from_command_line(command_line_args)
if config_name:
config_file = self.locator.locate_config_file(config_name)
if config_file:
self.parser.parse_file(config_file)
@staticmethod
def find_config_name_from_command_line(command_line_args):
for arg in command_line_args:
if arg[0] != '-':
basename = os.path.basename(arg)
if basename not in PRECOMMANDS:
return basename
return
================================================
FILE: rainbow/config/locator.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
from os.path import isfile, join
from rainbow import LOGGER
class ConfigLocator(object):
def __init__(self, paths=None):
self.paths = paths or []
def locate_config_file(self, config, working_directory=None):
LOGGER.debug('Trying to find config "%s"', config)
config_file = self.locate_config_file_in_directory(os.getcwd(), config)
if config_file:
return config_file
if working_directory:
config_file = self.locate_config_file_in_directory(working_directory, config)
if config_file:
return config_file
for directory in self.paths:
if directory:
config_file = self.locate_config_file_in_directory(directory, config)
if config_file:
return config_file
@staticmethod
def locate_config_file_in_directory(directory, config):
config_file = config
if isfile(config_file):
return config_file
config_file = config + '.cfg'
if isfile(config_file):
return config + '.cfg'
config_file = join(directory, config)
if isfile(config_file):
return config_file
config_file = join(directory, config + '.cfg')
if isfile(config_file):
return config_file
================================================
FILE: rainbow/config/parser.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
from os.path import dirname
from rainbow import LOGGER
from rainbow.config.locator import ConfigLocator
from rainbow.filter import FILTERS_BY_NAME, FILTERS_BY_SHORT_OPTION, FILTERS_BY_LONG_OPTION
try:
import configparser
except ImportError: # no cover
import ConfigParser as configparser
class ConfigParser(object):
def __init__(self,
stdout_builder,
stderr_builder,
paths=None,
error_handler=lambda error: None):
self.locator = ConfigLocator(paths)
self.stdout_builder = stdout_builder
self.stderr_builder = stderr_builder
self.error_handler = error_handler
def parse_file(self, config_file):
LOGGER.debug('Loading the config file "%s"', config_file)
config_parser = configparser.ConfigParser()
try:
if not config_parser.read(config_file):
self.error_handler('Could not open config file "%s"' % config_file)
return
except configparser.DuplicateSectionError as e: # no cover (inconsistent between Python 2 and 3)
self.error_handler('Duplicate section "%s" in "%s"' % (e.section, config_file))
return
enable_stderr_filtering = True
for section in config_parser.sections():
if section == 'general':
for key, value in config_parser.items(section):
if key == 'imports':
if not value:
self.error_handler('Empty imports section in config "%s"' % config_file)
else:
for config_import in [v.strip() for v in value.split(',')]:
if not config_import:
self.error_handler('Empty import in config "%s"' % config_file)
else:
config_import_file = self.locator.locate_config_file(config_import,
dirname(config_file))
if config_import_file:
self.parse_file(config_import_file)
else:
self.error_handler('Failed to resolve import of "%s" in config "%s"'
% (config_import, config_file))
elif key == 'enable-stderr-filtering':
try:
enable_stderr_filtering = config_parser.getboolean(section, 'enable-stderr-filtering')
except ValueError:
self.error_handler(
'Invalid value "%s" for key "%s" in config "%s"' % (value, key, config_file))
else:
self.error_handler('Invalid key "%s" in general section of config "%s"' % (key, config_file))
elif section == 'filters':
for filter_name, pattern_lines in config_parser.items(section):
resolved_filter = \
FILTERS_BY_NAME.get(filter_name) or \
FILTERS_BY_LONG_OPTION.get(filter_name) or \
FILTERS_BY_SHORT_OPTION.get(filter_name)
if not resolved_filter:
self.error_handler('Unknown filter "%s" in config "%s"' % (filter_name, config_file))
continue
if not pattern_lines:
self.error_handler('Empty pattern for "%s" in config "%s"' % (filter_name, config_file))
continue
for pattern in pattern_lines.splitlines():
self.stdout_builder.add_mapping(pattern, resolved_filter)
if enable_stderr_filtering:
self.stderr_builder.add_mapping(pattern, resolved_filter)
else:
self.error_handler('Invalid section "%s" in config "%s"' % (section, config_file))
LOGGER.info('Loaded config "%s"', config_file)
================================================
FILE: rainbow/filter.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
from . import ansi
class Filter(object):
def __init__(self, name, help, short_option=None, long_option=None, before=None, after=None):
self.name = name
self.help = help
self.short_option = short_option
self.long_option = long_option
self.before = before
self.after = after
def __str__(self):
return self.name
class FilterGroup(object):
def __init__(self, name, help, filters):
self.name = name
self.help = help
self.filters = filters
def __str__(self):
return self.name
FILTER_GROUPS = [
FilterGroup(
name='Foreground color',
help='Use these options to associate patterns to text foreground colors.',
filters=[
Filter(name='foreground-red',
short_option='r',
long_option='red',
help='print pattern in red',
before=ansi.ANSI_FOREGROUND_RED,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-light-red',
long_option='lightred',
help='print pattern in light red',
before=ansi.ANSI_FOREGROUND_LIGHT_RED,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-green',
short_option='g',
long_option='green',
help='print pattern in green',
before=ansi.ANSI_FOREGROUND_GREEN,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-light-green',
long_option='lightgreen',
help='print pattern in light green',
before=ansi.ANSI_FOREGROUND_LIGHT_GREEN,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-yellow',
short_option='y',
long_option='yellow',
help='print pattern in yellow',
before=ansi.ANSI_FOREGROUND_YELLOW,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-light-yellow',
long_option='lightyellow',
help='print pattern in light yellow',
before=ansi.ANSI_FOREGROUND_LIGHT_YELLOW,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-blue',
short_option='b',
long_option='blue',
help='print pattern in blue',
before=ansi.ANSI_FOREGROUND_BLUE,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-light-blue',
long_option='lightblue',
help='print pattern in light blue',
before=ansi.ANSI_FOREGROUND_LIGHT_BLUE,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-magenta',
short_option='m',
long_option='magenta',
help='print pattern in magenta',
before=ansi.ANSI_FOREGROUND_MAGENTA,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-cyan',
short_option='c',
long_option='cyan',
help='print pattern in cyan',
before=ansi.ANSI_FOREGROUND_CYAN,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-light-cyan',
long_option='lightcyan',
help='print pattern in light cyan',
before=ansi.ANSI_FOREGROUND_LIGHT_CYAN,
after=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-red-before',
long_option='red-before',
help='toggle foreground to red on beginning of pattern',
before=ansi.ANSI_FOREGROUND_RED),
Filter(name='foreground-light-red-before',
long_option='lightred-before',
help='toggle foreground to light red on beginning of pattern',
before=ansi.ANSI_FOREGROUND_LIGHT_RED),
Filter(name='foreground-green-before',
long_option='green-before',
help='toggle foreground to green on beginning of pattern',
before=ansi.ANSI_FOREGROUND_GREEN),
Filter(name='foreground-light-green-before',
long_option='lightgreen-before',
help='toggle foreground to light green on beginning of pattern',
before=ansi.ANSI_FOREGROUND_LIGHT_GREEN),
Filter(name='foreground-yellow-before',
long_option='yellow-before',
help='toggle foreground to yellow on beginning of pattern',
before=ansi.ANSI_FOREGROUND_YELLOW),
Filter(name='foreground-light-yellow-before',
long_option='lightyellow-before',
help='toggle foreground to light yellow on beginning of pattern',
before=ansi.ANSI_FOREGROUND_LIGHT_YELLOW),
Filter(name='foreground-blue-before',
long_option='blue-before',
help='toggle foreground to blue on beginning of pattern',
before=ansi.ANSI_FOREGROUND_BLUE),
Filter(name='foreground-light-blue-before',
long_option='lightblue-before',
help='toggle foreground to light blue on beginning of pattern',
before=ansi.ANSI_FOREGROUND_LIGHT_BLUE),
Filter(name='foreground-magenta-before',
long_option='magenta-before',
help='toggle foreground to magenta on beginning of pattern',
before=ansi.ANSI_FOREGROUND_MAGENTA),
Filter(name='foreground-cyan-before',
long_option='cyan-before',
help='toggle foreground to cyan on beginning of pattern',
before=ansi.ANSI_FOREGROUND_CYAN),
Filter(name='foreground-light-cyan-before',
long_option='lightcyan-before',
help='toggle foreground to light cyan on beginning of pattern',
before=ansi.ANSI_FOREGROUND_LIGHT_CYAN),
Filter(name='foreground-reset-before',
long_option='reset-before',
help='reset foreground color on beginning of pattern',
before=ansi.ANSI_FOREGROUND_RESET),
Filter(name='foreground-red-after',
long_option='red-after',
help='toggle foreground to red on end of pattern',
after=ansi.ANSI_FOREGROUND_RED),
Filter(name='foreground-light-red-after',
long_option='lightred-after',
help='toggle foreground to light red on end of pattern',
after=ansi.ANSI_FOREGROUND_LIGHT_RED),
Filter(name='foreground-green-after',
long_option='green-after',
help='toggle foreground to green on end of pattern',
after=ansi.ANSI_FOREGROUND_GREEN),
Filter(name='foreground-light-green-after',
long_option='lightgreen-after',
help='toggle foreground to light green on end of pattern',
after=ansi.ANSI_FOREGROUND_LIGHT_GREEN),
Filter(name='foreground-yellow-after',
long_option='yellow-after',
help='toggle foreground to yellow on end of pattern',
after=ansi.ANSI_FOREGROUND_YELLOW),
Filter(name='foreground-light-yellow-after',
long_option='lightyellow-after',
help='toggle foreground to light yellow on end of pattern',
after=ansi.ANSI_FOREGROUND_LIGHT_YELLOW),
Filter(name='foreground-blue-after',
long_option='blue-after',
help='toggle foreground to blue on end of pattern',
after=ansi.ANSI_FOREGROUND_BLUE),
Filter(name='foreground-light-blue-after',
long_option='lightblue-after',
help='toggle foreground to light blue on end of pattern',
after=ansi.ANSI_FOREGROUND_LIGHT_BLUE),
Filter(name='foreground-magenta-after',
long_option='magenta-after',
help='toggle foreground to magenta on end of pattern',
after=ansi.ANSI_FOREGROUND_MAGENTA),
Filter(name='foreground-cyan-after',
long_option='cyan-after',
help='toggle foreground to cyan on end of pattern',
after=ansi.ANSI_FOREGROUND_CYAN),
Filter(name='foreground-light-cyan-after',
long_option='lightcyan-after',
help='toggle foreground to light cyan on end of pattern',
after=ansi.ANSI_FOREGROUND_LIGHT_CYAN),
Filter(name='foreground-reset-after',
long_option='reset-after',
help='reset foreground color on end of pattern',
after=ansi.ANSI_FOREGROUND_RESET),
]
),
FilterGroup(
name='Background color',
help='Use these options to associate patterns to text background colors.',
filters=[
Filter(name='background-red',
long_option='background-red',
help='print pattern with red background',
before=ansi.ANSI_BACKGROUND_RED,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-light-red',
long_option='background-lightred',
help='print pattern with light red background',
before=ansi.ANSI_BACKGROUND_LIGHT_RED,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-green',
long_option='background-green',
help='print pattern with green background',
before=ansi.ANSI_BACKGROUND_GREEN,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-light-green',
long_option='background-lightgreen',
help='print pattern with light green background',
before=ansi.ANSI_BACKGROUND_LIGHT_GREEN,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-yellow',
long_option='background-yellow',
help='print pattern with yellow background',
before=ansi.ANSI_BACKGROUND_YELLOW,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-light-yellow',
long_option='background-lightyellow',
help='print pattern with light yellow background',
before=ansi.ANSI_BACKGROUND_LIGHT_YELLOW,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-blue',
long_option='background-blue',
help='print pattern with blue background',
before=ansi.ANSI_BACKGROUND_BLUE,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-light-blue',
long_option='background-lightblue',
help='print pattern with light blue background',
before=ansi.ANSI_BACKGROUND_LIGHT_BLUE,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-magenta',
long_option='background-magenta',
help='print pattern with magenta background',
before=ansi.ANSI_BACKGROUND_MAGENTA,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-cyan',
long_option='background-cyan',
help='print pattern with cyan background',
before=ansi.ANSI_BACKGROUND_CYAN,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-light-cyan',
long_option='background-lightcyan',
help='print pattern with light cyan background',
before=ansi.ANSI_BACKGROUND_LIGHT_CYAN,
after=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-red-before',
long_option='background-red-before',
help='toggle background to red on beginning of pattern',
before=ansi.ANSI_BACKGROUND_RED),
Filter(name='background-light-red-before',
long_option='background-lightred-before',
help='toggle background to light red on beginning of pattern',
before=ansi.ANSI_BACKGROUND_LIGHT_RED),
Filter(name='background-green-before',
long_option='background-green-before',
help='toggle background to green on beginning of pattern',
before=ansi.ANSI_BACKGROUND_GREEN),
Filter(name='background-light-green-before',
long_option='background-lightgreen-before',
help='toggle background to light green on beginning of pattern',
before=ansi.ANSI_BACKGROUND_LIGHT_GREEN),
Filter(name='background-yellow-before',
long_option='background-yellow-before',
help='toggle background to yellow on beginning of pattern',
before=ansi.ANSI_BACKGROUND_YELLOW),
Filter(name='background-light-yellow-before',
long_option='background-lightyellow-before',
help='toggle background to light yellow on beginning of pattern',
before=ansi.ANSI_BACKGROUND_LIGHT_YELLOW),
Filter(name='background-blue-before',
long_option='background-blue-before',
help='toggle background to blue on beginning of pattern',
before=ansi.ANSI_BACKGROUND_BLUE),
Filter(name='background-light-blue-before',
long_option='background-lightblue-before',
help='toggle background to light blue on beginning of pattern',
before=ansi.ANSI_BACKGROUND_LIGHT_BLUE),
Filter(name='background-magenta-before',
long_option='background-magenta-before',
help='toggle background to magenta on beginning of pattern',
before=ansi.ANSI_BACKGROUND_MAGENTA),
Filter(name='background-cyan-before',
long_option='background-cyan-before',
help='toggle background to cyan on beginning of pattern',
before=ansi.ANSI_BACKGROUND_CYAN),
Filter(name='background-light-cyan-before',
long_option='background-lightcyan-before',
help='toggle background to light cyan on beginning of pattern',
before=ansi.ANSI_BACKGROUND_LIGHT_CYAN),
Filter(name='background-reset-before',
long_option='background-reset-before',
help='reset background color on beginning of pattern',
before=ansi.ANSI_BACKGROUND_RESET),
Filter(name='background-red-after',
long_option='background-red-after',
help='toggle background to red on end of pattern',
after=ansi.ANSI_BACKGROUND_RED),
Filter(name='background-light-red-after',
long_option='background-lightred-after',
help='toggle background to light red on end of pattern',
after=ansi.ANSI_BACKGROUND_LIGHT_RED),
Filter(name='background-green-after',
long_option='background-green-after',
help='toggle background to green on end of pattern',
after=ansi.ANSI_BACKGROUND_GREEN),
Filter(name='background-light-green-after',
long_option='background-lightgreen-after',
help='toggle background to light green on end of pattern',
after=ansi.ANSI_BACKGROUND_LIGHT_GREEN),
Filter(name='background-yellow-after',
long_option='background-yellow-after',
help='toggle background to yellow on end of pattern',
after=ansi.ANSI_BACKGROUND_YELLOW),
Filter(name='background-light-yellow-after',
long_option='background-lightyellow-after',
help='toggle background to light yellow on end of pattern',
after=ansi.ANSI_BACKGROUND_LIGHT_YELLOW),
Filter(name='background-blue-after',
long_option='background-blue-after',
help='toggle background to blue on end of pattern',
after=ansi.ANSI_BACKGROUND_BLUE),
Filter(name='background-light-blue-after',
long_option='background-lightblue-after',
help='toggle background to light blue on end of pattern',
after=ansi.ANSI_BACKGROUND_LIGHT_BLUE),
Filter(name='background-magenta-after',
long_option='background-magenta-after',
help='toggle background to magenta on end of pattern',
after=ansi.ANSI_BACKGROUND_MAGENTA),
Filter(name='background-cyan-after',
long_option='background-cyan-after',
help='toggle background to cyan on end of pattern',
after=ansi.ANSI_BACKGROUND_CYAN),
Filter(name='background-light-cyan-after',
long_option='background-lightcyan-after',
help='toggle background to light cyan on end of pattern',
after=ansi.ANSI_BACKGROUND_LIGHT_CYAN),
Filter(name='background-reset-after',
long_option='background-reset-after',
help='reset background color on end of pattern',
after=ansi.ANSI_BACKGROUND_RESET),
]
),
FilterGroup(
name='Text effects',
help='Use these options to associate patterns to text effects.',
filters=[
Filter(name='bold',
long_option='bold',
help='print pattern in bold',
before=ansi.ANSI_BOLD,
after=ansi.ANSI_RESET_INTENSITY),
Filter(name='bold-before',
long_option='bold-before',
help='toggle bold on beginning of pattern',
before=ansi.ANSI_BOLD),
Filter(name='bold-after',
long_option='bold-after',
help='toggle bold on end of pattern',
after=ansi.ANSI_BOLD),
Filter(name='faint',
long_option='faint',
help='print pattern with decreased intensity',
before=ansi.ANSI_FAINT,
after=ansi.ANSI_RESET_INTENSITY),
Filter(name='faint-before',
long_option='faint-before',
help='toggle faint on beginning of pattern',
before=ansi.ANSI_FAINT),
Filter(name='faint-after',
long_option='faint-after',
help='toggle faint on end of pattern',
after=ansi.ANSI_FAINT),
Filter(name='intensity-reset-before',
long_option='intensity-reset-before',
help='reset text intensity (bold, faint) on beginning of pattern',
before=ansi.ANSI_RESET_INTENSITY),
Filter(name='intensity-reset-after',
long_option='intensity-reset-after',
help='reset text intensity (bold, faint) on end of pattern',
after=ansi.ANSI_RESET_INTENSITY),
Filter(name='italic',
long_option='italic',
help='print pattern in italic',
before=ansi.ANSI_ITALIC,
after=ansi.ANSI_RESET_ITALIC),
Filter(name='italic-before',
long_option='italic-before',
help='toggle italic on beginning of pattern',
before=ansi.ANSI_ITALIC),
Filter(name='italic-after',
long_option='italic-after',
help='toggle italic on end of pattern',
after=ansi.ANSI_ITALIC),
Filter(name='italic-reset-before',
long_option='italic-reset-before',
help='reset italic on beginning of pattern',
before=ansi.ANSI_RESET_ITALIC),
Filter(name='italic-reset-after',
long_option='italic-reset-after',
help='reset italic on end of pattern',
after=ansi.ANSI_RESET_ITALIC),
Filter(name='underline',
long_option='underline',
help='print pattern underlined',
before=ansi.ANSI_UNDERLINE,
after=ansi.ANSI_RESET_UNDERLINE),
Filter(name='underline-before',
long_option='underline-before',
help='toggle underline on beginning of pattern',
before=ansi.ANSI_UNDERLINE),
Filter(name='underline-after',
long_option='underline-after',
help='toggle underline on end of pattern',
after=ansi.ANSI_UNDERLINE),
Filter(name='underline-double',
long_option='underline-double',
help='print pattern double underlined',
before=ansi.ANSI_UNDERLINE_DOUBLE,
after=ansi.ANSI_RESET_UNDERLINE),
Filter(name='underline-double-before',
long_option='underline-double-before',
help='toggle double underline on beginning of pattern',
before=ansi.ANSI_UNDERLINE_DOUBLE),
Filter(name='underline-double-after',
long_option='underline-double-after',
help='toggle double underline on end of pattern',
after=ansi.ANSI_UNDERLINE_DOUBLE),
Filter(name='underline-reset-before',
long_option='underline-reset-before',
help='reset underline on beginning of pattern',
before=ansi.ANSI_RESET_UNDERLINE),
Filter(name='underline-reset-after',
long_option='underline-reset-after',
help='reset underline on end of pattern',
after=ansi.ANSI_RESET_UNDERLINE),
Filter(name='blink',
long_option='blink',
help='print pattern blinking',
before=ansi.ANSI_BLINK,
after=ansi.ANSI_RESET_BLINK),
Filter(name='blink-before',
long_option='blink-before',
help='toggle blinking on beginning of pattern',
before=ansi.ANSI_BLINK),
Filter(name='blink-after',
long_option='blink-after',
help='toggle blinking on end of pattern',
after=ansi.ANSI_BLINK),
Filter(name='blink-rapid',
long_option='blink-rapid',
help='print pattern blinking rapidly',
before=ansi.ANSI_BLINK,
after=ansi.ANSI_RESET_BLINK),
Filter(name='blink-rapid-before',
long_option='blink-rapid-before',
help='toggle rapid blinking on beginning of pattern',
before=ansi.ANSI_BLINK),
Filter(name='blink-rapid-after',
long_option='blink-rapid-after',
help='toggle rapid blinking on end of pattern',
after=ansi.ANSI_BLINK),
Filter(name='blink-reset-before',
long_option='blink-reset-before',
help='reset blinking on beginning of pattern',
before=ansi.ANSI_RESET_BLINK),
Filter(name='blink-reset-after',
long_option='blink-reset-after',
help='reset blinking on end of pattern',
after=ansi.ANSI_RESET_BLINK),
Filter(name='negative',
long_option='negative',
help='print pattern swapping foreground and background',
before=ansi.ANSI_NEGATIVE,
after=ansi.ANSI_RESET_NEGATIVE),
Filter(name='negative-before',
long_option='negative-before',
help='toggle negative on beginning of pattern',
before=ansi.ANSI_NEGATIVE),
Filter(name='negative-after',
long_option='negative-after',
help='toggle negative on end of pattern',
after=ansi.ANSI_NEGATIVE),
Filter(name='negative-reset-before',
long_option='negative-reset-before',
help='reset negative on beginning of pattern',
before=ansi.ANSI_RESET_NEGATIVE),
Filter(name='negative-reset-after',
long_option='negative-reset-after',
help='reset negative on end of pattern',
after=ansi.ANSI_RESET_NEGATIVE),
Filter(name='hide',
long_option='hide',
help='print pattern hidden',
before=ansi.ANSI_HIDE,
after=ansi.ANSI_RESET_HIDE),
Filter(name='hide-before',
long_option='hide-before',
help='toggle hiding on beginning of pattern',
before=ansi.ANSI_HIDE),
Filter(name='hide-after',
long_option='hide-after',
help='toggle hiding on end of pattern',
after=ansi.ANSI_HIDE),
Filter(name='hide-reset-before',
long_option='hide-reset-before',
help='reset hiding on beginning of pattern',
before=ansi.ANSI_RESET_HIDE),
Filter(name='hide-reset-after',
long_option='hide-reset-after',
help='reset hiding on end of pattern',
after=ansi.ANSI_RESET_HIDE),
Filter(name='reset-all',
long_option='reset-all',
help='reset all colors',
before=ansi.ANSI_RESET_ALL,
after=ansi.ANSI_RESET_ALL),
Filter(name='reset-all-before',
long_option='reset-all-before',
help='reset all colors on beginning of pattern',
before=ansi.ANSI_RESET_ALL),
Filter(name='reset-all-after',
long_option='reset-all-after',
help='reset all colors on end of pattern',
after=ansi.ANSI_RESET_ALL),
]
)
]
FILTERS = [f for g in FILTER_GROUPS for f in g.filters]
FILTERS_BY_NAME = dict((filter.name, filter) for group in FILTER_GROUPS for filter in group.filters)
FILTERS_BY_SHORT_OPTION = dict((filter.short_option, filter) for group in FILTER_GROUPS for filter in group.filters)
FILTERS_BY_LONG_OPTION = dict((filter.long_option, filter) for group in FILTER_GROUPS for filter in group.filters)
================================================
FILE: rainbow/transformer.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
import re
from . import LOGGER
class IdentityTransformer(object):
def __init__(self):
pass
def transform(self, line):
return line
def __str__(self):
return 'identity'
def __eq__(self, other):
return isinstance(other, self.__class__)
class ReplaceTransformer(IdentityTransformer):
def __init__(self, value, replacement):
IdentityTransformer.__init__(self)
self.value = value
self.replacement = replacement
def transform(self, line):
return line.replace(self.value, self.replacement)
def __str__(self):
return 'replace "%s" with "%s"' % (self.value, self.replacement)
def __eq__(self, other):
return isinstance(other, self.__class__) and (self.value, self.replacement) == (other.value, other.replacement)
class ReplaceRegexTransformer(IdentityTransformer):
def __init__(self, regex, replacement):
IdentityTransformer.__init__(self)
self.regex = regex
self.replacement = replacement
def transform(self, line):
return self.regex.sub(self.replacement, line)
def __str__(self):
return 'replace "%s" with "%s"' % (self.regex.pattern, self.replacement)
def __eq__(self, other):
return isinstance(other, self.__class__) and (self.regex, self.replacement) == (other.regex, other.replacement)
class InsertBeforeRegexTransformer(IdentityTransformer):
def __init__(self, regex, before):
IdentityTransformer.__init__(self)
self.regex = regex
self.before = before
def transform(self, line):
return self.regex.sub(self.before + r'\g<0>', line)
def __str__(self):
return 'insert "%s" before "%s"' % (self.before, self.regex.pattern)
def __eq__(self, other):
return isinstance(other, self.__class__) and (self.regex, self.before) == (other.regex, other.before)
class InsertAfterRegexTransformer(IdentityTransformer):
def __init__(self, regex, after):
IdentityTransformer.__init__(self)
self.regex = regex
self.after = after
def transform(self, line):
return self.regex.sub(r'\g<0>' + self.after, line)
def __str__(self):
return 'insert "%s" after "%s"' % (self.after, self.regex.pattern)
def __eq__(self, other):
return isinstance(other, self.__class__) and (self.regex, self.after) == (other.regex, other.after)
class InsertBeforeAndAfterRegexTransformer(IdentityTransformer):
def __init__(self, regex, before, after):
IdentityTransformer.__init__(self)
self.regex = regex
self.before = before
self.after = after
def transform(self, line):
return self.regex.sub(self.before + r'\g<0>' + self.after, line)
def __str__(self):
return 'insert "%s" before and "%s" after "%s"' % (self.before, self.after, self.regex.pattern)
def __eq__(self, other):
return isinstance(other, self.__class__) and (self.regex, self.before, self.after) == \
(other.regex, other.before, other.after)
class ListTransformer(IdentityTransformer):
def __init__(self, transformers):
IdentityTransformer.__init__(self)
self.transformers = transformers
def transform(self, line):
for transformer in self.transformers:
line = transformer.transform(line)
return line
def __str__(self):
return os.linesep.join([transformer.__str__() for transformer in self.transformers])
def __eq__(self, other):
return isinstance(other, self.__class__) and self.transformers == other.transformers
class DummyTransformerBuilder(object):
def __init__(self):
self.transformers = []
def add_mapping(self, pattern, filter):
pass
def build(self):
return IdentityTransformer()
class TransformerBuilder(DummyTransformerBuilder):
def add_mapping(self, pattern, filter):
LOGGER.debug('Binding pattern "%s" with filter "%s".', pattern, filter)
self.transformers.append(self.make_transformer(re.compile(pattern), filter))
@staticmethod
def make_transformer(regex, filter):
if filter.before and filter.after:
return InsertBeforeAndAfterRegexTransformer(regex, filter.before, filter.after)
elif filter.before:
return InsertBeforeRegexTransformer(regex, filter.before)
elif filter.after:
return InsertAfterRegexTransformer(regex, filter.after)
def build(self):
if not self.transformers:
return IdentityTransformer()
if len(self.transformers) == 1:
return self.transformers[0]
return ListTransformer(self.transformers)
================================================
FILE: scripts/rainbow
================================================
#!/usr/bin/python3
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import sys
from rainbow.__main__ import main
sys.exit(main())
================================================
FILE: setup.cfg
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
[clean]
paths = .cache,
.tox,
build,
dist,
rainbow.egg-info,
.coverage
[build_completion_bash]
shell = bash
output = build/completion/rainbow
[build_completion_zsh]
shell = zsh
output = build/completion/_rainbow
[build_man_page]
output = build/man/rainbow.1
[bdist_wheel]
universal = 1
[flake8]
max-line-length = 120
================================================
FILE: setup.py
================================================
#!/usr/bin/env python
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
from setuptools import setup, find_packages
from rainbow import __prog__, __version__, __license__, __author__, __email__, __url__, __description__
from rainbow.build import Clean, Build, GenerateCompletion, GenerateManPage
setup(
name=__prog__,
version=__version__,
author=__author__,
author_email=__email__,
url=__url__,
license=__license__,
description=__description__,
long_description=open(os.path.join(os.path.dirname(__file__), 'README.rst')).read(),
keywords='color colorize colorizer pattern',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Environment :: Console',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Topic :: System',
'Topic :: Utilities',
'Intended Audience :: Developers',
'Intended Audience :: End Users/Desktop',
'Intended Audience :: System Administrators',
'Natural Language :: English',
'Programming Language :: Python',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'License :: OSI Approved :: GNU General Public License (GPL)'
],
packages=find_packages(exclude=['tests*']),
include_package_data=True,
python_requires='>=3.6',
extras_require={
'build': [
'Jinja2==3.0.3',
],
'test': [
'pytest==6.2.5',
'coverage==6.2',
'pytest-cov==3.0.0',
'pytest-html==3.1.1',
'pytest-timeout==2.1.0',
'flake8==4.0.1',
'pygal==3.0.0',
'pygaljs==1.0.2',
'pytest-benchmark==3.4.1'
]
},
scripts=['scripts/rainbow'],
cmdclass={
'clean': Clean,
'build': Build,
'build_completion_bash': GenerateCompletion,
'build_completion_zsh': GenerateCompletion,
'build_man_page': GenerateManPage
}
)
================================================
FILE: templates/completion.bash
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
_rainbow()
{
local offset=0 i
for (( i=1; i <= COMP_CWORD; i++ )); do
case ${COMP_WORDS[$i]} in
--version|-h|--help|--disable-stderr-filtering|--verbose|-f|--config|-{{ filters|selectattr('short_option')|join('|-', attribute='short_option') }}|--{{ filters|join('|--', attribute='long_option') }})
i=$((i+1))
continue
;;
-*)
continue
;;
esac
offset=$i
break
done
if [[ $offset -gt 0 ]]; then
_command_offset $offset
else
cur=${COMP_WORDS[COMP_CWORD]}
if [ $COMP_CWORD -eq 1 ]; then
COMPREPLY=( $( compgen -W "--version -h --help --print-path --print-config-names --disable-stderr-filtering --verbose -f --config -{{ filters|selectattr('short_option')|join(' -', attribute='short_option') }} --{{ filters|join(' --', attribute='long_option') }}" -- $cur ) )
else
first=${COMP_WORDS[1]}
case "$first" in
--version|-h|--help|--print-path|--print-config-names)
COMPREPLY=()
;;
*)
prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
-{{ filters|selectattr('short_option')|join('|-', attribute='short_option') }}|--{{ filters|join('|--', attribute='long_option') }})
COMPREPLY=()
;;
-f|--config)
COMPREPLY=( $(rainbow --print-config-names) \
$(compgen -d $cur ) \
$(compgen -f -X "!*.cfg" $cur ) )
;;
*)
COMPREPLY=( $( compgen -W "--disable-stderr-filtering --verbose -f --config -{{ filters|selectattr('short_option')|join(' -', attribute='short_option') }} --{{ filters|join(' --', attribute='long_option') }}" -- $cur ) )
;;
esac
;;
esac
fi
fi
}
complete -F _rainbow rainbow
================================================
FILE: templates/completion.zsh
================================================
#compdef rainbow
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
_rainbow() {
typeset -A opt_args
local context state line curcontext="$curcontext"
_arguments \
{%- for filter in filters %}
{%- if filter.short_option %}
'*'{-{{ filter.short_option }}+,--{{ filter.long_option }}=}'[{{ filter.help }}]:pattern:_rainbow_patterns' \
{%- else %}
'*--{{ filter.long_option }}=[{{ filter.help }}]:pattern:_rainbow_patterns' \
{%- endif %}
{%- endfor %}
'(- 1 *)'{-h,--help}'[print program usage]' \
'(- 1 *)--version[print program version]' \
'(- 1 *)--print-path[print config paths]' \
'(- 1 *)--print-config-names[print config names]' \
'*'{-v,--verbose}'[verbose mode]' \
'--disable-stderr-filtering[disable STDERR filtering]' \
'*'{-f,--config=}'[rainbow config file]:rainbow config:_rainbow_configs' \
'(-):command name: _command_names -e' \
'*::arguments:_normal' && ret=0
}
(( $+functions[_rainbow_patterns] )) ||
_rainbow_patterns() {
_message -e pattern "pattern"
}
(( $+functions[_rainbow_configs] )) ||
_rainbow_configs() {
_alternative \
'config-names:config name:_rainbow_config_names' \
'config-files:config file:_rainbow_config_files'
}
(( $+functions[_rainbow_config_names] )) ||
_rainbow_config_names() {
local rainbow_config_names
rainbow_config_names=( "${(f)$(_call_program configs rainbow --print-config-names 2>/dev/null)}" )
_describe -t 'rainbow config names' 'rainbow config name' rainbow_config_names
}
(( $+functions[_rainbow_config_files] )) ||
_rainbow_config_files() {
_files -g "*.cfg"
}
_rainbow "$@"
================================================
FILE: templates/rainbow.man
================================================
.TH RAINBOW 1
.SH NAME
rainbow \- Colorize commands output using patterns.
.SH SYNOPSIS
.B rainbow
[rainbow options...] command [command args...]
command [command args...] |
.B rainbow
[rainbow options...]
.SH DESCRIPTION
Display commands output colored matching words or regular expressions. If you don't specify a command, STDIN is used.
.SH OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-'). A summary of
options is included below.
.PP
.B
Common options
.TP
.B
\-v, \-\-version
show program's version number and exit.
.TP
.B
\-h, \-\-help
show help message and exit.
.TP
.B
\-\-print-path
Print config paths and exit.
.TP
.B
\-\-print-config-names
Print config names and exit.
.TP
.B
\-f CONFIG, \-\-config CONFIG
Load a config file defining patterns. Go to /usr/share/rainbow/configs for examples. The option can be called
several times.
.TP
.B
\-\-disable\-stderr\-filtering
Disable STDERR filtering, which can have unexpected effects on commands directly using tty (such as top).
{%- for filter_group in filter_groups %}
.PP
.B
{{ filter_group.name }}
\- {{ filter_group.help }}
{%- for filter in filter_group.filters %}
.TP
.B
{%- if filter.short_option %}
\-{{ filter.short_option }}, \-\-{{ filter.long_option }} PATTERN
{{ filter.help }}
{%- else %}
\-\-{{ filter.long_option }} PATTERN
{{ filter.help }}
{%- endif %}
{%- endfor %}
{%- endfor %}
.SH EXAMPLES
.TP
Colorize the 'diff' command output using the builtin config:
rainbow diff file1 file2
.TP
Colorize the 'ping' command output using the builtin config:
rainbow ping www.google.com
.TP
Ping Google with IP addresses colorized in red:
rainbow \-\-red '\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}' ping www.google.com
.TP
Pipe content to rainbow instead of providing a command:
tail -f my-file.log | rainbow \-\-config my-config
.SH CONFIGS
.TP
The \-f or \-\-config option allows to load patterns defined in a configuration file, for example:
rainbow \-\-config MY_CONFIG
.PP
rainbow will look for the config at the following places, in the following order:
* $RAINBOW_CONFIGS/MY_CONFIG
* $RAINBOW_CONFIGS/MY_CONFIG.cfg
* $XDG_CONFIG_HOME/rainbow/MY_CONFIG
* $XDG_CONFIG_HOME/rainbow/MY_CONFIG.cfg
* ~/.rainbow/MY_CONFIG
* ~/.rainbow/MY_CONFIG.cfg
* /etc/rainbow/MY_CONFIG
* /etc/rainbow/MY_CONFIG.cfg
* <rainbow builtin configs>/MY_CONFIG
* <rainbow builtin configs>/usr/share/rainbow/configs/MY_CONFIG.cfg
rainbow comes bundled with several configs, for example for the ping, top and diff commands, for Tomcat/JBoss logs, etc.
You can override the default configs with your own ones by placing them in $RAINBOW_CONFIGS, ~/.rainbow or /etc/rainbow.
.SH BUGS
Please report bugs to https://github.com/nicoulaj/rainbow/issues.
.SH AUTHOR
.PP
This manual page was written by Julien Nicoulaud <julien.nicoulaud@gmail.com>,
for the rainbow project (https://github.com/nicoulaj/rainbow), and may be used
by others.
================================================
FILE: tests/__init__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
================================================
FILE: tests/command/__init__.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
================================================
FILE: tests/command/test_execute.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
import signal
import sys
from textwrap import dedent
from threading import Timer
import pytest
from rainbow import ansi
from rainbow.command.execute import ExecuteCommand
from rainbow.transformer import ReplaceTransformer
from tests.test_utils import stdin_empty_all_variants, stdin_from_string_all_variants
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_true(capfd, stdin):
with stdin:
assert ExecuteCommand(['true']).run() == 0
out, err = capfd.readouterr()
assert out == ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_false(capfd, stdin):
with stdin:
assert ExecuteCommand(['false']).run() == 1
out, err = capfd.readouterr()
assert out == ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('stdout\n')
sys.stdout.flush()
sys.stderr.write('stderr\n')
sys.stderr.flush()
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout\n' + ansi.ANSI_RESET_ALL
assert err == 'stderr\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity_no_newline(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('stdout')
sys.stdout.flush()
sys.stderr.write('stderr')
sys.stderr.flush()
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout' + ansi.ANSI_RESET_ALL
assert err == 'stderr' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity_partial_line(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys, time
sys.stdout.write('stdout1')
sys.stdout.flush()
time.sleep(0.5)
sys.stderr.write('stderr1')
sys.stderr.flush()
time.sleep(0.5)
sys.stdout.write('stdout2')
sys.stdout.flush()
time.sleep(0.5)
sys.stderr.write('stderr2')
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout1\rstdout1stdout2' + ansi.ANSI_RESET_ALL
assert err == 'stderr1\rstderr1stderr2' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity_overwritten_line(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys, time
sys.stdout.write('stdout1')
sys.stdout.flush()
time.sleep(0.5)
sys.stderr.write('stderr1')
sys.stderr.flush()
time.sleep(0.5)
sys.stdout.write('\rstdout2')
sys.stdout.flush()
time.sleep(0.5)
sys.stderr.write('\rstderr2')
sys.stderr.flush()
time.sleep(0.5)
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout1\rstdout1\rstdout2' + ansi.ANSI_RESET_ALL
assert err == 'stderr1\rstderr1\rstderr2' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity_bash(capfd, stdin):
with stdin:
assert ExecuteCommand(['/bin/bash', '-c', 'echo "stdout"; echo "stderr" >&2']).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout\n' + ansi.ANSI_RESET_ALL
assert err == 'stderr\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_identity_mixed_stdin_and_err(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('stdout1\n')
sys.stderr.write('stderr2\n')
sys.stdout.write('stdout3')
sys.stdout.write('stdout4\n')
sys.stderr.write('stderr4')
sys.stderr.write('stderr5\n')
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout1\nstdout3stdout4\n' + ansi.ANSI_RESET_ALL
assert err == 'stderr2\nstderr4stderr5\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_bufferized_output(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys, time
sys.stdout.write('stdout1\n')
sys.stdout.flush()
time.sleep(0.5)
sys.stdout.write('stdout2\nstdout3\n')
sys.stdout.flush()
time.sleep(0.5)
sys.stdout.write('stdout4\n')
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'stdout1\nstdout2\nstdout3\nstdout4\n' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_bufferized_partial_lines(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys, time
sys.stdout.write('std')
sys.stdout.flush()
time.sleep(0.5)
sys.stdout.write('out1\nstdout2\n')
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'std\rstdout1\nstdout2\n' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_unflushed_output(capfd, stdin):
with stdin:
assert ExecuteCommand(
[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('message')
''')]
).run() == 0
out, err = capfd.readouterr()
assert out == 'message' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.skip(reason="Issue #23: missing unit tests for executing subcommands with stdin")
@pytest.mark.timeout(2)
@pytest.mark.parametrize("stdin", stdin_from_string_all_variants('line\n'), ids=str)
def test_cat_stdin(capfd, stdin):
with stdin:
assert ExecuteCommand(['cat']).run() == 0
out, err = capfd.readouterr()
assert out == 'line\n' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.skip(reason="Issue #23: missing unit tests for executing subcommands with stdin")
@pytest.mark.timeout(2)
@pytest.mark.parametrize("stdin", stdin_from_string_all_variants('line1\nline2\n'), ids=str)
def test_cat_stdin_two_lines(capfd, stdin):
with stdin:
assert ExecuteCommand(['cat']).run() == 0
out, err = capfd.readouterr()
assert out == 'line1\nline2\n' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stdout_transformer(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('message\n')
sys.stderr.write('message\n')
''')],
stdout_transformer=ReplaceTransformer('message', 'REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'REPLACED\n' + ansi.ANSI_RESET_ALL
assert err == 'message\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stdout_transformer_bash(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=['/bin/bash', '-c', 'echo "message"; echo "message" >&2'],
stdout_transformer=ReplaceTransformer('message', 'REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'REPLACED\n' + ansi.ANSI_RESET_ALL
assert err == 'message\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stderr_transformer(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('message\n')
sys.stderr.write('message\n')
''')],
stderr_transformer=ReplaceTransformer('message', 'REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'message\n' + ansi.ANSI_RESET_ALL
assert err == 'REPLACED\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stderr_transformer_bash(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=['/bin/bash', '-c', 'echo "message"; echo "message" >&2'],
stderr_transformer=ReplaceTransformer('message', 'REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'message\n' + ansi.ANSI_RESET_ALL
assert err == 'REPLACED\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stdout_and_stderr_transformers(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=[sys.executable, '-c', dedent(r'''
import sys
sys.stdout.write('stdout\n')
sys.stderr.write('stderr\n')
''')],
stdout_transformer=ReplaceTransformer('stdout', 'STDOUT_REPLACED'),
stderr_transformer=ReplaceTransformer('stderr', 'STDERR_REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'STDOUT_REPLACED\n' + ansi.ANSI_RESET_ALL
assert err == 'STDERR_REPLACED\n' + ansi.ANSI_RESET_ALL
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_stdout_and_stderr_transformers_bash(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=['/bin/bash', '-c', 'echo "stdout"; echo "stderr" >&2'],
stdout_transformer=ReplaceTransformer('stdout', 'STDOUT_REPLACED'),
stderr_transformer=ReplaceTransformer('stderr', 'STDERR_REPLACED')
).run() == 0
out, err = capfd.readouterr()
assert out == 'STDOUT_REPLACED\n' + ansi.ANSI_RESET_ALL
assert err == 'STDERR_REPLACED\n' + ansi.ANSI_RESET_ALL
@pytest.mark.skip(reason="Issue #23: missing unit tests for executing subcommands with stdin")
@pytest.mark.timeout(2)
@pytest.mark.parametrize("stdin", stdin_from_string_all_variants("foo bar"), ids=str)
def test_read_bash(capfd, stdin):
with stdin:
assert ExecuteCommand(
args=['/bin/bash', '-c', 'read -p "Enter your input:" result; echo "You entered: $result"']
).run() == 0
out, err = capfd.readouterr()
assert out == 'Enter your input:\nYou entered: foo bar' + ansi.ANSI_RESET_ALL
assert err == ansi.ANSI_RESET_ALL
@pytest.mark.timeout(5)
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_interrupted(stdin):
with stdin:
Timer(1.0, os.kill, [os.getpid(), signal.SIGINT]).start()
assert ExecuteCommand(['sleep', '100']).run() == -2
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_malformed_utf8(stdin):
with stdin:
assert ExecuteCommand(['cat', 'tests/data/UTF-8-test.txt']).run() == 0
================================================
FILE: tests/command/test_noop.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import pytest
from rainbow.command.noop import NoOpCommand
def test_noop(capsys):
assert NoOpCommand().run() == 0
out, err = capsys.readouterr()
assert out == ''
assert err == ''
@pytest.mark.parametrize("exit_code", range(-256, 256), ids=str)
def test_noop_with_exit_code(capsys, exit_code):
assert NoOpCommand(exit_code).run() == exit_code
out, err = capsys.readouterr()
assert out == ''
assert err == ''
================================================
FILE: tests/command/test_print_config_names.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
from rainbow import DEFAULT_PATH
from rainbow.command.print_config_names import PrintConfigNamesCommand
def test_empty_path(capsys):
assert PrintConfigNamesCommand().run() == 0
out, err = capsys.readouterr()
assert out == ''
assert err == ''
def test_default_path(capsys):
assert PrintConfigNamesCommand(DEFAULT_PATH).run() == 0
out, err = capsys.readouterr()
assert 'diff\n' in out
assert 'ping' in out
assert 'md5sum' in out
assert 'env' in out
assert 'java-stack-trace' in out
assert 'host' in out
assert 'ifconfig' in out
assert 'traceroute' in out
assert 'df' in out
assert 'mvn' in out
assert 'tomcat' in out
assert err == ''
================================================
FILE: tests/command/test_print_path.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
from rainbow import DEFAULT_PATH
from rainbow.command.print_path import PrintPathCommand
def test_empty_path(capsys):
assert PrintPathCommand().run() == 0
out, err = capsys.readouterr()
assert out == ''
assert err == ''
def test_default_path(capsys):
assert PrintPathCommand(DEFAULT_PATH).run() == 0
out, err = capsys.readouterr()
assert os.path.expanduser('~/.rainbow') in out
assert os.path.join(os.sep, 'etc', 'rainbow') in out
assert os.path.join(os.sep, 'rainbow', 'config', 'builtin') in out
================================================
FILE: tests/command/test_stdin.py
================================================
# ----------------------------------------------------------------------
# rainbow, a terminal colorizer - https://github.com/nicoulaj/rainbow
# copyright (c) 2010-2018 rainbow contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# ----------------------------------------------------------------------
import os
import signal
from threading import Timer
import pytest
from rainbow import ansi
from rainbow.command.stdin import STDINCommand
from tests.test_utils import stdin_empty_all_variants, stdin_from_string_all_variants, stdin_from_file_all_variants, \
stdin_pipe
@pytest.mark.parametrize("stdin", stdin_empty_all_variants(), ids=str)
def test_empty(capfd, stdin):
with stdin:
assert STDINCommand().run() == 0
out, err = capfd.readouterr()
assert out == ansi.ANSI_RESET_ALL
assert err == ''
@pytest.mark.parametrize("stdin", stdin_from_string_all_variants('line\n'), ids=str)
def test_one_line(capfd, stdin):
with stdin:
assert STDINCommand().run() == 0
out, err = capfd.readouterr()
assert out == 'line\n' + ansi.ANSI_RESET_ALL
assert err == ''
@pytest.mark.parametrize("stdin", stdi
gitextract_f35q6phd/ ├── .codeclimate.yml ├── .coveragerc ├── .editorconfig ├── .github/ │ ├── dependabot.yml │ └── workflows/ │ ├── benchmarks.yml │ ├── lint.yml │ ├── packages.yml │ └── tests.yml ├── .gitignore ├── CONTRIBUTING.md ├── COPYING ├── MANIFEST.in ├── README.rst ├── rainbow/ │ ├── __init__.py │ ├── __main__.py │ ├── ansi.py │ ├── build.py │ ├── cli.py │ ├── command/ │ │ ├── __init__.py │ │ ├── execute.py │ │ ├── noop.py │ │ ├── print_config_names.py │ │ ├── print_path.py │ │ └── stdin.py │ ├── config/ │ │ ├── __init__.py │ │ ├── builtin/ │ │ │ ├── df.cfg │ │ │ ├── diff.cfg │ │ │ ├── env.cfg │ │ │ ├── host.cfg │ │ │ ├── ifconfig.cfg │ │ │ ├── java-stack-trace.cfg │ │ │ ├── jboss.cfg │ │ │ ├── md5sum.cfg │ │ │ ├── mvn.cfg │ │ │ ├── ping.cfg │ │ │ ├── tcpdump.cfg │ │ │ ├── tomcat.cfg │ │ │ └── traceroute.cfg │ │ ├── loader.py │ │ ├── locator.py │ │ └── parser.py │ ├── filter.py │ └── transformer.py ├── scripts/ │ └── rainbow ├── setup.cfg ├── setup.py ├── templates/ │ ├── completion.bash │ ├── completion.zsh │ └── rainbow.man ├── tests/ │ ├── __init__.py │ ├── command/ │ │ ├── __init__.py │ │ ├── test_execute.py │ │ ├── test_noop.py │ │ ├── test_print_config_names.py │ │ ├── test_print_path.py │ │ └── test_stdin.py │ ├── config/ │ │ ├── __init__.py │ │ ├── test_builtin.py │ │ ├── test_loader.py │ │ ├── test_locator.py │ │ └── test_parser.py │ ├── data/ │ │ ├── UTF-8-test.txt │ │ ├── cfg/ │ │ │ ├── config001.cfg │ │ │ ├── config002.cfg │ │ │ ├── config003.cfg │ │ │ ├── config004.cfg │ │ │ ├── config005.cfg │ │ │ ├── config006.cfg │ │ │ ├── config007.cfg │ │ │ ├── config008.cfg │ │ │ ├── config009.cfg │ │ │ ├── config010.cfg │ │ │ ├── config011.cfg │ │ │ ├── config012.cfg │ │ │ ├── config013.cfg │ │ │ ├── config014.cfg │ │ │ ├── config015.cfg │ │ │ ├── config016.cfg │ │ │ ├── config017.cfg │ │ │ ├── config018.cfg │ │ │ ├── config019.cfg │ │ │ ├── config020.cfg │ │ │ ├── config021.cfg │ │ │ ├── config022.cfg │ │ │ ├── config023.cfg │ │ │ ├── config024.cfg │ │ │ ├── config025.cfg │ │ │ ├── config026.cfg │ │ │ ├── config027.cfg │ │ │ ├── config028.cfg │ │ │ ├── config029.cfg │ │ │ ├── config030.cfg │ │ │ └── config031.cfg │ │ └── ref/ │ │ ├── df-001.log │ │ ├── df-001.log.out │ │ ├── df-002.log │ │ ├── df-002.log.out │ │ ├── diff-001.log │ │ ├── diff-001.log.out │ │ ├── diff-002.log │ │ ├── diff-002.log.out │ │ ├── diff-003.log │ │ ├── diff-003.log.out │ │ ├── env-001.log │ │ ├── env-001.log.out │ │ ├── host-001.log │ │ ├── host-001.log.out │ │ ├── host-002.log │ │ ├── host-002.log.out │ │ ├── ifconfig-001.log │ │ ├── ifconfig-001.log.out │ │ ├── ifconfig-002.log │ │ ├── ifconfig-002.log.out │ │ ├── java-stack-trace-001.log │ │ ├── java-stack-trace-001.log.out │ │ ├── jboss-001.log │ │ ├── jboss-001.log.out │ │ ├── md5sum-001.log │ │ ├── md5sum-001.log.out │ │ ├── md5sum-002.log │ │ ├── md5sum-002.log.out │ │ ├── mvn-001.log │ │ ├── mvn-001.log.out │ │ ├── mvn-002.log │ │ ├── mvn-002.log.out │ │ ├── mvn-003.log │ │ ├── mvn-003.log.out │ │ ├── mvn-004.log │ │ ├── mvn-004.log.out │ │ ├── ping-001.log │ │ ├── ping-001.log.out │ │ ├── ping-002.log │ │ ├── ping-002.log.out │ │ ├── tcpdump-001.log │ │ ├── tcpdump-001.log.out │ │ ├── tomcat-001.log │ │ ├── tomcat-001.log.out │ │ ├── traceroute-001.log │ │ ├── traceroute-001.log.out │ │ ├── traceroute-002.log │ │ └── traceroute-002.log.out │ ├── test_build.py │ ├── test_cli.py │ ├── test_filters.py │ ├── test_main.py │ ├── test_performance.py │ ├── test_rainbow.py │ ├── test_transformer.py │ └── test_utils.py └── tox.ini
SYMBOL INDEX (367 symbols across 30 files)
FILE: rainbow/__main__.py
function main (line 29) | def main(args=None):
FILE: rainbow/build.py
class Build (line 34) | class Build(build): # no cover
method run (line 35) | def run(self):
class Clean (line 42) | class Clean(clean): # no cover
method __init__ (line 44) | def __init__(self, dist):
method initialize_options (line 50) | def initialize_options(self):
method finalize_options (line 54) | def finalize_options(self):
method run (line 59) | def run(self):
class GenerateCompletion (line 72) | class GenerateCompletion(Command):
method initialize_options (line 80) | def initialize_options(self):
method finalize_options (line 84) | def finalize_options(self):
method run (line 90) | def run(self):
class GenerateManPage (line 105) | class GenerateManPage(Command):
method initialize_options (line 112) | def initialize_options(self):
method finalize_options (line 115) | def finalize_options(self):
method run (line 119) | def run(self):
function makeparentdirs (line 146) | def makeparentdirs(path):
FILE: rainbow/cli.py
class CommandLineParser (line 33) | class CommandLineParser(OptionParser):
method __init__ (line 34) | def __init__(self,
method parse_args (line 97) | def parse_args(self, args=None, values=None):
method _process_args (line 116) | def _process_args(self, largs, rargs, values):
method exit (line 126) | def exit(self, status=0, msg=None):
method error (line 131) | def error(self, msg):
method handle_config_option (line 134) | def handle_config_option(self, option, opt, value, parser):
method handle_pattern_option (line 137) | def handle_pattern_option(self, option, opt, value, parser):
method handle_verbosity_option (line 144) | def handle_verbosity_option(option, opt, value, parser):
method handle_print_path_option (line 147) | def handle_print_path_option(self, option, opt, value, parser):
method handle_print_config_names_option (line 151) | def handle_print_config_names_option(self, option, opt, value, parser):
method print_help (line 155) | def print_help(self, file=None):
method print_version (line 159) | def print_version(self, file=None):
FILE: rainbow/command/execute.py
class ExecuteCommand (line 34) | class ExecuteCommand(object):
method __init__ (line 35) | def __init__(self,
method encode (line 45) | def encode(self, string):
method decode (line 48) | def decode(self, bytes):
method run (line 51) | def run(self):
FILE: rainbow/command/noop.py
class NoOpCommand (line 20) | class NoOpCommand(object):
method __init__ (line 21) | def __init__(self, exit_code=0):
method run (line 24) | def run(self):
FILE: rainbow/command/print_config_names.py
class PrintConfigNamesCommand (line 22) | class PrintConfigNamesCommand(object):
method __init__ (line 23) | def __init__(self, paths=None):
method run (line 26) | def run(self):
FILE: rainbow/command/print_path.py
class PrintPathCommand (line 22) | class PrintPathCommand(object):
method __init__ (line 23) | def __init__(self, paths=None):
method run (line 26) | def run(self):
FILE: rainbow/command/stdin.py
class STDINCommand (line 28) | class STDINCommand(object):
method __init__ (line 29) | def __init__(self,
method run (line 35) | def run(self):
FILE: rainbow/config/loader.py
class ConfigLoader (line 44) | class ConfigLoader(object):
method __init__ (line 45) | def __init__(self,
method load_config_by_name (line 54) | def load_config_by_name(self, config):
method load_config_from_command_line (line 61) | def load_config_from_command_line(self, command_line_args):
method find_config_name_from_command_line (line 71) | def find_config_name_from_command_line(command_line_args):
FILE: rainbow/config/locator.py
class ConfigLocator (line 25) | class ConfigLocator(object):
method __init__ (line 26) | def __init__(self, paths=None):
method locate_config_file (line 29) | def locate_config_file(self, config, working_directory=None):
method locate_config_file_in_directory (line 49) | def locate_config_file_in_directory(directory, config):
FILE: rainbow/config/parser.py
class ConfigParser (line 32) | class ConfigParser(object):
method __init__ (line 33) | def __init__(self,
method parse_file (line 43) | def parse_file(self, config_file):
FILE: rainbow/filter.py
class Filter (line 22) | class Filter(object):
method __init__ (line 23) | def __init__(self, name, help, short_option=None, long_option=None, be...
method __str__ (line 31) | def __str__(self):
class FilterGroup (line 35) | class FilterGroup(object):
method __init__ (line 36) | def __init__(self, name, help, filters):
method __str__ (line 41) | def __str__(self):
FILE: rainbow/transformer.py
class IdentityTransformer (line 25) | class IdentityTransformer(object):
method __init__ (line 26) | def __init__(self):
method transform (line 29) | def transform(self, line):
method __str__ (line 32) | def __str__(self):
method __eq__ (line 35) | def __eq__(self, other):
class ReplaceTransformer (line 39) | class ReplaceTransformer(IdentityTransformer):
method __init__ (line 40) | def __init__(self, value, replacement):
method transform (line 45) | def transform(self, line):
method __str__ (line 48) | def __str__(self):
method __eq__ (line 51) | def __eq__(self, other):
class ReplaceRegexTransformer (line 55) | class ReplaceRegexTransformer(IdentityTransformer):
method __init__ (line 56) | def __init__(self, regex, replacement):
method transform (line 61) | def transform(self, line):
method __str__ (line 64) | def __str__(self):
method __eq__ (line 67) | def __eq__(self, other):
class InsertBeforeRegexTransformer (line 71) | class InsertBeforeRegexTransformer(IdentityTransformer):
method __init__ (line 72) | def __init__(self, regex, before):
method transform (line 77) | def transform(self, line):
method __str__ (line 80) | def __str__(self):
method __eq__ (line 83) | def __eq__(self, other):
class InsertAfterRegexTransformer (line 87) | class InsertAfterRegexTransformer(IdentityTransformer):
method __init__ (line 88) | def __init__(self, regex, after):
method transform (line 93) | def transform(self, line):
method __str__ (line 96) | def __str__(self):
method __eq__ (line 99) | def __eq__(self, other):
class InsertBeforeAndAfterRegexTransformer (line 103) | class InsertBeforeAndAfterRegexTransformer(IdentityTransformer):
method __init__ (line 104) | def __init__(self, regex, before, after):
method transform (line 110) | def transform(self, line):
method __str__ (line 113) | def __str__(self):
method __eq__ (line 116) | def __eq__(self, other):
class ListTransformer (line 121) | class ListTransformer(IdentityTransformer):
method __init__ (line 122) | def __init__(self, transformers):
method transform (line 126) | def transform(self, line):
method __str__ (line 131) | def __str__(self):
method __eq__ (line 134) | def __eq__(self, other):
class DummyTransformerBuilder (line 138) | class DummyTransformerBuilder(object):
method __init__ (line 139) | def __init__(self):
method add_mapping (line 142) | def add_mapping(self, pattern, filter):
method build (line 145) | def build(self):
class TransformerBuilder (line 149) | class TransformerBuilder(DummyTransformerBuilder):
method add_mapping (line 151) | def add_mapping(self, pattern, filter):
method make_transformer (line 156) | def make_transformer(regex, filter):
method build (line 167) | def build(self):
FILE: tests/command/test_execute.py
function test_true (line 34) | def test_true(capfd, stdin):
function test_false (line 43) | def test_false(capfd, stdin):
function test_identity (line 52) | def test_identity(capfd, stdin):
function test_identity_no_newline (line 69) | def test_identity_no_newline(capfd, stdin):
function test_identity_partial_line (line 86) | def test_identity_partial_line(capfd, stdin):
function test_identity_overwritten_line (line 109) | def test_identity_overwritten_line(capfd, stdin):
function test_identity_bash (line 134) | def test_identity_bash(capfd, stdin):
function test_identity_mixed_stdin_and_err (line 143) | def test_identity_mixed_stdin_and_err(capfd, stdin):
function test_bufferized_output (line 162) | def test_bufferized_output(capfd, stdin):
function test_bufferized_partial_lines (line 182) | def test_bufferized_partial_lines(capfd, stdin):
function test_unflushed_output (line 199) | def test_unflushed_output(capfd, stdin):
function test_cat_stdin (line 215) | def test_cat_stdin(capfd, stdin):
function test_cat_stdin_two_lines (line 226) | def test_cat_stdin_two_lines(capfd, stdin):
function test_stdout_transformer (line 235) | def test_stdout_transformer(capfd, stdin):
function test_stdout_transformer_bash (line 251) | def test_stdout_transformer_bash(capfd, stdin):
function test_stderr_transformer (line 263) | def test_stderr_transformer(capfd, stdin):
function test_stderr_transformer_bash (line 279) | def test_stderr_transformer_bash(capfd, stdin):
function test_stdout_and_stderr_transformers (line 291) | def test_stdout_and_stderr_transformers(capfd, stdin):
function test_stdout_and_stderr_transformers_bash (line 308) | def test_stdout_and_stderr_transformers_bash(capfd, stdin):
function test_read_bash (line 323) | def test_read_bash(capfd, stdin):
function test_interrupted (line 335) | def test_interrupted(stdin):
function test_malformed_utf8 (line 342) | def test_malformed_utf8(stdin):
FILE: tests/command/test_noop.py
function test_noop (line 24) | def test_noop(capsys):
function test_noop_with_exit_code (line 32) | def test_noop_with_exit_code(capsys, exit_code):
FILE: tests/command/test_print_config_names.py
function test_empty_path (line 23) | def test_empty_path(capsys):
function test_default_path (line 30) | def test_default_path(capsys):
FILE: tests/command/test_print_path.py
function test_empty_path (line 25) | def test_empty_path(capsys):
function test_default_path (line 32) | def test_default_path(capsys):
FILE: tests/command/test_stdin.py
function test_empty (line 32) | def test_empty(capfd, stdin):
function test_one_line (line 41) | def test_one_line(capfd, stdin):
function test_several_lines (line 50) | def test_several_lines(capfd, stdin):
function test_interrupted (line 58) | def test_interrupted(capfd):
function test_malformed_utf8 (line 68) | def test_malformed_utf8(stdin):
FILE: tests/config/test_builtin.py
function load_builtin_config (line 46) | def load_builtin_config(config):
function test_generate_flag_has_not_been_committed (line 57) | def test_generate_flag_has_not_been_committed():
function test_config_has_at_least_one_reference (line 62) | def test_config_has_at_least_one_reference(config):
function test_config_loads_without_errors (line 67) | def test_config_loads_without_errors(config):
function test_config_by_reference (line 73) | def test_config_by_reference(test):
FILE: tests/config/test_loader.py
function load_by_name (line 26) | def load_by_name(config):
function load_from_command_line (line 40) | def load_from_command_line(args):
function test_load_unresolvable_config_file (line 54) | def test_load_unresolvable_config_file():
function test_load_empty_config_file (line 59) | def test_load_empty_config_file():
function test_load_empty_config_file_from_command_line (line 66) | def test_load_empty_config_file_from_command_line():
function test_find_config_name_from_command_line_empty_args (line 73) | def test_find_config_name_from_command_line_empty_args():
function test_find_config_name_from_command_line_one_arg (line 77) | def test_find_config_name_from_command_line_one_arg():
function test_find_config_name_from_command_line_several_args (line 81) | def test_find_config_name_from_command_line_several_args():
function test_find_config_name_from_command_line_full_path (line 85) | def test_find_config_name_from_command_line_full_path():
function test_find_config_name_from_command_line_precommand (line 90) | def test_find_config_name_from_command_line_precommand(precommand):
function test_find_config_name_from_command_line_precommand_with_args (line 95) | def test_find_config_name_from_command_line_precommand_with_args(precomm...
function test_find_config_name_from_command_line_full_path_precommand (line 100) | def test_find_config_name_from_command_line_full_path_precommand(precomm...
function test_find_config_name_from_command_line_full_path_precommand_with_args (line 105) | def test_find_config_name_from_command_line_full_path_precommand_with_ar...
FILE: tests/config/test_locator.py
function test_locate_config_file_empty_path (line 22) | def test_locate_config_file_empty_path():
function test_locate_inexistent_config_file_empty_path (line 26) | def test_locate_inexistent_config_file_empty_path():
function test_locate_config_file_none_in_path (line 30) | def test_locate_config_file_none_in_path():
function test_locate_inexistent_config_file_none_in_path (line 34) | def test_locate_inexistent_config_file_none_in_path():
function test_locate_config_file_path_without_extension (line 38) | def test_locate_config_file_path_without_extension():
function test_locate_config_file_path (line 42) | def test_locate_config_file_path():
function test_locate_config_file_filename (line 46) | def test_locate_config_file_filename():
function test_locate_config_file_filename_without_extension (line 50) | def test_locate_config_file_filename_without_extension():
function test_locate_config_file_in_directory_filename (line 54) | def test_locate_config_file_in_directory_filename():
function test_locate_config_file_in_directory_filename_without_extension (line 59) | def test_locate_config_file_in_directory_filename_without_extension():
FILE: tests/config/test_parser.py
function parse (line 31) | def parse(config):
function test_parse_inexistent_config (line 45) | def test_parse_inexistent_config():
function test_parse_empty_config (line 50) | def test_parse_empty_config():
function test_parse_empty_filters_section (line 57) | def test_parse_empty_filters_section():
function test_parse_empty_general_section (line 64) | def test_parse_empty_general_section():
function test_parse_empty_filters_and_general_sections (line 71) | def test_parse_empty_filters_and_general_sections():
function test_parse_two_empty_filters_sections (line 79) | def test_parse_two_empty_filters_sections():
function test_parse_one_filter (line 86) | def test_parse_one_filter():
function test_parse_two_different_filters (line 99) | def test_parse_two_different_filters():
function test_parse_two_times_same_filter (line 123) | def test_parse_two_times_same_filter():
function test_parse_filter_in_global_section (line 147) | def test_parse_filter_in_global_section():
function test_parse_one_filter_and_stderr_setting_enabled (line 154) | def test_parse_one_filter_and_stderr_setting_enabled():
function test_parse_one_filter_and_stderr_setting_enabled_uppercase (line 167) | def test_parse_one_filter_and_stderr_setting_enabled_uppercase():
function test_parse_one_filter_and_stderr_setting_disabled (line 180) | def test_parse_one_filter_and_stderr_setting_disabled():
function test_parse_one_filter_and_stderr_setting_disabled_uppercase (line 190) | def test_parse_one_filter_and_stderr_setting_disabled_uppercase():
function test_parse_one_filter_and_stderr_setting_disabled_with_no (line 200) | def test_parse_one_filter_and_stderr_setting_disabled_with_no():
function test_parse_one_filter_uppercase (line 210) | def test_parse_one_filter_uppercase():
function test_parse_one_filter_extra_spaces_before_regex (line 223) | def test_parse_one_filter_extra_spaces_before_regex():
function test_parse_unknown_filter (line 236) | def test_parse_unknown_filter():
function test_parse_unresolved_import (line 243) | def test_parse_unresolved_import():
function test_parse_unresolved_import_and_valid_filter (line 250) | def test_parse_unresolved_import_and_valid_filter():
function test_parse_relative_import_without_extension (line 263) | def test_parse_relative_import_without_extension():
function test_parse_relative_import_with_extension (line 276) | def test_parse_relative_import_with_extension():
function test_parse_invalid_key_in_general_section (line 289) | def test_parse_invalid_key_in_general_section():
function test_parse_two_times_same_filter_once_in_config_once_in_import (line 296) | def test_parse_two_times_same_filter_once_in_config_once_in_import():
function test_parse_multiple_relative_imports_without_extension (line 319) | def test_parse_multiple_relative_imports_without_extension():
function test_parse_filter_using_filter_name (line 332) | def test_parse_filter_using_filter_name():
function test_parse_filter_with_empty_pattern (line 345) | def test_parse_filter_with_empty_pattern():
function test_parse_empty_imports_section (line 352) | def test_parse_empty_imports_section():
function test_parse_multiple_imports_with_empty_one (line 359) | def test_parse_multiple_imports_with_empty_one():
function test_parse_invalid_section (line 366) | def test_parse_invalid_section():
function test_parse_invalid_stderr_filtering_value (line 373) | def test_parse_invalid_stderr_filtering_value():
FILE: tests/test_build.py
function generate_completion (line 30) | def generate_completion(request, shell):
function test_completion_filter_included (line 40) | def test_completion_filter_included(request, shell):
function test_completion_ends_with_new_line (line 49) | def test_completion_ends_with_new_line(request, shell):
function generate_man_page (line 54) | def generate_man_page(request):
function test_manpage_filter_group_included (line 62) | def test_manpage_filter_group_included(request):
function test_manpage_filter_included (line 69) | def test_manpage_filter_included(request):
function test_manpage_ends_with_new_line (line 78) | def test_manpage_ends_with_new_line(request):
FILE: tests/test_cli.py
function parse (line 35) | def parse(args, stdout_builder=None, stderr_builder=None):
function test_empty_args (line 48) | def test_empty_args():
function test_filter_short_option (line 56) | def test_filter_short_option(filter):
function test_filter_long_option (line 64) | def test_filter_long_option(filter):
function test_filter_short_option_without_value (line 72) | def test_filter_short_option_without_value(filter):
function test_filter_long_option_without_value (line 80) | def test_filter_long_option_without_value(filter):
function test_command (line 87) | def test_command():
function test_command_remaining_args_separator (line 96) | def test_command_remaining_args_separator():
function test_command_with_option (line 105) | def test_command_with_option():
function test_command_with_option_remaining_args_separator (line 114) | def test_command_with_option_remaining_args_separator():
function test_command_that_looks_like_a_short_option (line 123) | def test_command_that_looks_like_a_short_option():
function test_command_that_looks_like_a_short_option_remaining_args_separator (line 132) | def test_command_that_looks_like_a_short_option_remaining_args_separator():
function test_command_that_looks_like_a_long_option (line 141) | def test_command_that_looks_like_a_long_option():
function test_command_that_looks_like_a_long_option_remaining_args_separator (line 150) | def test_command_that_looks_like_a_long_option_remaining_args_separator():
function test_command_with_long_option_filter (line 160) | def test_command_with_long_option_filter(filter):
function test_command_with_short_option_filter (line 171) | def test_command_with_short_option_filter(filter):
function test_command_remaining_args_separator_with_long_option_filter (line 182) | def test_command_remaining_args_separator_with_long_option_filter(filter):
function test_command_remaining_args_separator_with_short_option_filter (line 193) | def test_command_remaining_args_separator_with_short_option_filter(filter):
function test_command_with_option_with_long_option_filter (line 204) | def test_command_with_option_with_long_option_filter(filter):
function test_command_with_option_with_short_option_filter (line 215) | def test_command_with_option_with_short_option_filter(filter):
function test_command_with_option_remaining_args_separator_with_long_option_filter (line 226) | def test_command_with_option_remaining_args_separator_with_long_option_f...
function test_command_with_option_remaining_args_separator_with_short_option_filter (line 237) | def test_command_with_option_remaining_args_separator_with_short_option_...
function test_command_with_same_option_as_rainbow (line 247) | def test_command_with_same_option_as_rainbow():
function test_command_with_same_option_as_rainbow_remaining_args_separator (line 256) | def test_command_with_same_option_as_rainbow_remaining_args_separator():
function test_unresolvable_config_file_short_option (line 265) | def test_unresolvable_config_file_short_option():
function test_unresolvable_config_file_long_option (line 271) | def test_unresolvable_config_file_long_option():
function test_config_file_by_relative_path_short_option (line 277) | def test_config_file_by_relative_path_short_option():
function test_config_file_by_relative_path_without_extension_short_option (line 285) | def test_config_file_by_relative_path_without_extension_short_option():
function test_config_file_by_relative_path_long_option (line 293) | def test_config_file_by_relative_path_long_option():
function test_config_file_by_relative_path_without_extension_long_option (line 301) | def test_config_file_by_relative_path_without_extension_long_option():
function test_dummy_transfomer_builder (line 309) | def test_dummy_transfomer_builder():
function test_verbose_short_option (line 320) | def test_verbose_short_option():
function test_verbose_long_option (line 331) | def test_verbose_long_option():
function test_verbose_twice_short_option (line 342) | def test_verbose_twice_short_option():
function test_verbose_twice_long_option (line 353) | def test_verbose_twice_long_option():
function test_print_path (line 364) | def test_print_path():
function test_print_path_with_extra_args (line 371) | def test_print_path_with_extra_args():
function test_print_config_names (line 378) | def test_print_config_names():
function test_print_config_names_with_extra_args (line 385) | def test_print_config_names_with_extra_args():
function test_version (line 392) | def test_version():
function test_help (line 399) | def test_help():
FILE: tests/test_filters.py
function test_filter_group_has_name (line 29) | def test_filter_group_has_name(filter_group):
function test_filter_group_has_help (line 34) | def test_filter_group_has_help(filter_group):
function test_filter_group_has_filters (line 39) | def test_filter_group_has_filters(filter_group):
function test_filter_group_has_a_unique_name (line 44) | def test_filter_group_has_a_unique_name(filter_group_name):
function test_filter_group_name_syntax (line 49) | def test_filter_group_name_syntax(filter_group_name):
function test_filter_group_has_a_unique_help (line 54) | def test_filter_group_has_a_unique_help(filter_group_help):
function test_filter_group_help_syntax (line 59) | def test_filter_group_help_syntax(filter_group_help):
function test_filter_group_has_unique_list_of_filters (line 64) | def test_filter_group_has_unique_list_of_filters(filter_group_filters):
function test_filter_has_name (line 69) | def test_filter_has_name(filter):
function test_filter_has_help (line 74) | def test_filter_has_help(filter):
function test_filter_has_long_option (line 79) | def test_filter_has_long_option(filter):
function test_filter_has_before_or_after (line 84) | def test_filter_has_before_or_after(filter):
function test_filter_has_a_unique_name (line 89) | def test_filter_has_a_unique_name(filter_name):
function test_filter_name_syntax (line 94) | def test_filter_name_syntax(filter_name):
function test_filter_has_a_unique_help (line 99) | def test_filter_has_a_unique_help(filter_help):
function test_filter_help_syntax (line 104) | def test_filter_help_syntax(filter_help):
function test_filter_has_a_unique_short_option (line 109) | def test_filter_has_a_unique_short_option(filter_short_option):
function test_filter_short_option_syntax (line 114) | def test_filter_short_option_syntax(filter_short_option):
function test_filter_has_a_unique_long_option (line 119) | def test_filter_has_a_unique_long_option(filter_long_option):
function test_filter_long_option_syntax (line 124) | def test_filter_long_option_syntax(filter_long_option):
FILE: tests/test_main.py
function test_true (line 34) | def test_true(capfd, stdin):
function test_false (line 43) | def test_false(capfd, stdin):
function test_warning (line 52) | def test_warning(capfd, stdin):
function test_error (line 62) | def test_error(capfd, stdin, filter):
function test_stacktrace (line 74) | def test_stacktrace(capfd, stdin):
function test_read_from_stdin (line 83) | def test_read_from_stdin(capfd, stdin):
function test_malformed_utf8_from_command (line 92) | def test_malformed_utf8_from_command(stdin):
function test_malformed_utf8_from_command_with_filters (line 98) | def test_malformed_utf8_from_command_with_filters(stdin):
function test_malformed_utf8_from_stdin (line 104) | def test_malformed_utf8_from_stdin(stdin):
function test_malformed_utf8_from_stdin_with_filters (line 110) | def test_malformed_utf8_from_stdin_with_filters(stdin):
FILE: tests/test_performance.py
function test_invoke_command (line 23) | def test_invoke_command(benchmark):
function test_invoke_python (line 32) | def test_invoke_python(benchmark):
function test_python_invoke_command (line 41) | def test_python_invoke_command(benchmark):
function test_rainbow_no_matching_config (line 53) | def test_rainbow_no_matching_config(benchmark):
function test_rainbow_config_by_path_empty (line 62) | def test_rainbow_config_by_path_empty(benchmark):
function test_rainbow_config_by_path_many_filters (line 71) | def test_rainbow_config_by_path_many_filters(benchmark):
FILE: tests/test_rainbow.py
function test_true (line 32) | def test_true(capfd, stdin):
function test_false (line 41) | def test_false(capfd, stdin):
function test_read_from_stdin (line 50) | def test_read_from_stdin(capfd, stdin):
function test_malformed_utf8_from_command (line 59) | def test_malformed_utf8_from_command(stdin):
function test_malformed_utf8_from_stdin (line 65) | def test_malformed_utf8_from_stdin(stdin):
function test_version (line 71) | def test_version(capfd, stdin):
function test_help_filter_group (line 80) | def test_help_filter_group(capfd, stdin):
function test_help_filter_included (line 91) | def test_help_filter_included(capfd, stdin):
FILE: tests/test_transformer.py
function test_identity (line 34) | def test_identity():
function test_replace_not_matching (line 38) | def test_replace_not_matching():
function test_replace_matching (line 42) | def test_replace_matching():
function test_replace_multiples_matches (line 46) | def test_replace_multiples_matches():
function test_replace_regex_not_matching (line 50) | def test_replace_regex_not_matching():
function test_replace_regex_matching (line 54) | def test_replace_regex_matching():
function test_replace_regex_multiples_matches (line 58) | def test_replace_regex_multiples_matches():
function test_before_whole_line_matches (line 62) | def test_before_whole_line_matches():
function test_after_whole_line_matches (line 66) | def test_after_whole_line_matches():
function test_before_and_after_whole_line_matches (line 70) | def test_before_and_after_whole_line_matches():
function test_before_partial_line_matches (line 75) | def test_before_partial_line_matches():
function test_after_partial_line_matches (line 79) | def test_after_partial_line_matches():
function test_before_and_after_partial_line_matches (line 83) | def test_before_and_after_partial_line_matches():
function test_before_several_matches (line 88) | def test_before_several_matches():
function test_after_several_matches (line 93) | def test_after_several_matches():
function test_before_and_after_several_matches (line 98) | def test_before_and_after_several_matches():
function test_before_only_match_whole_line (line 103) | def test_before_only_match_whole_line():
function test_after_only_match_whole_line (line 108) | def test_after_only_match_whole_line():
function test_before_and_after_only_match_whole_line (line 113) | def test_before_and_after_only_match_whole_line():
function test_list_transformer (line 118) | def test_list_transformer():
function test_dummy_transformer_builder (line 125) | def test_dummy_transformer_builder():
function test_transformer_builder (line 133) | def test_transformer_builder():
function test_transformer_identity_str (line 152) | def test_transformer_identity_str():
function test_transformer_replace_str (line 156) | def test_transformer_replace_str():
function test_transformer_replace_regex_str (line 160) | def test_transformer_replace_regex_str():
function test_transformer_before_str (line 164) | def test_transformer_before_str():
function test_transformer_after_str (line 168) | def test_transformer_after_str():
function test_transformer_before_and_after_str (line 172) | def test_transformer_before_and_after_str():
function test_transformer_list_str (line 177) | def test_transformer_list_str():
function test_transformer_identity_eq (line 184) | def test_transformer_identity_eq():
function test_transformer_replace_eq (line 188) | def test_transformer_replace_eq():
function test_transformer_replace_regex_eq (line 192) | def test_transformer_replace_regex_eq():
function test_transformer_before_eq (line 197) | def test_transformer_before_eq():
function test_transformer_after_eq (line 202) | def test_transformer_after_eq():
function test_transformer_before_and_after_eq (line 207) | def test_transformer_before_and_after_eq():
function test_transformer_list_eq (line 213) | def test_transformer_list_eq():
function test_transformer_replace_not_eq (line 223) | def test_transformer_replace_not_eq():
function test_transformer_replace_regex_not_eq (line 227) | def test_transformer_replace_regex_not_eq():
function test_transformer_before_not_eq (line 232) | def test_transformer_before_not_eq():
function test_transformer_after_not_eq (line 237) | def test_transformer_after_not_eq():
function test_transformer_before_and_after_not_eq (line 242) | def test_transformer_before_and_after_not_eq():
function test_transformer_list_not_eq (line 248) | def test_transformer_list_not_eq():
FILE: tests/test_utils.py
function run (line 61) | def run(command, pipe=True):
function run_python (line 74) | def run_python(script, pipe=True):
function run_rainbow (line 78) | def run_rainbow(args, pipe=True):
function stdin_empty (line 86) | def stdin_empty():
function stdin_pipe (line 90) | def stdin_pipe():
function stdin_empty_all_variants (line 94) | def stdin_empty_all_variants():
function stdin_from_file_all_variants (line 98) | def stdin_from_file_all_variants(path):
function stdin_from_string_all_variants (line 102) | def stdin_from_string_all_variants(contents):
class CustomStdin (line 107) | class CustomStdin:
method __init__ (line 108) | def __init__(self):
method __enter__ (line 111) | def __enter__(self):
method __exit__ (line 115) | def __exit__(self, type, value, traceback):
method setup (line 120) | def setup(self):
method teardown (line 123) | def teardown(self):
class FileStdin (line 127) | class FileStdin(CustomStdin):
method __init__ (line 128) | def __init__(self, path):
method setup (line 132) | def setup(self):
method __str__ (line 135) | def __str__(self):
class StringAsFileStdin (line 139) | class StringAsFileStdin(CustomStdin):
method __init__ (line 140) | def __init__(self, contents):
method setup (line 144) | def setup(self):
method __str__ (line 150) | def __str__(self):
class StringAsPipeStdin (line 154) | class StringAsPipeStdin(CustomStdin):
method __init__ (line 155) | def __init__(self, contents):
method setup (line 159) | def setup(self):
method __str__ (line 165) | def __str__(self):
class PipeStdin (line 169) | class PipeStdin(CustomStdin):
method __init__ (line 170) | def __init__(self):
method setup (line 174) | def setup(self):
method teardown (line 179) | def teardown(self):
method write (line 183) | def write(self, string):
method __str__ (line 186) | def __str__(self):
Condensed preview — 150 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,504K chars).
[
{
"path": ".codeclimate.yml",
"chars": 1134,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": ".coveragerc",
"chars": 987,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": ".editorconfig",
"chars": 1102,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": ".github/dependabot.yml",
"chars": 202,
"preview": "version: 2\n\nupdates:\n\n - package-ecosystem: \"github-actions\"\n directory: \"/\"\n schedule:\n interval: weekly\n\n "
},
{
"path": ".github/workflows/benchmarks.yml",
"chars": 484,
"preview": "name: Benchmarks\n\non: [push, pull_request]\n\njobs:\n benchmark:\n\n name: 'benchmarks'\n\n runs-on: 'ubuntu-latest'\n\n "
},
{
"path": ".github/workflows/lint.yml",
"chars": 457,
"preview": "name: Lint\n\non: [push, pull_request]\n\njobs:\n lint:\n\n name: 'lint'\n\n runs-on: 'ubuntu-latest'\n\n steps:\n - "
},
{
"path": ".github/workflows/packages.yml",
"chars": 832,
"preview": "name: Packages\n\non:\n push:\n pull_request:\n release:\n types: [released]\n\njobs:\n\n python-packages:\n\n name: 'whee"
},
{
"path": ".github/workflows/tests.yml",
"chars": 1266,
"preview": "name: Tests\n\non: [push, pull_request]\n\njobs:\n test:\n\n strategy:\n fail-fast: false\n matrix:\n os: [ '"
},
{
"path": ".gitignore",
"chars": 1090,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "CONTRIBUTING.md",
"chars": 19360,
"preview": "Contributing\n============\n\nContributions are welcome, please take a look at the [issues list](https://github.com/nicoula"
},
{
"path": "COPYING",
"chars": 35068,
"preview": "\n\t\t GNU GENERAL PUBLIC LICENSE\n\t\t Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <"
},
{
"path": "MANIFEST.in",
"chars": 1006,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "README.rst",
"chars": 3697,
"preview": "rainbow\n=======\n\n.. image:: https://img.shields.io/github/tag/nicoulaj/rainbow.svg\n :target: https://pypi.org/project/"
},
{
"path": "rainbow/__init__.py",
"chars": 1784,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/__main__.py",
"chars": 2646,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/ansi.py",
"chars": 2489,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/build.py",
"chars": 4979,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/cli.py",
"chars": 7088,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/__init__.py",
"chars": 899,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/execute.py",
"chars": 4575,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/noop.py",
"chars": 1050,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/print_config_names.py",
"chars": 1302,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/print_path.py",
"chars": 1148,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/command/stdin.py",
"chars": 1867,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/__init__.py",
"chars": 899,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/df.cfg",
"chars": 1085,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/diff.cfg",
"chars": 1171,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/env.cfg",
"chars": 1129,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/host.cfg",
"chars": 1153,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/ifconfig.cfg",
"chars": 1134,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/java-stack-trace.cfg",
"chars": 1117,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/jboss.cfg",
"chars": 1516,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/md5sum.cfg",
"chars": 1103,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/mvn.cfg",
"chars": 1763,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/ping.cfg",
"chars": 1254,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/tcpdump.cfg",
"chars": 1091,
"preview": "[filters]\n# IPv4 address+port:\nreset-all-after: (\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,5}|\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\."
},
{
"path": "rainbow/config/builtin/tomcat.cfg",
"chars": 1308,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/builtin/traceroute.cfg",
"chars": 1158,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/loader.py",
"chars": 2596,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/locator.py",
"chars": 2246,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/config/parser.py",
"chars": 5145,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/filter.py",
"chars": 28856,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "rainbow/transformer.py",
"chars": 5677,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "scripts/rainbow",
"chars": 983,
"preview": "#!/usr/bin/python3\n# ----------------------------------------------------------------------\n# rainbow, a terminal colori"
},
{
"path": "setup.cfg",
"chars": 1262,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "setup.py",
"chars": 3220,
"preview": "#!/usr/bin/env python\n# ----------------------------------------------------------------------\n# rainbow, a terminal col"
},
{
"path": "templates/completion.bash",
"chars": 2739,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "templates/completion.zsh",
"chars": 2466,
"preview": "#compdef rainbow\n# ----------------------------------------------------------------------\n# rainbow, a terminal colorize"
},
{
"path": "templates/rainbow.man",
"chars": 3077,
"preview": ".TH RAINBOW 1\n\n\n.SH NAME\nrainbow \\- Colorize commands output using patterns.\n\n\n.SH SYNOPSIS\n.B rainbow\n[rainbow options."
},
{
"path": "tests/__init__.py",
"chars": 899,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/__init__.py",
"chars": 899,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/test_execute.py",
"chars": 13035,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/test_noop.py",
"chars": 1344,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/test_print_config_names.py",
"chars": 1608,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/test_print_path.py",
"chars": 1449,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/command/test_stdin.py",
"chars": 2505,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/config/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "tests/config/test_builtin.py",
"chars": 6689,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/config/test_loader.py",
"chars": 4193,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/config/test_locator.py",
"chars": 2659,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/config/test_parser.py",
"chars": 20165,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config001.cfg",
"chars": 899,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config002.cfg",
"chars": 910,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config003.cfg",
"chars": 910,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config004.cfg",
"chars": 921,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config005.cfg",
"chars": 920,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config006.cfg",
"chars": 921,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config007.cfg",
"chars": 934,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config008.cfg",
"chars": 931,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config009.cfg",
"chars": 911,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config010.cfg",
"chars": 961,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config011.cfg",
"chars": 961,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config012.cfg",
"chars": 962,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config013.cfg",
"chars": 962,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config014.cfg",
"chars": 921,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config015.cfg",
"chars": 926,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config016.cfg",
"chars": 921,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config017.cfg",
"chars": 923,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config018.cfg",
"chars": 945,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config019.cfg",
"chars": 929,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config020.cfg",
"chars": 933,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config021.cfg",
"chars": 919,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config022.cfg",
"chars": 953,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config023.cfg",
"chars": 940,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config024.cfg",
"chars": 932,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config025.cfg",
"chars": 915,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config026.cfg",
"chars": 919,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config027.cfg",
"chars": 942,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config028.cfg",
"chars": 906,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config029.cfg",
"chars": 938,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config030.cfg",
"chars": 960,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/cfg/config031.cfg",
"chars": 4977,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/data/ref/df-001.log",
"chars": 652,
"preview": "Filesystem 1K-blocks Used Available Use% Mounted on\ndev 8184284 0 8184284 0% /dev\nrun "
},
{
"path": "tests/data/ref/df-001.log.out",
"chars": 686,
"preview": "Filesystem 1K-blocks Used Available Use% Mounted on\ndev 8184284 0 8184284 0% /dev\nrun "
},
{
"path": "tests/data/ref/df-002.log",
"chars": 71,
"preview": "df: unrecognized option '--test'\nTry 'df --help' for more information.\n"
},
{
"path": "tests/data/ref/df-002.log.out",
"chars": 71,
"preview": "df: unrecognized option '--test'\nTry 'df --help' for more information.\n"
},
{
"path": "tests/data/ref/diff-001.log",
"chars": 81,
"preview": "diff: missing operand after 'diff'\ndiff: Try 'diff --help' for more information.\n"
},
{
"path": "tests/data/ref/diff-001.log.out",
"chars": 81,
"preview": "diff: missing operand after 'diff'\ndiff: Try 'diff --help' for more information.\n"
},
{
"path": "tests/data/ref/diff-002.log",
"chars": 2751,
"preview": "0a1\n> #!/usr/bin/env python\n19,25c20\n< [clean]\n< paths = .cache,\n< .tox,\n< build,\n< dist,\n< "
},
{
"path": "tests/data/ref/diff-002.log.out",
"chars": 2887,
"preview": "0a1\n> #!/usr/bin/env python\n19,25c20\n< [clean]\n< paths = .cache,\n< .tox,\n< build,\n< dist,\n< "
},
{
"path": "tests/data/ref/diff-003.log",
"chars": 3099,
"preview": "--- setup.cfg\t2017-03-18 22:27:04.430726575 +0100\n+++ setup.py\t2017-03-19 11:54:17.386754769 +0100\n@@ -1,3 +1,4 @@\n+#!/u"
},
{
"path": "tests/data/ref/diff-003.log.out",
"chars": 6053,
"preview": "[FOREGROUND_RED]--- setup.cfg\t2017-03-18 22:27:04.430726575 +0100[FOREGROUND_RESET]\n[FOREGROUND_GREEN]+++ setup.py\t2017-"
},
{
"path": "tests/data/ref/env-001.log",
"chars": 6692,
"preview": "LANG=C\nDISPLAY=:1\nSHLVL=1\nLOGNAME=nicoulaj\nXDG_VTNR=2\nFREETYPE_PROPERTIES=truetype:interpreter-version=38\nPWD=/home/nico"
},
{
"path": "tests/data/ref/env-001.log.out",
"chars": 64955,
"preview": "[FOREGROUND_BLUE][BOLD]LANG[FOREGROUND_RESET]=[RESET_INTENSITY][RESET_ALL]C[RESET_ALL]\n[FOREGROUND_BLUE][BOLD]DISPLAY[FO"
},
{
"path": "tests/data/ref/host-001.log",
"chars": 375,
"preview": "google.com has address 216.58.205.14\ngoogle.com has IPv6 address 2a00:1450:4007:80a::200e\ngoogle.com mail is handled by "
},
{
"path": "tests/data/ref/host-001.log.out",
"chars": 513,
"preview": "[BOLD]google.com has address 216.58.205.14[RESET_INTENSITY]\ngoogle.com has IPv6 address 2a00:1450:4007:80a::200e\n[BOLD]g"
},
{
"path": "tests/data/ref/host-002.log",
"chars": 45,
"preview": "Host wwwww.google.com not found: 3(NXDOMAIN)\n"
},
{
"path": "tests/data/ref/host-002.log.out",
"chars": 45,
"preview": "Host wwwww.google.com not found: 3(NXDOMAIN)\n"
},
{
"path": "tests/data/ref/ifconfig-001.log",
"chars": 1435,
"preview": "docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500\n inet 172.17.0.1 netmask 255.255.0.0 broadcast 0.0.0.0\n "
},
{
"path": "tests/data/ref/ifconfig-001.log.out",
"chars": 1519,
"preview": "[UNDERLINE]docker0:[RESET_UNDERLINE] flags=4099<UP,BROADCAST,MULTICAST> mtu 1500\n inet 172.17.0.1 netmask 255.2"
},
{
"path": "tests/data/ref/ifconfig-002.log",
"chars": 86,
"preview": "ifconfig: option `--test' not recognised.\nifconfig: `--help' gives usage information.\n"
},
{
"path": "tests/data/ref/ifconfig-002.log.out",
"chars": 142,
"preview": "[UNDERLINE]ifconfig:[RESET_UNDERLINE] option `--test' not recognised.\n[UNDERLINE]ifconfig:[RESET_UNDERLINE] `--help' giv"
},
{
"path": "tests/data/ref/java-stack-trace-001.log",
"chars": 256,
"preview": "Exception in thread \"main\" java.lang.NullPointerException\n at com.example.myproject.Book.getTitle(Book.java:16)\n "
},
{
"path": "tests/data/ref/java-stack-trace-001.log.out",
"chars": 392,
"preview": "[FOREGROUND_RED]Exception in thread \"main\" java.lang.NullPointerException[FOREGROUND_RESET]\n[FOREGROUND_RED] at c"
},
{
"path": "tests/data/ref/jboss-001.log",
"chars": 0,
"preview": ""
},
{
"path": "tests/data/ref/jboss-001.log.out",
"chars": 0,
"preview": ""
},
{
"path": "tests/data/ref/md5sum-001.log",
"chars": 43,
"preview": "0bc2ee1037199736ad2b8b144f7834f1 setup.py\n"
},
{
"path": "tests/data/ref/md5sum-001.log.out",
"chars": 67,
"preview": "[FAINT]0bc2ee1037199736ad2b8b144f7834f1[RESET_INTENSITY] setup.py\n"
},
{
"path": "tests/data/ref/md5sum-002.log",
"chars": 45,
"preview": "md5sum: setup.pyy: No such file or directory\n"
},
{
"path": "tests/data/ref/md5sum-002.log.out",
"chars": 69,
"preview": "[FAINT]md5sum:[RESET_INTENSITY] setup.pyy: No such file or directory\n"
},
{
"path": "tests/data/ref/mvn-001.log",
"chars": 7410,
"preview": "[INFO] Scanning for projects...\n[INFO] \n[INFO] -"
},
{
"path": "tests/data/ref/mvn-001.log.out",
"chars": 8404,
"preview": "[FOREGROUND_GREEN][INFO] Scanning for projects[FOREGROUND_RESET]...\n[INFO] "
},
{
"path": "tests/data/ref/mvn-002.log",
"chars": 13768,
"preview": "[INFO] Scanning for projects...\n[INFO] \n[INFO] -"
},
{
"path": "tests/data/ref/mvn-002.log.out",
"chars": 15036,
"preview": "[FOREGROUND_GREEN][INFO] Scanning for projects[FOREGROUND_RESET]...\n[INFO] "
},
{
"path": "tests/data/ref/mvn-003.log",
"chars": 6159,
"preview": "[INFO] Scanning for projects...\n[INFO] \n[INFO] -"
},
{
"path": "tests/data/ref/mvn-003.log.out",
"chars": 7539,
"preview": "[FOREGROUND_GREEN][INFO] Scanning for projects[FOREGROUND_RESET]...\n[INFO] "
},
{
"path": "tests/data/ref/mvn-004.log",
"chars": 484715,
"preview": "Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11-23T11:17:27+01:00)\nMaven home: /opt/maven\nJava"
},
{
"path": "tests/data/ref/mvn-004.log.out",
"chars": 485736,
"preview": "Apache Maven 3.3.9 (NON-CANONICAL_2015-11-23T13:17:27+03:00_root; 2015-11-23T11:17:27+01:00)\nMaven home: /opt/maven\nJava"
},
{
"path": "tests/data/ref/ping-001.log",
"chars": 509,
"preview": "PING www.google.com(dh-in-x67.1e100.net (2a00:1450:400b:c03::67)) 56 data bytes\n64 bytes from dh-in-x67.1e100.net (2a00:"
},
{
"path": "tests/data/ref/ping-001.log.out",
"chars": 758,
"preview": "[BOLD]PING www.google.com(dh-in-x67.1e100.net (2a00:1450:400b:c03::67)) 56 data bytes[RESET_INTENSITY]\n64 bytes from dh-"
},
{
"path": "tests/data/ref/ping-002.log",
"chars": 50,
"preview": "ping: wwwww.google.com: Name or service not known\n"
},
{
"path": "tests/data/ref/ping-002.log.out",
"chars": 50,
"preview": "ping: wwwww.google.com: Name or service not known\n"
},
{
"path": "tests/data/ref/tcpdump-001.log",
"chars": 6947,
"preview": " 1.2.3.4.443 > 4.5.6.7.57434: Flags [.], cksum 0xff56 (incorrect -> 0x2fdc), seq 1504125:1507021, ack 275, win 269, o"
},
{
"path": "tests/data/ref/tcpdump-001.log.out",
"chars": 13212,
"preview": " [FOREGROUND_MAGENTA]1.2.3.4[FOREGROUND_RESET].[FOREGROUND_BLUE]443[RESET_ALL] > [FOREGROUND_MAGENTA]4.5.6.7[FOREGROU"
},
{
"path": "tests/data/ref/tomcat-001.log",
"chars": 9168,
"preview": "Using CATALINA_BASE: /usr/share/tomcat8\nUsing CATALINA_HOME: /usr/share/tomcat8\nUsing CATALINA_TMPDIR: /usr/share/to"
},
{
"path": "tests/data/ref/tomcat-001.log.out",
"chars": 9283,
"preview": "[BOLD]Using CATALINA_BASE: /usr/share/tomcat8[RESET_INTENSITY]\n[BOLD]Using CATALINA_HOME: /usr/share/tomcat8[RESET_I"
},
{
"path": "tests/data/ref/traceroute-001.log",
"chars": 1160,
"preview": "traceroute to www.google.com (111.58.118.18), 30 hops max, 10 byte packets\n 1 foo.home (111.118.1.1) 0.511 ms 0.115 m"
},
{
"path": "tests/data/ref/traceroute-001.log.out",
"chars": 1487,
"preview": "[UNDERLINE]traceroute to www.google.com (111.58.118.18), 30 hops max, 10 byte packets[RESET_UNDERLINE]\n[BOLD] 1[RESET_IN"
},
{
"path": "tests/data/ref/traceroute-002.log",
"chars": 119,
"preview": "wwwww.google.com: Name or service not known\nCannot handle \"host\" cmdline arg `wwwww.google.com' on position 1 (argc 1)\n"
},
{
"path": "tests/data/ref/traceroute-002.log.out",
"chars": 119,
"preview": "wwwww.google.com: Name or service not known\nCannot handle \"host\" cmdline arg `wwwww.google.com' on position 1 (argc 1)\n"
},
{
"path": "tests/test_build.py",
"chars": 2805,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_cli.py",
"chars": 15752,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_filters.py",
"chars": 4549,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_main.py",
"chars": 4012,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_performance.py",
"chars": 2268,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_rainbow.py",
"chars": 3594,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_transformer.py",
"chars": 10522,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tests/test_utils.py",
"chars": 5659,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
},
{
"path": "tox.ini",
"chars": 1920,
"preview": "# ----------------------------------------------------------------------\n# rainbow, a terminal colorizer - https://githu"
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the nicoulaj/rainbow GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 150 files (1.4 MB), approximately 417.9k tokens, and a symbol index with 367 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.