1
0
Fork 0

Adding upstream version 2.2.2.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-07 10:19:58 +01:00
parent 12d94d2889
commit 7ffdc0dc3c
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
13 changed files with 407 additions and 2 deletions

104
CHANGELOG.md Normal file
View file

@ -0,0 +1,104 @@
Changelog
=========
This project adheres to `Semantic Versioning <http://semver.org/>`_.
2.2.1 - 2021-12-08
------------------
Added
* Publishin wheels
2.2.0 - 2016-05-14
------------------
Added
* ``disable_if_no_tty()`` function to conditionally disable colors when STDERR and STDOUT are not streams.
Changed
* Colors enabled by default always, like it was before v2.0.0.
2.1.1 - 2016-05-10
------------------
Fixed
* Printing box drawing characters on Windows from Python 2.6.
2.1.0 - 2016-05-07
------------------
Added
* ``keep_tags`` boolean keyword argument to Color(). Prevents colorclass from parsing curly brackets.
* Automatically skip replacing stderr/stdout streams on latest Windows 10 versions with native ANSI color support.
Changed
* Refactored most of windows.py.
* Background color determined from either stderr or stdout, instead of just one stream (e.g. piping stderr to file).
Fixed
* https://github.com/Robpol86/colorclass/issues/16
* https://github.com/Robpol86/colorclass/issues/18
2.0.0 - 2016-04-10
------------------
Added
* Python 3.5 support.
* ``enable_all_colors()``, ``is_enabled()``, and ``is_light()`` toggle functions.
* Library can be used as a script (e.g. ``echo "{red}Red{/red}" |python -m colorclass``).
* Ability to add/multiply Color instances just like str.
* Ability to iterate a Color instance and have each character keep its color codes.
Changed
* Converted library from Python module to a package.
* ``set_light_background()`` and ``set_dark_background()`` no longer enable colors. Use ``enable_all_colors()``.
* Colors are disabled by default when STDERR and STDOUT are not streams (piped to files/null). Similar to ``grep``.
* Reduce size of ANSI escape sequences by removing codes that have no effect. e.g. ``\033[31;35m`` to ``\033[35m``.
* Color methods that return strings now return Color instances instead of str instances.
Fixed
* https://github.com/Robpol86/colorclass/issues/15
* https://github.com/Robpol86/colorclass/issues/17
1.2.0 - 2015-03-19
------------------
Added
* Convenience single-color methods by `Marc Abramowitz <https://github.com/msabramo>`_.
1.1.2 - 2015-01-07
------------------
Fixed
* Maintaining ``Color`` type through ``.encode()`` and ``.decode()`` chains.
1.1.1 - 2014-11-03
------------------
Fixed
* Python 2.7 64-bit original colors bug on Windows.
* resetting colors when ``reset_atexit`` is True.
* Improved sorting of ``list_tags()``.
1.1.0 - 2014-11-01
------------------
Added
* Native Windows support and automatic background colors.
1.0.2 - 2014-10-20
------------------
Added
* Ability to disable/strip out all colors.
1.0.1 - 2014-09-11
------------------
Fixed
* ``splitlines()`` method.
1.0.0 - 2014-09-01
------------------
* Initial release.

13
Pipfile Normal file
View file

@ -0,0 +1,13 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
pytest = "*"
vermin = "*"
[requires]
python_version = "3.10"

108
Pipfile.lock generated Normal file
View file

@ -0,0 +1,108 @@
{
"_meta": {
"hash": {
"sha256": "98f4caac4a46252f166ade98a8f70e0a01ea0f6a24ad1f3292f8549c6faf81f7"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.10"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"vermin": {
"hashes": [
"sha256:ef38dedab8cf7b68f8037f531b82222153ab21d3c54b91dd80776bbf95637ae5"
],
"index": "pypi",
"version": "==1.3.1"
}
},
"develop": {
"atomicwrites": {
"hashes": [
"sha256:6d1784dea7c0c8d4a5172b6c620f40b6e4cbfdf96d783691f2e1302a7b88e197",
"sha256:ae70396ad1a434f9c7046fd2dd196fc04b12f9e91ffb859164193be8b6168a7a"
],
"markers": "sys_platform == 'win32'",
"version": "==1.4.0"
},
"attrs": {
"hashes": [
"sha256:149e90d6d8ac20db7a955ad60cf0e6881a3f20d37096140088356da6c716b0b1",
"sha256:ef6aaac3ca6cd92904cdd0d83f629a15f18053ec84e6432106f7a4d04ae4f5fb"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==21.2.0"
},
"colorama": {
"hashes": [
"sha256:5941b2b48a20143d2267e95b1c2a7603ce057ee39fd88e7329b0c292aa16869b",
"sha256:9f47eda37229f68eee03b24b9748937c7dc3868f906e8ba69fbcbdd3bc5dc3e2"
],
"markers": "sys_platform == 'win32'",
"version": "==0.4.4"
},
"iniconfig": {
"hashes": [
"sha256:011e24c64b7f47f6ebd835bb12a743f2fbe9a26d4cecaa7f53bc4f35ee9da8b3",
"sha256:bc3af051d7d14b2ee5ef9969666def0cd1a000e121eaea580d4a313df4b37f32"
],
"version": "==1.1.1"
},
"packaging": {
"hashes": [
"sha256:dd47c42927d89ab911e606518907cc2d3a1f38bbd026385970643f9c5b8ecfeb",
"sha256:ef103e05f519cdc783ae24ea4e2e0f508a9c99b2d4969652eed6a2e1ea5bd522"
],
"markers": "python_version >= '3.6'",
"version": "==21.3"
},
"pluggy": {
"hashes": [
"sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159",
"sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"
],
"markers": "python_version >= '3.6'",
"version": "==1.0.0"
},
"py": {
"hashes": [
"sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719",
"sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'",
"version": "==1.11.0"
},
"pyparsing": {
"hashes": [
"sha256:04ff808a5b90911829c55c4e26f75fa5ca8a2f5f36aa3a51f68e27033341d3e4",
"sha256:d9bdec0013ef1eb5a84ab39a3b3868911598afa494f5faa038647101504e2b81"
],
"markers": "python_version >= '3.6'",
"version": "==3.0.6"
},
"pytest": {
"hashes": [
"sha256:131b36680866a76e6781d13f101efb86cf674ebb9762eb70d3082b6f29889e89",
"sha256:7310f8d27bc79ced999e760ca304d69f6ba6c6649c0b60fb0e04a4a77cacc134"
],
"index": "pypi",
"version": "==6.2.5"
},
"toml": {
"hashes": [
"sha256:806143ae5bfb6a3c6e736a764057db0e6a0e05e338b5630894a5f779cabb4f9b",
"sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"
],
"markers": "python_version >= '2.6' and python_version not in '3.0, 3.1, 3.2, 3.3'",
"version": "==0.10.2"
}
}
}

99
README.md Normal file
View file

@ -0,0 +1,99 @@
# colorclass
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``.
* Python 2.6, 2.7, PyPy, PyPy3, 3.3, 3.4, and 3.5 supported on Linux and OS X.
* Python 2.6, 2.7, 3.3, 3.4, and 3.5 supported on Windows (both 32 and 64 bit versions of Python).
## Quickstart
Install:
```bash
pip install colorclass
```
## Piped Command Line
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:
```bash
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.
=============== ============================================
## Example Implementation
![Example Script Screenshot](https://github.com/Robpol86/colorclass/raw/master/example.png?raw=true)
![Example Windows Screenshot](https://github.com/Robpol86/colorclass/raw/master/example_windows.png?raw=true)
Source code for the example code is: [example.py](https://github.com/Robpol86/colorclass/blob/master/example.py)
## Usage
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:
* autoblack
* autored
* autogreen
* autoyellow
* autoblue
* automagenta
* autocyan
* autowhite
* autobgblack
* autobgred
* autobggreen
* autobgyellow
* autobgblue
* autobgmagenta
* autobgcyan
* autobgwhite
Methods of Class instances try to return sane data, such as:
```python
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:
```python
>>> color_string.value_colors
'\x1b[31mTest\x1b[39m'
>>> color_string.value_no_colors
'Test'
```
[Change Log](https://github.com/matthewdeanmartin/colorclass/blob/master/CHANGELOG.md)

11
build.sh Normal file
View file

@ -0,0 +1,11 @@
echo assuming we still want to support python 2!
PROJECT="colorclass"
export PYTHONPATH=$PYTHONPATH:.
pylint "$PROJECT"
flake8 "$PROJECT"
python -m pytest "$PROJECT"
python -m pytest --doctest-glob="$PROJECT/**/*.py"
pytest tests -v --cov-report html:coverage --cov="$PROJECT"
echo not bumping version here, just checking if we can create the wheel
poetry build
check-wheel-contents dist/*.whl

View file

@ -1,7 +1,10 @@
"""Handles mapping between color names and ANSI codes and determining auto color codes."""
import sys
from collections import Mapping
try:
from collections import Mapping
except ImportError:
from collections.abc import Mapping
BASE_CODES = {
'/all': 0, 'b': 1, 'f': 2, 'i': 3, 'u': 4, 'flash': 5, 'outline': 6, 'negative': 7, 'invis': 8, 'strike': 9,

0
setup.py → dead_code/setup.py Executable file → Normal file
View file

1
publish.sh Normal file
View file

@ -0,0 +1 @@
rm -rf dist && poetry version patch && poetry build && twine upload dist/*

66
pyproject.toml Normal file
View file

@ -0,0 +1,66 @@
[tool.poetry]
name = "colorclass"
version = "2.2.2"
description = "Colorful worry-free console applications for Linux, Mac OS X, and Windows."
authors = [
"Robpol86 <robpol86@gmail.com>",
"Matthew Martin <matthewdeanmartin@gmail.com>"
]
keywords = ["Shell", "Bash", "ANSI", "ASCII", "terminal", "console", "colors", "automatic"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Environment :: MacOS X",
"Environment :: Win32 (MS Windows)",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: POSIX",
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"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 :: PyPy",
"Topic :: Software Development :: Libraries",
"Topic :: Terminals",
"Topic :: Text Processing :: Markup"
]
packages = [
{ include = "colorclass" },
]
include = [
"colorclass/**/*.py",
]
exclude = [
]
license = "MIT"
readme = "README.md"
repository = "https://github.com/matthewdeanmartin/colorclass"
homepage = "https://github.com/matthewdeanmartin/colorclass"
documentation = "https://github.com/matthewdeanmartin/colorclass"
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/matthewdeanmartin/colorclass/issues"
"Change Log" = "https://github.com/matthewdeanmartin/colorclass/blob/master/CHANGELOG.md"
[tool.poetry.scripts]
[tool.poetry.dependencies]
# per vermin's estimation
python = ">=2.6 || >=3.0"
[tool.poetry.dev-dependencies]
pytest = "==6.0.1"
[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

View file

@ -174,7 +174,7 @@ class RunNewConsole(object):
def iter_rows(pil_image):
"""Yield tuple of pixels for each row in the image.
itertools.izip in Python 2.x and zip in Python 3.x are writen in C. Much faster than anything else I've found
itertools.izip in Python 2.x and zip in Python 3.x are written in C. Much faster than anything else I've found
written in pure Python.
From: