mirror of
https://github.com/Farama-Foundation/Gymnasium.git
synced 2025-08-01 14:10:30 +00:00
* remove six * remove __future__ imports * remove six from setup.py, python 2.7 from README.rst
31 lines
738 B
Python
31 lines
738 B
Python
"""A set of common utilities used within the environments. These are
|
|
not intended as API functions, and will not remain stable over time.
|
|
"""
|
|
|
|
color2num = dict(
|
|
gray=30,
|
|
red=31,
|
|
green=32,
|
|
yellow=33,
|
|
blue=34,
|
|
magenta=35,
|
|
cyan=36,
|
|
white=37,
|
|
crimson=38
|
|
)
|
|
|
|
|
|
def colorize(string, color, bold=False, highlight = False):
|
|
"""Return string surrounded by appropriate terminal color codes to
|
|
print colorized text. Valid colors: gray, red, green, yellow,
|
|
blue, magenta, cyan, white, crimson
|
|
"""
|
|
|
|
attr = []
|
|
num = color2num[color]
|
|
if highlight: num += 10
|
|
attr.append(str(num))
|
|
if bold: attr.append('1')
|
|
attrs = ';'.join(attr)
|
|
return '\x1b[%sm%s\x1b[0m' % (attrs, string)
|