Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-pygments-ansi-color for
openSUSE:Factory checked in at 2022-10-14 15:40:16
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-pygments-ansi-color (Old)
and /work/SRC/openSUSE:Factory/.python-pygments-ansi-color.new.2275 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-pygments-ansi-color"
Fri Oct 14 15:40:16 2022 rev:4 rq:1010380 version:0.1.0
Changes:
--------
---
/work/SRC/openSUSE:Factory/python-pygments-ansi-color/python-pygments-ansi-color.changes
2020-03-27 00:27:59.052338463 +0100
+++
/work/SRC/openSUSE:Factory/.python-pygments-ansi-color.new.2275/python-pygments-ansi-color.changes
2022-10-14 15:40:27.587710053 +0200
@@ -1,0 +2,6 @@
+Wed Oct 12 14:17:24 UTC 2022 - Yogalakshmi Arunachalam <[email protected]>
+
+- Update to version 0.1.0
+ No upstream changelog
+
+-------------------------------------------------------------------
Old:
----
v0.0.5.tar.gz
New:
----
v0.1.0.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-pygments-ansi-color.spec ++++++
--- /var/tmp/diff_new_pack.jDYLwK/_old 2022-10-14 15:40:28.139710975 +0200
+++ /var/tmp/diff_new_pack.jDYLwK/_new 2022-10-14 15:40:28.163711015 +0200
@@ -1,7 +1,7 @@
#
# spec file for package python-pygments-ansi-color
#
-# Copyright (c) 2020 SUSE LLC
+# Copyright (c) 2022 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-pygments-ansi-color
-Version: 0.0.5
+Version: 0.1.0
Release: 0
Summary: ANSI color-code highlighting for Pygments
License: Apache-2.0
++++++ v0.0.5.tar.gz -> v0.1.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/.gitignore
new/pygments-ansi-color-0.1.0/.gitignore
--- old/pygments-ansi-color-0.0.5/.gitignore 2020-01-07 20:36:45.000000000
+0100
+++ new/pygments-ansi-color-0.1.0/.gitignore 2022-09-14 01:40:08.000000000
+0200
@@ -4,4 +4,3 @@
/.cache
/.coverage
/.tox
-/venv
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/.pre-commit-config.yaml
new/pygments-ansi-color-0.1.0/.pre-commit-config.yaml
--- old/pygments-ansi-color-0.0.5/.pre-commit-config.yaml 2020-01-07
20:36:45.000000000 +0100
+++ new/pygments-ansi-color-0.1.0/.pre-commit-config.yaml 2022-09-14
01:40:08.000000000 +0200
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v2.4.0
+ rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
@@ -12,20 +12,29 @@
- id: name-tests-test
- id: check-added-large-files
- id: check-byte-order-marker
- - id: fix-encoding-pragma
- repo: https://github.com/pre-commit/mirrors-autopep8
- rev: v1.4.4
+ rev: v1.7.0
hooks:
- id: autopep8
- repo: https://gitlab.com/pycqa/flake8
- rev: 3.7.9
+ rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/asottile/reorder_python_imports
- rev: v1.8.0
+ rev: v3.8.2
hooks:
- id: reorder-python-imports
args: [
- '--add-import', 'from __future__ import absolute_import',
- '--add-import', 'from __future__ import unicode_literals',
- ]
+ '--py37-plus',
+ '--add-import', 'from __future__ import annotations',
+ ]
+- repo: https://github.com/asottile/pyupgrade
+ rev: v2.37.3
+ hooks:
+ - id: pyupgrade
+ args: ['--py37-plus']
+- repo: https://github.com/asottile/add-trailing-comma
+ rev: v2.2.3
+ hooks:
+ - id: add-trailing-comma
+ args: ['--py36-plus']
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/mypy.ini
new/pygments-ansi-color-0.1.0/mypy.ini
--- old/pygments-ansi-color-0.0.5/mypy.ini 1970-01-01 01:00:00.000000000
+0100
+++ new/pygments-ansi-color-0.1.0/mypy.ini 2022-09-14 01:40:08.000000000
+0200
@@ -0,0 +1,8 @@
+[mypy]
+check_untyped_defs = true
+disallow_any_generics = true
+disallow_incomplete_defs = true
+disallow_untyped_defs = true
+no_implicit_optional = true
+warn_redundant_casts = true
+warn_unused_ignores = true
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pygments-ansi-color-0.0.5/pygments_ansi_color/__init__.py
new/pygments-ansi-color-0.1.0/pygments_ansi_color/__init__.py
--- old/pygments-ansi-color-0.0.5/pygments_ansi_color/__init__.py
1970-01-01 01:00:00.000000000 +0100
+++ new/pygments-ansi-color-0.1.0/pygments_ansi_color/__init__.py
2022-09-14 01:40:08.000000000 +0200
@@ -0,0 +1,309 @@
+"""Pygments lexer for text containing ANSI color codes."""
+from __future__ import annotations
+
+import itertools
+import re
+import typing
+
+import pygments.lexer
+import pygments.token
+
+
+C = pygments.token.Token.C
+Color = pygments.token.Token.Color
+
+
+_ansi_code_to_color = {
+ 0: 'Black',
+ 1: 'Red',
+ 2: 'Green',
+ 3: 'Yellow',
+ 4: 'Blue',
+ 5: 'Magenta',
+ 6: 'Cyan',
+ 7: 'White',
+}
+
+_256_colors = {
+ 0: '#000000',
+ 1: '#800000',
+ 2: '#008000',
+ 3: '#808000',
+ 4: '#000080',
+ 5: '#800080',
+ 6: '#008080',
+ 7: '#c0c0c0',
+ 8: '#808080',
+ 9: '#ff0000',
+ 10: '#00ff00',
+ 11: '#ffff00',
+ 12: '#0000ff',
+ 13: '#ff00ff',
+ 14: '#00ffff',
+ 15: '#ffffff',
+}
+_vals = (0, 95, 135, 175, 215, 255)
+_256_colors.update({
+ 16 + i: '#{:02x}{:02x}{:02x}'.format(*rgb)
+ for i, rgb in enumerate(itertools.product(_vals, _vals, _vals))
+})
+_256_colors.update({
+ 232 + i: '#{0:02x}{0:02x}{0:02x}'.format(10 * i + 8)
+ for i in range(24)
+})
+
+
+def _token_from_lexer_state(
+ bold: bool,
+ faint: bool,
+ fg_color: str | None,
+ bg_color: str | None,
+) -> pygments.token._TokenType:
+ """Construct a token given the current lexer state.
+
+ We can only emit one token even though we have a multiple-tuple state.
+ To do work around this, we construct tokens like "Bold.Red".
+ """
+ components: tuple[str, ...] = ()
+
+ if bold:
+ components += ('Bold',)
+
+ if faint:
+ components += ('Faint',)
+
+ if fg_color:
+ components += (fg_color,)
+
+ if bg_color:
+ components += ('BG' + bg_color,)
+
+ if len(components) == 0:
+ return pygments.token.Text
+ else:
+ token = Color
+ for component in components:
+ token = getattr(token, component)
+ return token
+
+
+def color_tokens(
+ fg_colors: dict[str, str],
+ bg_colors: dict[str, str],
+ enable_256color: bool = False,
+) -> dict[pygments.token._TokenType, str]:
+ """Return color tokens for a given set of colors.
+
+ Pygments doesn't have a generic "color" token; instead everything is
+ contextual (e.g. "comment" or "variable"). That doesn't make sense for us,
+ where the colors actually *are* what we care about.
+
+ This function will register combinations of tokens (things like "Red" or
+ "Bold.Red.BGGreen") based on the colors passed in.
+
+ You can also define the tokens yourself, but note that the token names are
+ *not* currently guaranteed to be stable between releases as I'm not really
+ happy with this approach.
+
+ Optionally, you can enable 256-color support by passing
+ `enable_256color=True`. This will (very slightly) increase the CSS size,
+ but enable the use of 256-color in text. The reason this is optional and
+ non-default is that it requires patching the Pygments formatter you're
+ using, using the ExtendedColorHtmlFormatterMixin provided by this file.
+ For more details on why and how, see the README.
+
+ Usage:
+
+ fg_colors = bg_colors = {
+ 'Black': '#000000',
+ 'Red': '#EF2929',
+ 'Green': '#8AE234',
+ 'Yellow': '#FCE94F',
+ 'Blue': '#3465A4',
+ 'Magenta': '#c509c5',
+ 'Cyan': '#34E2E2',
+ 'White': '#ffffff',
+ }
+ class MyStyle(pygments.styles.SomeStyle):
+ styles = dict(pygments.styles.SomeStyle.styles)
+ styles.update(color_tokens(fg_colors, bg_colors))
+ """
+ styles: dict[pygments.token._TokenType, str] = {}
+
+ if enable_256color:
+ styles[pygments.token.Token.C.Bold] = 'bold'
+ styles[pygments.token.Token.C.Faint] = ''
+ for i, color in _256_colors.items():
+ styles[getattr(pygments.token.Token.C, f'C{i}')] = color
+ styles[getattr(pygments.token.Token.C, f'BGC{i}')] = f'bg:{color}'
+
+ for color, color_value in fg_colors.items():
+ styles[getattr(C, color)] = color_value
+
+ for color, color_value in bg_colors.items():
+ styles[getattr(C, f'BG{color}')] = f'bg:{color_value}'
+ else:
+ for bold, faint, fg_color, bg_color in itertools.product(
+ (False, True),
+ (False, True),
+ {None} | set(fg_colors),
+ {None} | set(bg_colors),
+ ):
+ token = _token_from_lexer_state(bold, faint, fg_color, bg_color)
+ if token is not pygments.token.Text:
+ value: list[str] = []
+ if bold:
+ value.append('bold')
+ if fg_color:
+ value.append(fg_colors[fg_color])
+ if bg_color:
+ value.append('bg:' + bg_colors[bg_color])
+ styles[token] = ' '.join(value)
+
+ return styles
+
+
+class AnsiColorLexer(pygments.lexer.RegexLexer):
+ name = 'ANSI Color'
+ aliases = ('ansi-color', 'ansi', 'ansi-terminal')
+ flags = re.DOTALL | re.MULTILINE
+
+ bold: bool
+ fant: bool
+ fg_color: str | None
+ bg_color: str | None
+
+ def __init__(self, *args: typing.Any, **kwargs: typing.Any) -> None:
+ super().__init__(*args, **kwargs)
+ self.reset_state()
+
+ def reset_state(self) -> None:
+ self.bold = False
+ self.faint = False
+ self.fg_color = None
+ self.bg_color = None
+
+ @property
+ def current_token(self) -> pygments.token._TokenType:
+ return _token_from_lexer_state(
+ self.bold, self.faint, self.fg_color, self.bg_color,
+ )
+
+ def process(
+ self,
+ match: re.Match[str],
+ ) -> typing.Generator[
+ tuple[int, pygments.token._TokenType, str],
+ None,
+ None,
+ ]:
+ """Produce the next token and bit of text.
+
+ Interprets the ANSI code (which may be a color code or some other
+ code), changing the lexer state and producing a new token. If it's not
+ a color code, we just strip it out and move on.
+
+ Some useful reference for ANSI codes:
+ * http://ascii-table.com/ansi-escape-sequences.php
+ """
+ # "after_escape" contains everything after the start of the escape
+ # sequence, up to the next escape sequence. We still need to separate
+ # the content from the end of the escape sequence.
+ after_escape = match.group(1)
+
+ # TODO: this doesn't handle the case where the values are non-numeric.
+ # This is rare but can happen for keyboard remapping, e.g.
+ # '\x1b[0;59;"A"p'
+ parsed = re.match(
+ r'([0-9;=]*?)?([a-zA-Z])(.*)$',
+ after_escape,
+ re.DOTALL | re.MULTILINE,
+ )
+ if parsed is None:
+ # This shouldn't ever happen if we're given valid text + ANSI, but
+ # people can provide us with utter junk, and we should tolerate it.
+ text = after_escape
+ else:
+ value, code, text = parsed.groups()
+ if code == 'm': # "m" is "Set Graphics Mode"
+ # Special case \x1b[m is a reset code
+ if value == '':
+ self.reset_state()
+ else:
+ try:
+ values = [int(v) for v in value.split(';')]
+ except ValueError:
+ # Shouldn't ever happen, but could with invalid ANSI.
+ values = []
+
+ while len(values) > 0:
+ value = values.pop(0)
+ fg_color = _ansi_code_to_color.get(value - 30)
+ bg_color = _ansi_code_to_color.get(value - 40)
+ if fg_color:
+ self.fg_color = fg_color
+ elif bg_color:
+ self.bg_color = bg_color
+ elif value == 1:
+ self.bold = True
+ elif value == 2:
+ self.faint = True
+ elif value == 22:
+ self.bold = False
+ self.faint = False
+ elif value == 39:
+ self.fg_color = None
+ elif value == 49:
+ self.bg_color = None
+ elif value == 0:
+ self.reset_state()
+ elif value in (38, 48):
+ try:
+ five = values.pop(0)
+ color = values.pop(0)
+ except IndexError:
+ continue
+ else:
+ if five != 5:
+ continue
+ if 0 <= color <= 255:
+ if value == 38:
+ self.fg_color = f'C{color}'
+ else:
+ self.bg_color = f'C{color}'
+
+ yield match.start(), self.current_token, text
+
+ def ignore_unknown_escape(self, match: re.Match[str]) -> typing.Generator[
+ tuple[int, pygments.token._TokenType, str],
+ None,
+ None,
+ ]:
+ after = match.group(1)
+ # mypy prints these out because it uses curses to determine colors
+ # http://ascii-table.com/ansi-escape-sequences-vt-100.php
+ if re.match(r'\([AB012]', after):
+ yield match.start(), self.current_token, after[2:]
+ else:
+ yield match.start(), self.current_token, after
+
+ tokens = {
+ # states have to be native strings
+ 'root': [
+ (r'\x1b\[([^\x1b]*)', process),
+ (r'\x1b([^\x1b]*)', ignore_unknown_escape),
+ (r'[^\x1b]+', pygments.token.Text),
+ ],
+ }
+
+
+class ExtendedColorHtmlFormatterMixin:
+
+ def _get_css_classes(self, token: pygments.token._TokenType) -> str:
+ classes = super()._get_css_classes(token) # type: ignore
+ if token[0] == 'Color':
+ classes += ' ' + ' '.join(
+ self._get_css_class(getattr(C, part)) # type: ignore
+ for part in token[1:]
+ )
+ return classes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/pygments_ansi_color.py
new/pygments-ansi-color-0.1.0/pygments_ansi_color.py
--- old/pygments-ansi-color-0.0.5/pygments_ansi_color.py 2020-01-07
20:36:45.000000000 +0100
+++ new/pygments-ansi-color-0.1.0/pygments_ansi_color.py 1970-01-01
01:00:00.000000000 +0100
@@ -1,277 +0,0 @@
-# -*- coding: utf-8 -*-
-"""Pygments lexer for text containing ANSI color codes."""
-from __future__ import absolute_import
-from __future__ import unicode_literals
-
-import itertools
-import re
-
-import pygments.lexer
-import pygments.token
-
-
-C = pygments.token.Token.C
-Color = pygments.token.Token.Color
-
-
-_ansi_code_to_color = {
- 0: 'Black',
- 1: 'Red',
- 2: 'Green',
- 3: 'Yellow',
- 4: 'Blue',
- 5: 'Magenta',
- 6: 'Cyan',
- 7: 'White',
-}
-
-_256_colors = {
- 0: '#000000',
- 1: '#800000',
- 2: '#008000',
- 3: '#808000',
- 4: '#000080',
- 5: '#800080',
- 6: '#008080',
- 7: '#c0c0c0',
- 8: '#808080',
- 9: '#ff0000',
- 10: '#00ff00',
- 11: '#ffff00',
- 12: '#0000ff',
- 13: '#ff00ff',
- 14: '#00ffff',
- 15: '#ffffff',
-}
-_vals = (0, 95, 135, 175, 215, 255)
-_256_colors.update({
- 16 + i: '#{:02x}{:02x}{:02x}'.format(*rgb)
- for i, rgb in enumerate(itertools.product(_vals, _vals, _vals))
-})
-_256_colors.update({
- 232 + i: '#{0:02x}{0:02x}{0:02x}'.format(10 * i + 8)
- for i in range(24)
-})
-
-
-def _token_from_lexer_state(bold, faint, fg_color, bg_color):
- """Construct a token given the current lexer state.
-
- We can only emit one token even though we have a multiple-tuple state.
- To do work around this, we construct tokens like "Bold.Red".
- """
- components = ()
-
- if bold:
- components += ('Bold',)
-
- if faint:
- components += ('Faint',)
-
- if fg_color:
- components += (fg_color,)
-
- if bg_color:
- components += ('BG' + bg_color,)
-
- if len(components) == 0:
- return pygments.token.Text
- else:
- token = Color
- for component in components:
- token = getattr(token, component)
- return token
-
-
-def color_tokens(fg_colors, bg_colors, enable_256color=False):
- """Return color tokens for a given set of colors.
-
- Pygments doesn't have a generic "color" token; instead everything is
- contextual (e.g. "comment" or "variable"). That doesn't make sense for us,
- where the colors actually *are* what we care about.
-
- This function will register combinations of tokens (things like "Red" or
- "Bold.Red.BGGreen") based on the colors passed in.
-
- You can also define the tokens yourself, but note that the token names are
- *not* currently guaranteed to be stable between releases as I'm not really
- happy with this approach.
-
- Optionally, you can enable 256-color support by passing
- `enable_256color=True`. This will (very slightly) increase the CSS size,
- but enable the use of 256-color in text. The reason this is optional and
- non-default is that it requires patching the Pygments formatter you're
- using, using the ExtendedColorHtmlFormatterMixin provided by this file.
- For more details on why and how, see the README.
-
- Usage:
-
- fg_colors = bg_colors = {
- 'Black': '#000000',
- 'Red': '#EF2929',
- 'Green': '#8AE234',
- 'Yellow': '#FCE94F',
- 'Blue': '#3465A4',
- 'Magenta': '#c509c5',
- 'Cyan': '#34E2E2',
- 'White': '#ffffff',
- }
- class MyStyle(pygments.styles.SomeStyle):
- styles = dict(pygments.styles.SomeStyle.styles)
- styles.update(color_tokens(fg_colors, bg_colors))
- """
- styles = {}
-
- if enable_256color:
- styles[pygments.token.Token.C.Bold] = 'bold'
- styles[pygments.token.Token.C.Faint] = ''
- for i, color in _256_colors.items():
- styles[getattr(pygments.token.Token.C, 'C{}'.format(i))] = color
- styles[getattr(pygments.token.Token.C, 'BGC{}'.format(i))] =
'bg:{}'.format(color)
-
- for color, value in fg_colors.items():
- styles[getattr(C, color)] = value
-
- for color, value in bg_colors.items():
- styles[getattr(C, 'BG{}'.format(color))] = 'bg:{}'.format(value)
- else:
- for bold, faint, fg_color, bg_color in itertools.product(
- (False, True),
- (False, True),
- {None} | set(fg_colors),
- {None} | set(bg_colors),
- ):
- token = _token_from_lexer_state(bold, faint, fg_color, bg_color)
- if token is not pygments.token.Text:
- value = []
- if bold:
- value.append('bold')
- if fg_color:
- value.append(fg_colors[fg_color])
- if bg_color:
- value.append('bg:' + bg_colors[bg_color])
- styles[token] = ' '.join(value)
-
- return styles
-
-
-class AnsiColorLexer(pygments.lexer.RegexLexer):
- name = 'ANSI Color'
- aliases = ('ansi-color', 'ansi', 'ansi-terminal')
- flags = re.DOTALL | re.MULTILINE
-
- def __init__(self, *args, **kwargs):
- super(AnsiColorLexer, self).__init__(*args, **kwargs)
- self.reset_state()
-
- def reset_state(self):
- self.bold = False
- self.faint = False
- self.fg_color = None
- self.bg_color = None
-
- @property
- def current_token(self):
- return _token_from_lexer_state(
- self.bold, self.faint, self.fg_color, self.bg_color,
- )
-
- def process(self, match):
- """Produce the next token and bit of text.
-
- Interprets the ANSI code (which may be a color code or some other
- code), changing the lexer state and producing a new token. If it's not
- a color code, we just strip it out and move on.
-
- Some useful reference for ANSI codes:
- * http://ascii-table.com/ansi-escape-sequences.php
- """
- # "after_escape" contains everything after the start of the escape
- # sequence, up to the next escape sequence. We still need to separate
- # the content from the end of the escape sequence.
- after_escape = match.group(1)
-
- # TODO: this doesn't handle the case where the values are non-numeric.
- # This is rare but can happen for keyboard remapping, e.g.
- # '\x1b[0;59;"A"p'
- parsed = re.match(
- r'([0-9;=]*?)?([a-zA-Z])(.*)$',
- after_escape,
- re.DOTALL | re.MULTILINE,
- )
- if parsed is None:
- # This shouldn't ever happen if we're given valid text + ANSI, but
- # people can provide us with utter junk, and we should tolerate it.
- text = after_escape
- else:
- value, code, text = parsed.groups()
- if code == 'm': # "m" is "Set Graphics Mode"
- # Special case \x1b[m is a reset code
- if value == '':
- self.reset_state()
- else:
- try:
- values = [int(v) for v in value.split(';')]
- except ValueError:
- # Shouldn't ever happen, but could with invalid ANSI.
- values = []
-
- while len(values) > 0:
- value = values.pop(0)
- fg_color = _ansi_code_to_color.get(value - 30)
- bg_color = _ansi_code_to_color.get(value - 40)
- if fg_color:
- self.fg_color = fg_color
- elif bg_color:
- self.bg_color = bg_color
- elif value == 1:
- self.bold = True
- elif value == 2:
- self.faint = True
- elif value == 22:
- self.bold = False
- self.faint = False
- elif value == 39:
- self.fg_color = None
- elif value == 49:
- self.bg_color = None
- elif value == 0:
- self.reset_state()
- elif value in (38, 48):
- try:
- five = values.pop(0)
- color = values.pop(0)
- except IndexError:
- continue
- else:
- if five != 5:
- continue
- if not 0 <= color <= 255:
- continue
- color = 'C{}'.format(color)
- if value == 38:
- self.fg_color = color
- else:
- self.bg_color = color
-
- yield match.start(), self.current_token, text
-
- tokens = {
- # states have to be native strings
- str('root'): [
- (r'\x1b\[([^\x1b]*)', process),
- (r'[^\x1b]+', pygments.token.Text),
- ],
- }
-
-
-class ExtendedColorHtmlFormatterMixin(object):
-
- def _get_css_classes(self, token):
- classes = super(ExtendedColorHtmlFormatterMixin,
self)._get_css_classes(token)
- if token[0] == 'Color':
- classes += ' ' + ' '.join(
- self._get_css_class(getattr(C, part))
- for part in token[1:]
- )
- return classes
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/requirements-dev.txt
new/pygments-ansi-color-0.1.0/requirements-dev.txt
--- old/pygments-ansi-color-0.0.5/requirements-dev.txt 2020-01-07
20:36:45.000000000 +0100
+++ new/pygments-ansi-color-0.1.0/requirements-dev.txt 2022-09-14
01:40:08.000000000 +0200
@@ -1,3 +1,5 @@
coverage
+mypy
pre-commit>=1.0.0
pytest
+types-pygments
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/setup.cfg
new/pygments-ansi-color-0.1.0/setup.cfg
--- old/pygments-ansi-color-0.0.5/setup.cfg 2020-01-07 20:36:45.000000000
+0100
+++ new/pygments-ansi-color-0.1.0/setup.cfg 1970-01-01 01:00:00.000000000
+0100
@@ -1,2 +0,0 @@
-[wheel]
-universal = True
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/setup.py
new/pygments-ansi-color-0.1.0/setup.py
--- old/pygments-ansi-color-0.0.5/setup.py 2020-01-07 20:36:45.000000000
+0100
+++ new/pygments-ansi-color-0.1.0/setup.py 2022-09-14 01:40:08.000000000
+0200
@@ -1,22 +1,25 @@
-# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import annotations
from setuptools import setup
setup(
name='pygments-ansi-color',
- version='0.0.5',
+ version='0.1.0',
classifiers=[
'License :: OSI Approved :: Apache Software License',
- 'Programming Language :: Python :: 2',
- 'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
- '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',
],
- install_requires=['pygments'],
- py_modules=['pygments_ansi_color'],
+ python_requires='>=3.7',
+ install_requires=['pygments!=2.7.3'],
+ packages=['pygments_ansi_color'],
+ package_data={
+ 'pygments_ansi_color': ['py.typed'],
+ },
entry_points={
'pygments.lexers': [
'ansi_color = pygments_ansi_color:AnsiColorLexer',
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore'
old/pygments-ansi-color-0.0.5/tests/pygments_ansi_color_test.py
new/pygments-ansi-color-0.1.0/tests/pygments_ansi_color_test.py
--- old/pygments-ansi-color-0.0.5/tests/pygments_ansi_color_test.py
2020-01-07 20:36:45.000000000 +0100
+++ new/pygments-ansi-color-0.1.0/tests/pygments_ansi_color_test.py
2022-09-14 01:40:08.000000000 +0200
@@ -1,6 +1,4 @@
-# -*- coding: utf-8 -*-
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import annotations
import itertools
@@ -55,21 +53,25 @@
fg_colors = {'Red': '#ff0000'}
bg_colors = {'Green': '#00ff00'}
- expected = dict(itertools.chain.from_iterable(
- (
- (getattr(C, 'C{}'.format(i)), value),
- (getattr(C, 'BGC{}'.format(i)), 'bg:{}'.format(value)),
- )
- for i, value in main._256_colors.items()
- ))
+ expected = dict(
+ itertools.chain.from_iterable(
+ (
+ (getattr(C, f'C{i}'), value),
+ (getattr(C, f'BGC{i}'), f'bg:{value}'),
+ )
+ for i, value in main._256_colors.items()
+ ),
+ )
expected.update({
C.Red: '#ff0000',
C.BGGreen: 'bg:#00ff00',
C.Bold: 'bold',
C.Faint: '',
})
- assert main.color_tokens(fg_colors, bg_colors,
- enable_256color=True) == expected
+ assert main.color_tokens(
+ fg_colors, bg_colors,
+ enable_256color=True,
+ ) == expected
def _highlight(text):
@@ -93,7 +95,7 @@
'\x1b[43mbold from previous line with yellow bg\n'
'\x1b[49mbg color turned off\n'
'\x1b[2mfaint turned on\n'
- '\x1b[22mbold turned off\n'
+ '\x1b[22mbold turned off\n',
) == (
(Text, 'plain text\n'),
(Color.Red, 'red text\n'),
@@ -115,7 +117,7 @@
'\x1b[1mbold color 15\n'
'\x1b[48;5;8mbold color 15 with color 8 bg\n'
'\x1b[38;5;11;22mnot bold color 11 with color 8 bg\n'
- '\x1b[0mplain text after reset\n'
+ '\x1b[0mplain text after reset\n',
) == (
(Text, 'plain text\n'),
(Color.C15, 'color 15\n'),
@@ -136,7 +138,7 @@
# invalid values (not integers)
'\x1b[38;4=;15mC\n'
# invalid values (color larger than 255)
- '\x1b[38;5;937mD\n'
+ '\x1b[38;5;937mD\n',
) == (
(Text, 'plain text\n'),
(Text, 'A\n'),
@@ -151,18 +153,18 @@
assert ret == ((Text, 'plain'), (Color.Red, 'red'), (Text, 'plain\n'))
-def test_ignores_unrecognized_ansi_color_codes():
[email protected](
+ 's',
+ (
+ pytest.param('\x1b[99m' 'plain text\n', id='unknown int code'),
+ pytest.param('\x1b[=m' 'plain text\n', id='invalid non-int code'),
+ pytest.param('\x1b(B' 'plain text\n', id='other unknown vt100 code'),
+ pytest.param('\x1b' 'plain text\n', id='stray ESC'),
+ ),
+)
+def test_ignores_unrecognized_ansi_color_codes(s):
"""It should just strip and ignore any unrecognized color ANSI codes."""
- assert _highlight(
- # unknown int code
- '\x1b[99m' 'plain text\n'
-
- # invalid non-int code
- '\x1b[=m' 'plain text\n'
- ) == (
- (Text, 'plain text\n'),
- (Text, 'plain text\n'),
- )
+ assert _highlight(s) == ((Text, 'plain text\n'),)
def test_ignores_valid_ansi_non_color_codes():
@@ -174,7 +176,7 @@
# restore cursor position
'\x1b[u' 'plain '
# move cursor backwards 55 steps
- '\x1b[55C' 'text\n'
+ '\x1b[55C' 'text\n',
) == (
# Ideally these would be just one token, but our regex isn't smart
# enough yet.
@@ -190,7 +192,7 @@
followed by garbage.
"""
assert _highlight(
- 'plain \x1b[%text\n'
+ 'plain \x1b[%text\n',
) == (
(Text, 'plain '),
(Text, '%text\n'),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/pygments-ansi-color-0.0.5/tox.ini
new/pygments-ansi-color-0.1.0/tox.ini
--- old/pygments-ansi-color-0.0.5/tox.ini 2020-01-07 20:36:45.000000000
+0100
+++ new/pygments-ansi-color-0.1.0/tox.ini 2022-09-14 01:40:08.000000000
+0200
@@ -1,5 +1,5 @@
[tox]
-envlist = py27,py36
+envlist = py39
tox_pip_extensions_ext_venv_update = true
tox_pip_extensions_ext_pip_custom_platform = true
@@ -10,11 +10,12 @@
coverage erase
coverage run -m pytest {posargs:tests}
coverage report --fail-under 100
+ mypy pygments_ansi_color
pre-commit install -f --install-hooks
pre-commit run --all-files
[testenv:venv]
-basepython = /usr/bin/python3.6
+basepython = /usr/bin/python3.9
envdir = venv
commands =