Skip to content

Commit 7b2603e

Browse files
authored
Merge pull request #583 from python-cmd2/delete_colorize
Deleted Cmd.colorize() method and Cmd._colorcodes dictionary
2 parents aad1219 + 6a8af75 commit 7b2603e

File tree

4 files changed

+4
-33
lines changed

4 files changed

+4
-33
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.9.7 (TBD, 2018)
2+
* Deletions (potentially breaking changes)
3+
* Deleted ``Cmd.colorize()`` and ``Cmd._colorcodes`` which were deprecated in 0.9.5
4+
15
## 0.9.6 (October 13, 2018)
26
* Bug Fixes
37
* Fixed bug introduced in 0.9.5 caused by backing up and restoring `self.prompt` in `pseudo_raw_input`.

cmd2/cmd2.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -436,15 +436,6 @@ def __init__(self, completekey: str='tab', stdin=None, stdout=None, persistent_h
436436
# Codes used for exit conditions
437437
self._STOP_AND_EXIT = True # cmd convention
438438

439-
self._colorcodes = {'bold': {True: '\x1b[1m', False: '\x1b[22m'},
440-
'cyan': {True: Fore.CYAN, False: Fore.RESET},
441-
'blue': {True: Fore.BLUE, False: Fore.RESET},
442-
'red': {True: Fore.RED, False: Fore.RESET},
443-
'magenta': {True: Fore.MAGENTA, False: Fore.RESET},
444-
'green': {True: Fore.GREEN, False: Fore.RESET},
445-
'underline': {True: '\x1b[4m', False: Fore.RESET},
446-
'yellow': {True: Fore.YELLOW, False: Fore.RESET}}
447-
448439
# Used load command to store the current script dir as a LIFO queue to support _relative_load command
449440
self._script_dir = []
450441

@@ -714,17 +705,6 @@ def ppaged(self, msg: str, end: str='\n', chop: bool=False) -> None:
714705
if self.broken_pipe_warning:
715706
sys.stderr.write(self.broken_pipe_warning)
716707

717-
def colorize(self, val: str, color: str) -> str:
718-
"""Given a string (``val``), returns that string wrapped in UNIX-style
719-
special characters that turn on (and then off) text color and style.
720-
If the ``colors`` environment parameter is ``False``, or the application
721-
is running on Windows, will return ``val`` unchanged.
722-
``color`` should be one of the supported strings (or styles):
723-
red/blue/green/cyan/magenta, bold, underline"""
724-
if self.colors.lower() != constants.COLORS_NEVER.lower() and (self.stdout == self.initial_stdout):
725-
return self._colorcodes[color][True] + val + self._colorcodes[color][False]
726-
return val
727-
728708
# ----- Methods related to tab completion -----
729709

730710
def reset_completion_defaults(self) -> None:

docs/unfreefeatures.rst

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,6 @@ Always
161161
the output destination
162162

163163

164-
The previously recommended ``colorize`` method is now deprecated.
165-
166-
167164
.. _quiet:
168165

169166
Suppressing non-essential output

tests/test_cmd2.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -855,16 +855,6 @@ def test_base_debug(base_app, capsys):
855855
assert str(err).startswith('Traceback (most recent call last):')
856856

857857

858-
def test_base_colorize(base_app):
859-
# If using base_app test fixture it won't get colorized because we replaced self.stdout
860-
color_test = base_app.colorize('Test', 'red')
861-
assert color_test == 'Test'
862-
863-
# But if we create a fresh Cmd() instance, it will
864-
fresh_app = cmd2.Cmd()
865-
color_test = fresh_app.colorize('Test', 'red')
866-
assert color_test == '\x1b[31mTest\x1b[39m'
867-
868858
def _expected_no_editor_error():
869859
expected_exception = 'OSError'
870860
# If PyPy, expect a different exception than with Python 3

0 commit comments

Comments
 (0)