awscli2/awscli2-remove-colorama.patch
Major Hayden 53e1810c55
Initial package
Resolves: RHEL-14523

Signed-off-by: Major Hayden <major@redhat.com>
2024-05-01 09:10:37 -05:00

270 lines
9.2 KiB
Diff

From 0fd1ede2fd0c1898ff8360afd210c4ff3d22034f Mon Sep 17 00:00:00 2001
From: Major Hayden <major@mhtx.net>
Date: Wed, 1 May 2024 08:42:55 -0500
Subject: [PATCH] Remove colorama
---
awscli/customizations/configure/sso.py | 5 ++--
awscli/customizations/history/show.py | 11 +------
awscli/customizations/logs/tail.py | 10 ++-----
awscli/formatter.py | 3 +-
awscli/table.py | 29 +------------------
exe/pyinstaller/hook-awscli.py | 1 -
pyproject.toml | 3 +-
.../build_system/functional/test_utils.py | 4 ---
tests/backends/test_pep517.py | 1 -
tests/dependencies/test_closure.py | 1 -
10 files changed, 8 insertions(+), 60 deletions(-)
diff --git a/awscli/customizations/configure/sso.py b/awscli/customizations/configure/sso.py
index 5a650a367..881cc9bd5 100644
--- a/awscli/customizations/configure/sso.py
+++ b/awscli/customizations/configure/sso.py
@@ -17,7 +17,6 @@ import os
import logging
import re
-import colorama
from botocore import UNSIGNED
from botocore.config import Config
from botocore.configprovider import ConstantProvider
@@ -619,10 +618,10 @@ class ConfigureSSOCommand(BaseSSOConfigurationCommand):
def _warn_configuring_using_legacy_format(self):
uni_print(
- f'{colorama.Style.BRIGHT}WARNING: Configuring using legacy format '
+ f'WARNING: Configuring using legacy format '
f'(e.g. without an SSO session).\n'
f'Consider re-running "configure sso" command and providing '
- f'a session name.\n{colorama.Style.RESET_ALL}'
+ f'a session name.\n'
)
def _prompt_for_sso_account_and_role(self, sso, sso_token):
diff --git a/awscli/customizations/history/show.py b/awscli/customizations/history/show.py
index 587bc13de..0eac9f7db 100644
--- a/awscli/customizations/history/show.py
+++ b/awscli/customizations/history/show.py
@@ -16,8 +16,6 @@ import sys
import xml.parsers.expat
import xml.dom.minidom
-import colorama
-
from awscli.table import COLORAMA_KWARGS
from awscli.compat import six
from awscli.customizations.history.commands import HistorySubcommand
@@ -169,19 +167,12 @@ class DetailedFormatter(Formatter):
},
}
- _COMPONENT_COLORS = {
- 'title': colorama.Style.BRIGHT,
- 'description': colorama.Fore.CYAN
- }
-
def __init__(self, output=None, include=None, exclude=None, colorize=True):
super(DetailedFormatter, self).__init__(output, include, exclude)
self._request_id_to_api_num = {}
self._num_api_calls = 0
self._colorize = colorize
self._value_pformatter = SectionValuePrettyFormatter()
- if self._colorize:
- colorama.init(**COLORAMA_KWARGS)
def _display(self, event_record):
section_definition = self._SECTIONS.get(event_record['event_type'])
@@ -254,7 +245,7 @@ class DetailedFormatter(Formatter):
def _color_if_configured(self, text, component):
if self._colorize:
color = self._COMPONENT_COLORS[component]
- return color + text + colorama.Style.RESET_ALL
+ return color + text
return text
diff --git a/awscli/customizations/logs/tail.py b/awscli/customizations/logs/tail.py
index cb3151003..3a26827c5 100644
--- a/awscli/customizations/logs/tail.py
+++ b/awscli/customizations/logs/tail.py
@@ -18,7 +18,6 @@ import time
from botocore.utils import parse_timestamp, datetime2timestamp
from dateutil import tz
-import colorama
from awscli.compat import get_stdout_text_writer
from awscli.utils import is_a_tty
@@ -27,21 +26,16 @@ from awscli.customizations.commands import BasicCommand
class BaseLogEventsFormatter(object):
- _TIMESTAMP_COLOR = colorama.Fore.GREEN
- _STREAM_NAME_COLOR = colorama.Fore.CYAN
-
- def __init__(self, output, colorize=True):
+ def __init__(self, output, colorize=False):
self._output = output
self._colorize = colorize
- if self._colorize:
- colorama.init(autoreset=True, strip=False)
def display_log_event(self, log_event):
raise NotImplementedError('display_log_event()')
def _color_if_configured(self, text, color):
if self._colorize:
- return color + text + colorama.Style.RESET_ALL
+ return color + text
return text
def _write_log_event(self, log_event):
diff --git a/awscli/formatter.py b/awscli/formatter.py
index 78566dd35..38f003859 100644
--- a/awscli/formatter.py
+++ b/awscli/formatter.py
@@ -18,7 +18,7 @@ from botocore.utils import set_value_from_jmespath
from botocore.paginate import PageIterator
from ruamel.yaml import YAML
-from awscli.table import MultiTable, Styler, ColorizedStyler
+from awscli.table import MultiTable, Styler
from awscli import text
from awscli import compat
from awscli.utils import json_encoder
@@ -206,7 +206,6 @@ class TableFormatter(FullyBufferedFormatter):
self.table = MultiTable(initial_section=False,
column_separator='|', styler=styler)
elif args.color == 'on':
- styler = ColorizedStyler()
self.table = MultiTable(initial_section=False,
column_separator='|', styler=styler)
else:
diff --git a/awscli/table.py b/awscli/table.py
index df96392fc..ba3cfb9d0 100644
--- a/awscli/table.py
+++ b/awscli/table.py
@@ -14,8 +14,6 @@ import sys
import struct
import unicodedata
-import colorama
-
from awscli.utils import is_a_tty
from awscli.compat import six
@@ -161,28 +159,6 @@ class Styler(object):
return text
-class ColorizedStyler(Styler):
- def __init__(self):
- colorama.init(**COLORAMA_KWARGS)
-
- def style_title(self, text):
- # Originally bold + underline
- return text
- #return colorama.Style.BOLD + text + colorama.Style.RESET_ALL
-
- def style_header_column(self, text):
- # Originally underline
- return text
-
- def style_row_element(self, text):
- return (colorama.Style.BRIGHT + colorama.Fore.BLUE +
- text + colorama.Style.RESET_ALL)
-
- def style_indentation_char(self, text):
- return (colorama.Style.DIM + colorama.Fore.YELLOW +
- text + colorama.Style.RESET_ALL)
-
-
class MultiTable(object):
def __init__(self, terminal_width=None, initial_section=True,
column_separator='|', terminal=None,
@@ -196,10 +172,7 @@ class MultiTable(object):
self._sections = []
if styler is None:
# Move out to factory.
- if is_a_tty():
- self._styler = ColorizedStyler()
- else:
- self._styler = Styler()
+ self._styler = Styler()
else:
self._styler = styler
self._rendering_index = 0
diff --git a/exe/pyinstaller/hook-awscli.py b/exe/pyinstaller/hook-awscli.py
index 617b71d92..2ea109556 100644
--- a/exe/pyinstaller/hook-awscli.py
+++ b/exe/pyinstaller/hook-awscli.py
@@ -9,7 +9,6 @@ hiddenimports = [
'configparser',
'xml.etree',
'pipes',
- 'colorama',
'awscli.handlers',
# NOTE: This can be removed once this hidden import issue related to
# setuptools and PyInstaller is resolved:
diff --git a/pyproject.toml b/pyproject.toml
index 76c757b68..4d4165444 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -28,7 +28,6 @@ classifiers = [
"Programming Language :: Python :: 3.11",
]
dependencies = [
- "colorama>=0.2.5,<0.4.7",
"docutils>=0.10,<0.20",
"cryptography>=3.3.2,<40.0.2",
"ruamel.yaml>=0.15.0,<=0.17.21",
@@ -98,4 +97,4 @@ filterwarnings = [
]
[tool.black]
-line-length = 80
\ No newline at end of file
+line-length = 80
diff --git a/tests/backends/build_system/functional/test_utils.py b/tests/backends/build_system/functional/test_utils.py
index 683cc7ab2..c93b0074e 100644
--- a/tests/backends/build_system/functional/test_utils.py
+++ b/tests/backends/build_system/functional/test_utils.py
@@ -39,10 +39,6 @@ def utils():
"flit_core>=3.7.1,<3.7.2",
Requirement("flit_core", ">=3.7.1", "<3.7.2"),
),
- (
- "colorama>=0.2.5,<0.4.4",
- Requirement("colorama", ">=0.2.5", "<0.4.4"),
- ),
("docutils>=0.10,<0.16", Requirement("docutils", ">=0.10", "<0.16")),
(
"cryptography>=3.3.2,<37.0.0",
diff --git a/tests/backends/test_pep517.py b/tests/backends/test_pep517.py
index 5f60e04eb..ef763c81a 100644
--- a/tests/backends/test_pep517.py
+++ b/tests/backends/test_pep517.py
@@ -242,7 +242,6 @@ def test_get_requires_for_build_wheel(config_settings, repo_root):
config_settings
)
expected_requirements = [
- "colorama",
"docutils",
"cryptography",
"ruamel.yaml",
diff --git a/tests/dependencies/test_closure.py b/tests/dependencies/test_closure.py
index 6231438cd..fcb38c591 100644
--- a/tests/dependencies/test_closure.py
+++ b/tests/dependencies/test_closure.py
@@ -139,7 +139,6 @@ class TestDependencyClosure:
expected_dependencies = {
"awscrt",
"cffi",
- "colorama",
"cryptography",
"distro",
"docutils",
--
2.44.0