Add type annotions to irc->ansi color functions

This commit is contained in:
jesopo 2018-11-14 10:28:38 +00:00
parent ca965e20cc
commit bcdbb3640c

View file

@ -144,11 +144,11 @@ def strip_font(s: str) -> str:
s = s.replace(utils.consts.COLOR, "") s = s.replace(utils.consts.COLOR, "")
return s return s
def _color_tokenize(s): def _color_tokens(s: str) -> typing.List[str]:
is_color = False is_color = False
foreground = "" foreground = ""
background = "" background = ""
matches = [] matches = [] # type: typing.List[str]
for char in s: for char in s:
if char == utils.consts.COLOR: if char == utils.consts.COLOR:
@ -173,12 +173,12 @@ def _color_tokenize(s):
background = "" background = ""
return matches return matches
def to_ansi_colors(s): def to_ansi_colors(s: str) -> str:
color = False color = False
ansi_bold = False ansi_bold = False
bold = False bold = False
for token in _color_tokenize(s): for token in _color_tokens(s):
replace = "" replace = ""
type = token[0] type = token[0]