Check SUPPORTS_ANSI when rendering

This commit is contained in:
Richard Hudson 2021-12-29 09:30:35 +01:00
parent 08370604d3
commit 8e55efcbd9

View File

@ -1,8 +1,11 @@
from typing import Dict, List, Optional, Union, cast from typing import Dict, List, Optional, Union, cast
from os import linesep from os import linesep
from spacy.tests.test_visualization import SUPPORTS_ANSI
import wasabi import wasabi
from wasabi.util import supports_ansi
from spacy.tokens import Span, Token, Doc from spacy.tokens import Span, Token, Doc
SUPPORTS_ANSI = supports_ansi()
SPACE = 0 SPACE = 0
HALF_HORIZONTAL_LINE = 1 # the half is the half further away from the root HALF_HORIZONTAL_LINE = 1 # the half is the half further away from the root
@ -116,7 +119,7 @@ class AttributeFormat:
right_padding = " " * (right_pad_to_length - len(value)) right_padding = " " * (right_pad_to_length - len(value))
else: else:
right_padding = "" right_padding = ""
if not ignore_colors and len(value) > 0: if SUPPORTS_ANSI and not ignore_colors and len(value) > 0:
if whole_row_fg_color is not None: if whole_row_fg_color is not None:
fg_color = whole_row_fg_color fg_color = whole_row_fg_color
elif self.value_dependent_fg_colors is not None: elif self.value_dependent_fg_colors is not None: