Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-termcolor for openSUSE:Factory checked in at 2023-01-06 17:04:41 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-termcolor (Old) and /work/SRC/openSUSE:Factory/.python-termcolor.new.1563 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-termcolor" Fri Jan 6 17:04:41 2023 rev:12 rq:1046125 version:2.1.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python-termcolor/python-termcolor.changes 2022-10-12 18:24:06.721577608 +0200 +++ /work/SRC/openSUSE:Factory/.python-termcolor.new.1563/python-termcolor.changes 2023-01-06 17:05:07.512036311 +0100 @@ -1,0 +2,13 @@ +Mon Jan 2 09:55:10 UTC 2023 - Dirk Müller <dmuel...@suse.com> + +- update to 2.1.1: + * Add __main__ to re-enable demo via python -m termcolor + +------------------------------------------------------------------- +Sat Dec 3 01:09:36 UTC 2022 - Yogalakshmi Arunachalam <yarunacha...@suse.com> + +- Update to 2.1.0 + * Support FORCE_COLOR and detect tty (#25) @hugovk + * Deprecate __ALL__, use __all__ instead (#23) @hugovk + +------------------------------------------------------------------- Old: ---- termcolor-2.0.1.tar.gz New: ---- termcolor-2.1.1.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-termcolor.spec ++++++ --- /var/tmp/diff_new_pack.8UpPVc/_old 2023-01-06 17:05:07.896038467 +0100 +++ /var/tmp/diff_new_pack.8UpPVc/_new 2023-01-06 17:05:07.900038490 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-termcolor # -# Copyright (c) 2022 SUSE LLC +# Copyright (c) 2023 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -18,7 +18,7 @@ %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-termcolor -Version: 2.0.1 +Version: 2.1.1 Release: 0 Summary: ANSII Color formatting for output in terminal License: MIT ++++++ termcolor-2.0.1.tar.gz -> termcolor-2.1.1.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.coveragerc new/termcolor-2.1.1/.coveragerc --- old/termcolor-2.0.1/.coveragerc 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.coveragerc 2020-02-02 01:00:00.000000000 +0100 @@ -1,5 +1,9 @@ # .coveragerc to control coverage.py +[run] +omit = + */termcolor/__main__.py + [report] # Regexes for lines to exclude from consideration exclude_lines = diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.github/FUNDING.yml new/termcolor-2.1.1/.github/FUNDING.yml --- old/termcolor-2.0.1/.github/FUNDING.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.github/FUNDING.yml 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,2 @@ +github: hugovk +tidelift: "pypi/termcolor" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.github/SECURITY.md new/termcolor-2.1.1/.github/SECURITY.md --- old/termcolor-2.0.1/.github/SECURITY.md 1970-01-01 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.github/SECURITY.md 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,5 @@ +# Security policy + +To report sensitive vulnerability information, please use the +[Tidelift security contact](https://tidelift.com/security). Tidelift will coordinate the +fix and disclosure. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.github/labels.yml new/termcolor-2.1.1/.github/labels.yml --- old/termcolor-2.0.1/.github/labels.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.github/labels.yml 2020-02-02 01:00:00.000000000 +0100 @@ -52,9 +52,9 @@ - color: 0366d6 description: "For dependencies" name: dependencies -- color: 0052cc - description: "Documentation" - name: docs +- color: 0075ca + description: "Improvements or additions to documentation" + name: documentation - color: f4660e description: "" name: Hacktoberfest diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.github/workflows/test.yml new/termcolor-2.1.1/.github/workflows/test.yml --- old/termcolor-2.0.1/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.github/workflows/test.yml 2020-02-02 01:00:00.000000000 +0100 @@ -11,7 +11,7 @@ strategy: fail-fast: false matrix: - python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10", "3.11-dev"] + python-version: ["pypy-3.8", "3.7", "3.8", "3.9", "3.10", "3.11"] os: [windows-latest, macos-latest, ubuntu-latest] steps: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/.pre-commit-config.yaml new/termcolor-2.1.1/.pre-commit-config.yaml --- old/termcolor-2.0.1/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/.pre-commit-config.yaml 2020-02-02 01:00:00.000000000 +0100 @@ -1,12 +1,12 @@ repos: - repo: https://github.com/asottile/pyupgrade - rev: v2.37.3 + rev: v3.1.0 hooks: - id: pyupgrade args: [--py37-plus] - repo: https://github.com/psf/black - rev: 22.8.0 + rev: 22.10.0 hooks: - id: black args: [--target-version=py37] @@ -39,7 +39,7 @@ - id: trailing-whitespace - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.971 + rev: v0.982 hooks: - id: mypy args: [--strict, --pretty, --show-error-codes] @@ -61,7 +61,7 @@ - id: tox-ini-fmt - repo: https://github.com/pre-commit/mirrors-prettier - rev: v3.0.0-alpha.0 + rev: v3.0.0-alpha.3 hooks: - id: prettier args: [--prose-wrap=always, --print-width=88] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/PKG-INFO new/termcolor-2.1.1/PKG-INFO --- old/termcolor-2.0.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/PKG-INFO 2020-02-02 01:00:00.000000000 +0100 @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: termcolor -Version: 2.0.1 +Version: 2.1.1 Summary: ANSI color formatting for output in terminal Project-URL: Changelog, https://github.com/termcolor/termcolor/releases Project-URL: Homepage, https://github.com/termcolor/termcolor @@ -41,6 +41,31 @@ [](https://codecov.io/gh/termcolor/termcolor) [](COPYING.txt) [](https://github.com/psf/black) +[](https://tidelift.com/subscription/pkg/pypi-termcolor?utm_source=pypi-termcolor&utm_medium=referral&utm_campaign=readme) + +## Installation + +### From PyPI + +```bash +python3 -m pip install --upgrade termcolor +``` + +### From source + +```bash +git clone https://github.com/termcolor/termcolor +cd termcolor +python3 -m pip install . +``` + +### Demo + +To see demo output, run: + +```bash +python3 -m termcolor +``` ## Example @@ -65,36 +90,16 @@ ## Text properties -Text colors: - -- grey -- red -- green -- yellow -- blue -- magenta -- cyan -- white - -Text highlights: - -- on_grey -- on_red -- on_green -- on_yellow -- on_blue -- on_magenta -- on_cyan -- on_white - -Attributes: - -- bold -- dark -- underline -- blink -- reverse -- concealed +| Text colors | Text highlights | Attributes | +| ----------- | --------------- | ----------- | +| `grey` | `on_grey` | `bold` | +| `red` | `on_red` | `dark` | +| `green` | `on_green` | `underline` | +| `yellow` | `on_yellow` | `blink` | +| `blue` | `on_blue` | `reverse` | +| `magenta` | `on_magenta` | `concealed` | +| `cyan` | `on_cyan` | | +| `white` | `on_white` | | ## Terminal properties diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/README.md new/termcolor-2.1.1/README.md --- old/termcolor-2.0.1/README.md 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/README.md 2020-02-02 01:00:00.000000000 +0100 @@ -7,6 +7,31 @@ [](https://codecov.io/gh/termcolor/termcolor) [](COPYING.txt) [](https://github.com/psf/black) +[](https://tidelift.com/subscription/pkg/pypi-termcolor?utm_source=pypi-termcolor&utm_medium=referral&utm_campaign=readme) + +## Installation + +### From PyPI + +```bash +python3 -m pip install --upgrade termcolor +``` + +### From source + +```bash +git clone https://github.com/termcolor/termcolor +cd termcolor +python3 -m pip install . +``` + +### Demo + +To see demo output, run: + +```bash +python3 -m termcolor +``` ## Example @@ -31,36 +56,16 @@ ## Text properties -Text colors: - -- grey -- red -- green -- yellow -- blue -- magenta -- cyan -- white - -Text highlights: - -- on_grey -- on_red -- on_green -- on_yellow -- on_blue -- on_magenta -- on_cyan -- on_white - -Attributes: - -- bold -- dark -- underline -- blink -- reverse -- concealed +| Text colors | Text highlights | Attributes | +| ----------- | --------------- | ----------- | +| `grey` | `on_grey` | `bold` | +| `red` | `on_red` | `dark` | +| `green` | `on_green` | `underline` | +| `yellow` | `on_yellow` | `blink` | +| `blue` | `on_blue` | `reverse` | +| `magenta` | `on_magenta` | `concealed` | +| `cyan` | `on_cyan` | | +| `white` | `on_white` | | ## Terminal properties diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/src/termcolor/__init__.py new/termcolor-2.1.1/src/termcolor/__init__.py --- old/termcolor-2.0.1/src/termcolor/__init__.py 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/src/termcolor/__init__.py 2020-02-02 01:00:00.000000000 +0100 @@ -1,3 +1,4 @@ +"""ANSI color formatting for output in terminal.""" from __future__ import annotations from termcolor.termcolor import ATTRIBUTES, COLORS, HIGHLIGHTS, RESET, colored, cprint diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/src/termcolor/__main__.py new/termcolor-2.1.1/src/termcolor/__main__.py --- old/termcolor-2.0.1/src/termcolor/__main__.py 1970-01-01 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/src/termcolor/__main__.py 2020-02-02 01:00:00.000000000 +0100 @@ -0,0 +1,52 @@ +from __future__ import annotations + +import os + +from termcolor import cprint + +if __name__ == "__main__": + print(f"Current terminal type: {os.getenv('TERM')}") + print("Test basic colors:") + cprint("Grey color", "grey") + cprint("Red color", "red") + cprint("Green color", "green") + cprint("Yellow color", "yellow") + cprint("Blue color", "blue") + cprint("Magenta color", "magenta") + cprint("Cyan color", "cyan") + cprint("White color", "white") + print("-" * 78) + + print("Test highlights:") + cprint("On grey color", on_color="on_grey") + cprint("On red color", on_color="on_red") + cprint("On green color", on_color="on_green") + cprint("On yellow color", on_color="on_yellow") + cprint("On blue color", on_color="on_blue") + cprint("On magenta color", on_color="on_magenta") + cprint("On cyan color", on_color="on_cyan") + cprint("On white color", color="grey", on_color="on_white") + print("-" * 78) + + print("Test attributes:") + cprint("Bold grey color", "grey", attrs=["bold"]) + cprint("Dark red color", "red", attrs=["dark"]) + cprint("Underline green color", "green", attrs=["underline"]) + cprint("Blink yellow color", "yellow", attrs=["blink"]) + cprint("Reversed blue color", "blue", attrs=["reverse"]) + cprint("Concealed Magenta color", "magenta", attrs=["concealed"]) + cprint( + "Bold underline reverse cyan color", + "cyan", + attrs=["bold", "underline", "reverse"], + ) + cprint( + "Dark blink concealed white color", + "white", + attrs=["dark", "blink", "concealed"], + ) + print("-" * 78) + + print("Test mixing:") + cprint("Underline red on grey color", "red", "on_grey", ["underline"]) + cprint("Reversed green on red color", "green", "on_red", ["reverse"]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/src/termcolor/termcolor.py new/termcolor-2.1.1/src/termcolor/termcolor.py --- old/termcolor-2.0.1/src/termcolor/termcolor.py 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/src/termcolor/termcolor.py 2020-02-02 01:00:00.000000000 +0100 @@ -25,9 +25,22 @@ from __future__ import annotations import os +import sys +import warnings from typing import Any, Iterable -__ALL__ = ["colored", "cprint"] + +def __getattr__(name: str) -> list[str]: + if name == "__ALL__": + warnings.warn( + "__ALL__ is deprecated and will be removed in termcolor 3. " + "Use __all__ instead.", + DeprecationWarning, + stacklevel=2, + ) + return ["colored", "cprint"] + raise AttributeError(f"module '{__name__}' has no attribute '{name}'") + ATTRIBUTES = dict( list( @@ -90,6 +103,21 @@ RESET = "\033[0m" +def _can_do_colour() -> bool: + """Check env vars and for tty/dumb terminal""" + if "ANSI_COLORS_DISABLED" in os.environ: + return False + if "NO_COLOR" in os.environ: + return False + if "FORCE_COLOR" in os.environ: + return True + return ( + hasattr(sys.stdout, "isatty") + and sys.stdout.isatty() + and os.environ.get("TERM") != "dumb" + ) + + def colored( text: str, color: str | None = None, @@ -111,7 +139,7 @@ colored('Hello, World!', 'red', 'on_grey', ['bold', 'blink']) colored('Hello, World!', 'green') """ - if "NO_COLOR" in os.environ or "ANSI_COLORS_DISABLED" in os.environ: + if not _can_do_colour(): return text fmt_str = "\033[%dm%s" @@ -141,51 +169,3 @@ """ print((colored(text, color, on_color, attrs)), **kwargs) - - -if __name__ == "__main__": - print("Current terminal type: %s" % os.getenv("TERM")) - print("Test basic colors:") - cprint("Grey color", "grey") - cprint("Red color", "red") - cprint("Green color", "green") - cprint("Yellow color", "yellow") - cprint("Blue color", "blue") - cprint("Magenta color", "magenta") - cprint("Cyan color", "cyan") - cprint("White color", "white") - print("-" * 78) - - print("Test highlights:") - cprint("On grey color", on_color="on_grey") - cprint("On red color", on_color="on_red") - cprint("On green color", on_color="on_green") - cprint("On yellow color", on_color="on_yellow") - cprint("On blue color", on_color="on_blue") - cprint("On magenta color", on_color="on_magenta") - cprint("On cyan color", on_color="on_cyan") - cprint("On white color", color="grey", on_color="on_white") - print("-" * 78) - - print("Test attributes:") - cprint("Bold grey color", "grey", attrs=["bold"]) - cprint("Dark red color", "red", attrs=["dark"]) - cprint("Underline green color", "green", attrs=["underline"]) - cprint("Blink yellow color", "yellow", attrs=["blink"]) - cprint("Reversed blue color", "blue", attrs=["reverse"]) - cprint("Concealed Magenta color", "magenta", attrs=["concealed"]) - cprint( - "Bold underline reverse cyan color", - "cyan", - attrs=["bold", "underline", "reverse"], - ) - cprint( - "Dark blink concealed white color", - "white", - attrs=["dark", "blink", "concealed"], - ) - print("-" * 78) - - print("Test mixing:") - cprint("Underline red on grey color", "red", "on_grey", ["underline"]) - cprint("Reversed green on red color", "green", "on_red", ["reverse"]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/tests/test_termcolor.py new/termcolor-2.1.1/tests/test_termcolor.py --- old/termcolor-2.0.1/tests/test_termcolor.py 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/tests/test_termcolor.py 2020-02-02 01:00:00.000000000 +0100 @@ -5,7 +5,7 @@ import pytest -from termcolor import ATTRIBUTES, COLORS, HIGHLIGHTS, colored, cprint +from termcolor import ATTRIBUTES, COLORS, HIGHLIGHTS, colored, cprint, termcolor ALL_COLORS = [*COLORS, None] ALL_HIGHLIGHTS = [*HIGHLIGHTS, None] @@ -14,13 +14,18 @@ def setup_module() -> None: # By default, make sure no env vars already set for tests - try: - del os.environ["ANSI_COLORS_DISABLED"] - except KeyError: # pragma: no cover - pass + for var in ("ANSI_COLORS_DISABLED", "NO_COLOR", "FORCE_COLOR"): + try: + del os.environ[var] + except KeyError: # pragma: no cover + pass -def test_basic() -> None: +def test_basic(monkeypatch: pytest.MonkeyPatch) -> None: + # Arrange + monkeypatch.setattr("sys.stdout.isatty", lambda: True) + + # Act / Assert assert colored("text") == "text\x1b[0m" @@ -61,7 +66,16 @@ ("white", "\x1b[37mtext\x1b[0m"), ], ) -def test_color(capsys: pytest.CaptureFixture[str], color: str, expected: str) -> None: +def test_color( + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + color: str, + expected: str, +) -> None: + # Arrange + monkeypatch.setattr("sys.stdout.isatty", lambda: True) + + # Act / Assert assert colored("text", color=color) == expected assert_cprint(capsys, expected, "text", color=color) @@ -80,8 +94,15 @@ ], ) def test_on_color( - capsys: pytest.CaptureFixture[str], on_color: str, expected: str + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + on_color: str, + expected: str, ) -> None: + # Arrange + monkeypatch.setattr("sys.stdout.isatty", lambda: True) + + # Act / Assert assert colored("text", on_color=on_color) == expected assert_cprint(capsys, expected, "text", on_color=on_color) @@ -97,7 +118,16 @@ ("concealed", "\x1b[8mtext\x1b[0m"), ], ) -def test_attrs(capsys: pytest.CaptureFixture[str], attr: str, expected: str) -> None: +def test_attrs( + capsys: pytest.CaptureFixture[str], + monkeypatch: pytest.MonkeyPatch, + attr: str, + expected: str, +) -> None: + # Arrange + monkeypatch.setattr("sys.stdout.isatty", lambda: True) + + # Act / Assert assert colored("text", attrs=[attr]) == expected assert_cprint(capsys, expected, "text", attrs=[attr]) @@ -119,9 +149,71 @@ "", ], ) -def test_env_var( +def test_environment_variables_disable_color( monkeypatch: pytest.MonkeyPatch, test_env_var: str, test_value: str ) -> None: - """Assert nothing applied when this env var set, regardless of value.""" + """Assert nothing applied when this env var set, regardless of value""" monkeypatch.setenv(test_env_var, test_value) - assert colored("text", color="red") == "text" + assert colored("text", color="cyan") == "text" + + +@pytest.mark.parametrize( + "test_value", + [ + "true", + "false", + "1", + "0", + "", + ], +) +def test_environment_variables_force_color( + monkeypatch: pytest.MonkeyPatch, test_value: str +) -> None: + """Assert color applied when this env var set, regardless of value""" + monkeypatch.setenv("FORCE_COLOR", test_value) + assert colored("text", color="cyan") == "\x1b[36mtext\x1b[0m" + + +@pytest.mark.parametrize( + "test_env_vars, expected", + [ + (["ANSI_COLORS_DISABLED=1"], False), + (["NO_COLOR=1"], False), + (["FORCE_COLOR=1"], True), + (["ANSI_COLORS_DISABLED=1", "NO_COLOR=1", "FORCE_COLOR=1"], False), + (["NO_COLOR=1", "FORCE_COLOR=1"], False), + ], +) +def test_environment_variables( + monkeypatch: pytest.MonkeyPatch, test_env_vars: str, expected: bool +) -> None: + """Assert combinations do the right thing""" + for env_var in test_env_vars: + name, value = env_var.split("=") + print(name, value) + monkeypatch.setenv(name, value) + + assert termcolor._can_do_colour() == expected + + +@pytest.mark.parametrize( + "test_isatty, expected", + [ + (True, "\x1b[36mtext\x1b[0m"), + (False, "text"), + ], +) +def test_tty(monkeypatch: pytest.MonkeyPatch, test_isatty: bool, expected: str) -> None: + """Assert color when attached to tty, no color when not attached""" + # Arrange + monkeypatch.setattr("sys.stdout.isatty", lambda: test_isatty) + + # Act / Assert + assert colored("text", color="cyan") == expected + + +def test_all_deprecation() -> None: + """Assert that __ALL__ is deprecated (use __all__ instead)""" + with pytest.deprecated_call(): + assert termcolor.__ALL__ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/termcolor-2.0.1/tox.ini new/termcolor-2.1.1/tox.ini --- old/termcolor-2.0.1/tox.ini 2020-02-02 01:00:00.000000000 +0100 +++ new/termcolor-2.1.1/tox.ini 2020-02-02 01:00:00.000000000 +0100 @@ -10,7 +10,7 @@ extras = tests commands = - {envpython} -m pytest --cov termcolor --cov tests --cov-report xml {posargs} + {envpython} -m pytest --cov termcolor --cov tests --cov-report html --cov-report xml {posargs} [testenv:lint] passenv =