Skip to main content

compare text and show the difference with color.

Project description

=============== Compare text and show the difference with color.

Install

 pip install diffcolor

Useage

show the help

python -m diffcolor

After that, diffcolor will read data from STDIN.

For more help, you can use the "-h" option.

So, the following test command

echo "Hello World\nHello Worll" | python -m diffcolor

It will output the following, the last "l" is different:

Hello World
Hello Worll

By default, diffcolor compare each character in each frame of the data. You can use the "-s" parameter to specify the delimiter, such as the space. This "-s" parameter can be used multiple times. For example, the following command will compare the data frame using the space.

echo "Hello World\nHello Worll" | python -m diffcolor -s " "

It will output the following, the last word "Worll" is different:

Hello World
Hello Worll

By default, it splits data frames using line breaks(\n). But sometimes, we need a front end and a frame end to segment. We can use the "-b" parameter to specify the frame header and the "-e" parameter to specify the frame footer.

For example, the following command will splits the data frame begin with "[" and end with "]\n".

echo "[Hello World,\nI am Tom]\nThis is not a frame.\n[Hello Worll,\nI am Tim]" | python -m diffcolor -b="[" -e="]\n" -s=" "

It will output the following, the color of "This is not a frame." is gray, because it is not a frame:

[Hello World,
I am Tom]
This is not a frame.
Hello Worll,
I am Tim]

We can use the "-i" option to ignore the none frame data.

echo "[Hello World,\nI am Tom]\nThis is not a frame.\n[Hello Worll,\nI am Tim]" | python -m diffcolor -b="[" -e="]\n" -s=" " -i

It will output the following:

[Hello World,
I am Tom]
Hello Worll,
I am Tim]

We can use the "-f" option to handled output appended data as the file grows. This option is like "tail -f", often used to handle growing log files.

The colors define you can use "-v" option to show.

python -m diffcolor -v
TYPE
COLOR
NORMAL
NORMAL
DIFF
DIFF
IGNORE
DIFF
MISS
DIFF
OVER
DIFF

Click to view more information!

CHANGES

0.0.1

  • first version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

diffcolor-0.0.2.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file diffcolor-0.0.2.tar.gz.

File metadata

  • Download URL: diffcolor-0.0.2.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.8.2 requests/2.27.1 setuptools/44.1.1 requests-toolbelt/0.9.1 tqdm/4.64.0 CPython/2.7.16

File hashes

Hashes for diffcolor-0.0.2.tar.gz
Algorithm Hash digest
SHA256 66b47e15ae6542312f3f6a8933514eda4f41ec959e895f2d0066e19cda5b3bbc
MD5 4be42e1db1e812b0daff04bfcc2de787
BLAKE2b-256 7447499239a8fe179ac302ebf78d3ae871c834c3de38c73411bd19ce0937eade

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page