/
__init__.py
31 lines (24 loc) · 1019 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""\
The ``ansicolor`` object provides ``bg`` and ``fg`` to access colors,
and attributes like bold and
underlined text. It also provides ``reset`` to recover the normal font.
"""
from plumbum.colorlib.factories import StyleFactory
from plumbum.colorlib.styles import Style, ANSIStyle, HTMLStyle, ColorNotFound
ansicolors = StyleFactory(ANSIStyle)
htmlcolors = StyleFactory(HTMLStyle)
def load_ipython_extension(ipython): # pragma: no cover
try:
from plumbum.colorlib._ipython_ext import OutputMagics
except ImportError:
print("IPython required for the IPython extension to be loaded.")
raise
ipython.push({"colors":htmlcolors})
ipython.register_magics(OutputMagics)
def main(): # pragma: no cover
"""Color changing script entry. Call using
python -m plumbum.colors, will reset if no arguments given."""
import sys
color = ' '.join(sys.argv[1:]) if len(sys.argv) > 1 else ''
ansicolors.use_color=True
ansicolors.get_colors_from_string(color).now()