Handle the case in which colorama is not installed.
This commit is contained in:
parent
5ddc83e3ff
commit
956b3c6053
1 changed files with 6 additions and 3 deletions
|
@ -1,5 +1,8 @@
|
||||||
import argparse
|
import argparse
|
||||||
import colorama
|
try:
|
||||||
|
import colorama
|
||||||
|
except ImportError:
|
||||||
|
colorama = None
|
||||||
import io
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
@ -131,7 +134,7 @@ def make_helptext(
|
||||||
# Even though this text is going out on stderr, we only colorize it if
|
# Even though this text is going out on stderr, we only colorize it if
|
||||||
# both stdout and stderr are tty because as soon as pipe buffers are
|
# both stdout and stderr are tty because as soon as pipe buffers are
|
||||||
# involved, even on stdout, things start to get weird.
|
# involved, even on stdout, things start to get weird.
|
||||||
if do_colors and pipeable.stdout_tty() and pipeable.stderr_tty():
|
if do_colors and colorama and pipeable.stdout_tty() and pipeable.stderr_tty():
|
||||||
colorama.init()
|
colorama.init()
|
||||||
color = dotdict.DotDict(
|
color = dotdict.DotDict(
|
||||||
positional=colorama.Style.BRIGHT + colorama.Fore.CYAN,
|
positional=colorama.Style.BRIGHT + colorama.Fore.CYAN,
|
||||||
|
@ -148,7 +151,7 @@ def make_helptext(
|
||||||
flag='',
|
flag='',
|
||||||
command='',
|
command='',
|
||||||
reset='',
|
reset='',
|
||||||
required_asterisk=colorama.Style.BRIGHT + colorama.Fore.RED + '(*)' + colorama.Style.RESET_ALL,
|
required_asterisk='(*)',
|
||||||
)
|
)
|
||||||
|
|
||||||
if program_name is None:
|
if program_name is None:
|
||||||
|
|
Loading…
Reference in a new issue