##// END OF EJS Templates
run-tests: add a function to colorize a piece of text...
marmoute -
r53409:c2ee1ad7 default
parent child Browse files
Show More
@@ -97,6 +97,7 try: # is pygments installed
97 import pygments.formatters as formatters
97 import pygments.formatters as formatters
98 import pygments.token as token
98 import pygments.token as token
99 import pygments.style as style
99 import pygments.style as style
100 from pygments.console import ansiformat
100
101
101 if WINDOWS:
102 if WINDOWS:
102 hgpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
103 hgpath = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@@ -113,8 +114,17 try: # is pygments installed
113 pygmentspresent = True
114 pygmentspresent = True
114 difflexer = lexers.DiffLexer()
115 difflexer = lexers.DiffLexer()
115 terminal256formatter = formatters.Terminal256Formatter()
116 terminal256formatter = formatters.Terminal256Formatter()
117
118 def colorize(text: str, style: str, color: bool = True) -> str:
119 if not color:
120 return text
121 return ansiformat(style, text)
122
116 except ImportError:
123 except ImportError:
117 pass
124
125 def colorize(text: str, style: str, color: bool = True) -> str:
126 return text
127
118
128
119 progress_type = {}
129 progress_type = {}
120
130
General Comments 0
You need to be logged in to leave comments. Login now