diff options
Diffstat (limited to 'contrib/python')
| -rw-r--r-- | contrib/python/jaraco.text/.dist-info/METADATA | 11 | ||||
| -rw-r--r-- | contrib/python/jaraco.text/README.rst | 2 | ||||
| -rw-r--r-- | contrib/python/jaraco.text/jaraco/text/__init__.py | 29 | ||||
| -rw-r--r-- | contrib/python/jaraco.text/jaraco/text/layouts.py | 7 | ||||
| -rw-r--r-- | contrib/python/jaraco.text/ya.make | 2 |
5 files changed, 36 insertions, 15 deletions
diff --git a/contrib/python/jaraco.text/.dist-info/METADATA b/contrib/python/jaraco.text/.dist-info/METADATA index 1d21bc04f99..7189bbab98b 100644 --- a/contrib/python/jaraco.text/.dist-info/METADATA +++ b/contrib/python/jaraco.text/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: jaraco.text -Version: 4.2.0 +Version: 4.3.0 Summary: Module for text manipulation Author-email: "Jason R. Coombs" <[email protected]> License-Expression: MIT @@ -9,7 +9,7 @@ Classifier: Development Status :: 5 - Production/Stable Classifier: Intended Audience :: Developers Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only -Requires-Python: >=3.9 +Requires-Python: >=3.10 Description-Content-Type: text/x-rst License-File: LICENSE Requires-Dist: jaraco.context>=4.1 @@ -29,15 +29,14 @@ Requires-Dist: jaraco.tidelift>=1.4; extra == "doc" Provides-Extra: inflect Requires-Dist: inflect; extra == "inflect" Provides-Extra: check -Requires-Dist: pytest-checkdocs>=2.4; extra == "check" +Requires-Dist: pytest-checkdocs>=2.14; extra == "check" Requires-Dist: pytest-ruff>=0.2.1; sys_platform != "cygwin" and extra == "check" Provides-Extra: cover Requires-Dist: pytest-cov; extra == "cover" Provides-Extra: enabler Requires-Dist: pytest-enabler>=3.4; extra == "enabler" Provides-Extra: type -Requires-Dist: pytest-mypy>=1.0.1; extra == "type" -Requires-Dist: mypy<1.19; platform_python_implementation == "PyPy" and extra == "type" +Requires-Dist: pytest-mypy>=1.0.1; platform_python_implementation != "PyPy" and extra == "type" Dynamic: license-file .. image:: https://img.shields.io/pypi/v/jaraco.text.svg @@ -56,7 +55,7 @@ Dynamic: license-file .. image:: https://readthedocs.org/projects/jaracotext/badge/?version=latest :target: https://jaracotext.readthedocs.io/en/latest/?badge=latest -.. image:: https://img.shields.io/badge/skeleton-2025-informational +.. image:: https://img.shields.io/badge/skeleton-2026-informational :target: https://blog.jaraco.com/skeleton .. image:: https://tidelift.com/badges/package/pypi/jaraco.text diff --git a/contrib/python/jaraco.text/README.rst b/contrib/python/jaraco.text/README.rst index 8f563a05fba..f21f5425115 100644 --- a/contrib/python/jaraco.text/README.rst +++ b/contrib/python/jaraco.text/README.rst @@ -14,7 +14,7 @@ .. image:: https://readthedocs.org/projects/jaracotext/badge/?version=latest :target: https://jaracotext.readthedocs.io/en/latest/?badge=latest -.. image:: https://img.shields.io/badge/skeleton-2025-informational +.. image:: https://img.shields.io/badge/skeleton-2026-informational :target: https://blog.jaraco.com/skeleton .. image:: https://tidelift.com/badges/package/pypi/jaraco.text diff --git a/contrib/python/jaraco.text/jaraco/text/__init__.py b/contrib/python/jaraco.text/jaraco/text/__init__.py index 9ae1f6e0600..10360e35f5e 100644 --- a/contrib/python/jaraco.text/jaraco/text/__init__.py +++ b/contrib/python/jaraco.text/jaraco/text/__init__.py @@ -29,16 +29,18 @@ else: # pragma: no cover from importlib.abc import Traversable if TYPE_CHECKING: + from typing import TypeAlias, TypeGuard + from _typeshed import ( FileDescriptorOrPath, SupportsIter, SupportsNext, ) - from typing_extensions import Self, TypeAlias, TypeGuard, Unpack + from typing_extensions import Self, Unpack Openable: TypeAlias = FileDescriptorOrPath else: - Openable = Union[str, bytes, os.PathLike, int] + Openable = str | bytes | os.PathLike | int _T = TypeVar("_T") @@ -210,7 +212,7 @@ class FoldedCase(str): return pattern.split(self, int(maxsplit)) -@ExceptionTrap(UnicodeDecodeError).passes # type: ignore[no-untyped-call, untyped-decorator, unused-ignore, misc] # jaraco/jaraco.context#15 +@ExceptionTrap(UnicodeDecodeError).passes # type: ignore[no-untyped-call, untyped-decorator, unused-ignore, misc, arg-type] # jaraco/jaraco.context#15 def is_decodable(value: _SupportsDecode) -> None: r""" Return True if the supplied value is decodable (using the default @@ -488,6 +490,25 @@ def simple_html_strip(s: str) -> str: return ''.join(texts) +# ECMA-48 escape sequences: a Fe escape (except CSI) or a CSI sequence. +_ansi_pattern = re.compile(r'\x1b(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])') + + +def strip_ansi(text: str) -> str: + r""" + Remove ANSI escape sequences (such as SGR color codes) from `text`. + + >>> strip_ansi('\x1b[1;32m3.24 nsec\x1b[0m \x1b[32mper loop\x1b[0m') + '3.24 nsec per loop' + + Text without escape sequences passes through unchanged. + + >>> strip_ansi('plain text') + 'plain text' + """ + return _ansi_pattern.sub('', text) + + class SeparatedValues(str): """ A string separated by a separator. Overrides __iter__ for getting @@ -697,7 +718,7 @@ def join_continuation(lines: SupportsIter[SupportsNext[str]]) -> Generator[str]: # https://docs.python.org/3/library/io.html#io.TextIOBase.newlines -NewlineSpec: TypeAlias = Union[str, tuple[str, ...], None] +NewlineSpec: TypeAlias = str | tuple[str, ...] | None @functools.singledispatch diff --git a/contrib/python/jaraco.text/jaraco/text/layouts.py b/contrib/python/jaraco.text/jaraco/text/layouts.py index 7ad0cd42624..3e25d8de74a 100644 --- a/contrib/python/jaraco.text/jaraco/text/layouts.py +++ b/contrib/python/jaraco.text/jaraco/text/layouts.py @@ -1,13 +1,14 @@ from __future__ import annotations -from typing import TYPE_CHECKING, Union +from typing import TYPE_CHECKING if TYPE_CHECKING: + from typing import TypeAlias + from _typeshed import SupportsGetItem, SupportsRead - from typing_extensions import TypeAlias # Same as builtins._TranslateTable from typeshed - _TranslateTable: TypeAlias = SupportsGetItem[int, Union[str, int, None]] + _TranslateTable: TypeAlias = SupportsGetItem[int, str | int | None] qwerty = "-=qwertyuiop[]asdfghjkl;'zxcvbnm,./_+QWERTYUIOP{}ASDFGHJKL:\"ZXCVBNM<>?" dvorak = "[]',.pyfgcrl/=aoeuidhtns-;qjkxbmwvz{}\"<>PYFGCRL?+AOEUIDHTNS_:QJKXBMWVZ" diff --git a/contrib/python/jaraco.text/ya.make b/contrib/python/jaraco.text/ya.make index ab74fb5b55b..5421a2166d0 100644 --- a/contrib/python/jaraco.text/ya.make +++ b/contrib/python/jaraco.text/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(4.2.0) +VERSION(4.3.0) LICENSE(MIT) |
