4242from typing import Any , Callable , Dict , List , Mapping , Optional , Tuple , Type , Union , IO
4343
4444import colorama
45+ from colorama import Fore
4546
4647from . import constants
4748from . import plugin
5859 rl_warning = "Readline features including tab completion have been disabled since no \n " \
5960 "supported version of readline was found. To resolve this, install \n " \
6061 "pyreadline on Windows or gnureadline on Mac.\n \n "
61- sys .stderr .write (constants . WARNING_COLOR + rl_warning + constants . RESET_COLOR )
62+ sys .stderr .write (Fore . LIGHTYELLOW_EX + rl_warning + Fore . RESET )
6263else :
6364 from .rl_utils import rl_force_redisplay , readline
6465
@@ -615,7 +616,7 @@ def poutput(self, msg: Any, end: str = '\n', color: str = '') -> None:
615616 if not msg_str .endswith (end ):
616617 msg_str += end
617618 if color :
618- msg_str = color + msg_str + constants . RESET_COLOR
619+ msg_str = color + msg_str + Fore . RESET
619620 self .decolorized_write (self .stdout , msg_str )
620621 except BrokenPipeError :
621622 # This occurs if a command's output is being piped to another
@@ -626,8 +627,8 @@ def poutput(self, msg: Any, end: str = '\n', color: str = '') -> None:
626627 if self .broken_pipe_warning :
627628 sys .stderr .write (self .broken_pipe_warning )
628629
629- def perror (self , err : Union [str , Exception ], traceback_war : bool = True , err_color : str = constants . ERROR_COLOR ,
630- war_color : str = constants . WARNING_COLOR ) -> None :
630+ def perror (self , err : Union [str , Exception ], traceback_war : bool = True , err_color : str = Fore . LIGHTRED_EX ,
631+ war_color : str = Fore . LIGHTYELLOW_EX ) -> None :
631632 """ Print error message to sys.stderr and if debug is true, print an exception Traceback if one exists.
632633
633634 :param err: an Exception or error message to print out
@@ -643,12 +644,12 @@ def perror(self, err: Union[str, Exception], traceback_war: bool = True, err_col
643644 err_msg = "EXCEPTION of type '{}' occurred with message: '{}'\n " .format (type (err ).__name__ , err )
644645 else :
645646 err_msg = "{}\n " .format (err )
646- err_msg = err_color + err_msg + constants . RESET_COLOR
647+ err_msg = err_color + err_msg + Fore . RESET
647648 self .decolorized_write (sys .stderr , err_msg )
648649
649650 if traceback_war and not self .debug :
650651 war = "To enable full traceback, run the following command: 'set debug true'\n "
651- war = war_color + war + constants . RESET_COLOR
652+ war = war_color + war + Fore . RESET
652653 self .decolorized_write (sys .stderr , war )
653654
654655 def pfeedback (self , msg : str ) -> None :
@@ -3574,7 +3575,7 @@ def _generate_transcript(self, history: List[Union[HistoryItem, str]], transcrip
35743575 # Check if all commands ran
35753576 if commands_run < len (history ):
35763577 warning = "Command {} triggered a stop and ended transcript generation early" .format (commands_run )
3577- self .perror (warning , err_color = constants . WARNING_COLOR , traceback_war = False )
3578+ self .perror (warning , err_color = Fore . LIGHTYELLOW_EX , traceback_war = False )
35783579
35793580 # finally, we can write the transcript out to the file
35803581 try :
@@ -3739,7 +3740,7 @@ class TestMyAppCase(Cmd2TestCase):
37393740 test_results = runner .run (testcase )
37403741 if test_results .wasSuccessful ():
37413742 self .decolorized_write (sys .stderr , stream .read ())
3742- self .poutput ('Tests passed' , color = constants . SUCCESS_COLOR )
3743+ self .poutput ('Tests passed' , color = Fore . LIGHTGREEN_EX )
37433744 else :
37443745 # Strip off the initial traceback which isn't particularly useful for end users
37453746 error_str = stream .read ()
0 commit comments