Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Yet another ANSI color text library for Python. Provides "auto colors" for dark/light terminals. Works on Linux, OS X,
and Windows. For Windows support you just need to call Windows.enable()
in your application.
On Linux/OS X autocolors
are toggled by calling set_light_background()
and set_dark_background()
. On Windows
this can be done automatically if you call Windows.enable(auto_colors=True)
. Even though the latest Windows 10 does
support ANSI color codes natively, you still need to run Windows.enable() to take advantage of automatically detecting
the console's background color.
In Python2.x this library subclasses unicode
, while on Python3.x it subclasses str
.
Install:
pip install colorclass
It is possible to pipe curly-bracket tagged (or regular ANSI coded) text to Python in the command line to produce color text. Some examples:
echo "{red}Red{/red}" |python -m colorclass # Red colored text.
echo -e "\033[31mRed\033[0m" | COLOR_DISABLE=true python -m colorclass # Strip colors
echo -e "\033[31mRed\033[0m" | COLOR_ENABLE=true python -m colorclass &> file.txt # Force colors.
Export these environment variables as "true" to enable/disable some features:
=============== ============================================
Env Variable Description
=============== ============================================
COLOR_ENABLE Force colors even when piping to a file.
COLOR_DISABLE Strip all colors from incoming text.
COLOR_LIGHT Use light colored text for dark backgrounds.
COLOR_DARK Use dark colored text for light backgrounds.
=============== ============================================
Source code for the example code is: example.py
Different colors are chosen using curly-bracket tags, such as {red}{/red}
. For a list of available colors, call
colorclass.list_tags()
.
The available "auto colors" tags are:
Methods of Class instances try to return sane data, such as:
from colorclass import Color
color_string = Color('{red}Test{/red}')
>>> color_string
u'\x1b[31mTest\x1b[39m'
>>> len(color_string)
4
>>> color_string.istitle()
True
There are also a couple of helper attributes for all Color instances:
>>> color_string.value_colors
'\x1b[31mTest\x1b[39m'
>>> color_string.value_no_colors
'Test'
FAQs
Colorful worry-free console applications for Linux, Mac OS X, and Windows.
We found that colorclass demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.