Add type annotations to some functions in color.py.
This commit is contained in:
parent
d5c1538db9
commit
85f3a9eef0
1 changed files with 5 additions and 2 deletions
|
@ -75,7 +75,6 @@ class MatrixHtmlParser(HTMLParser):
|
||||||
self.text = ""
|
self.text = ""
|
||||||
self.attributes["fgcolor"] = color
|
self.attributes["fgcolor"] = color
|
||||||
else:
|
else:
|
||||||
# W.prnt("", "Unhandled tag {t}".format(t=tag))
|
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_endtag(self, tag):
|
def handle_endtag(self, tag):
|
||||||
|
@ -325,6 +324,7 @@ def color_html_to_weechat(color):
|
||||||
|
|
||||||
|
|
||||||
def color_weechat_to_html(color):
|
def color_weechat_to_html(color):
|
||||||
|
# type: (str) -> str
|
||||||
first_16 = {
|
first_16 = {
|
||||||
"black": "black", # 0
|
"black": "black", # 0
|
||||||
"red": "maroon", # 1
|
"red": "maroon", # 1
|
||||||
|
@ -705,6 +705,7 @@ def parse_input_line(line):
|
||||||
|
|
||||||
|
|
||||||
def formatted(strings):
|
def formatted(strings):
|
||||||
|
# type: (List[FormattedString]) -> bool
|
||||||
for string in strings:
|
for string in strings:
|
||||||
if string.attributes != DEFAULT_ATRIBUTES:
|
if string.attributes != DEFAULT_ATRIBUTES:
|
||||||
return True
|
return True
|
||||||
|
@ -782,17 +783,19 @@ def formatted_to_plain(strings):
|
||||||
|
|
||||||
|
|
||||||
def html_to_formatted(html):
|
def html_to_formatted(html):
|
||||||
|
# type: (str) -> FormattedString
|
||||||
parser = MatrixHtmlParser()
|
parser = MatrixHtmlParser()
|
||||||
parser.feed(html)
|
parser.feed(html)
|
||||||
return parser.get_substrings()
|
return parser.get_substrings()
|
||||||
|
|
||||||
|
|
||||||
def string_strikethrough(string):
|
def string_strikethrough(string):
|
||||||
|
# type (str) -> str
|
||||||
return "".join(["{}\u0336".format(c) for c in string])
|
return "".join(["{}\u0336".format(c) for c in string])
|
||||||
|
|
||||||
|
|
||||||
def formatted_to_weechat(W, strings):
|
def formatted_to_weechat(W, strings):
|
||||||
# type: (weechat, List[colors.FormattedString]) -> str
|
# type: (weechat, List[FormattedString]) -> str
|
||||||
# TODO BG COLOR
|
# TODO BG COLOR
|
||||||
def add_attribute(string, name, value):
|
def add_attribute(string, name, value):
|
||||||
if name == "bold" and value:
|
if name == "bold" and value:
|
||||||
|
|
Loading…
Add table
Reference in a new issue