Fix some style issues.
This commit is contained in:
parent
efa39f88b2
commit
72221246b0
1 changed files with 44 additions and 44 deletions
|
@ -10,7 +10,6 @@ import datetime
|
||||||
import pprint
|
import pprint
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import webcolors
|
|
||||||
|
|
||||||
# pylint: disable=redefined-builtin
|
# pylint: disable=redefined-builtin
|
||||||
from builtins import bytes, str
|
from builtins import bytes, str
|
||||||
|
@ -23,6 +22,7 @@ from functools import wraps
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from typing import (List, Set, Dict, Tuple, Text, Optional, AnyStr, Deque, Any)
|
from typing import (List, Set, Dict, Tuple, Text, Optional, AnyStr, Deque, Any)
|
||||||
|
|
||||||
|
import webcolors
|
||||||
from http_parser.pyparser import HttpParser
|
from http_parser.pyparser import HttpParser
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -274,6 +274,7 @@ class MatrixMessage:
|
||||||
extra_data=None # type: Dict[str, Any]
|
extra_data=None # type: Dict[str, Any]
|
||||||
):
|
):
|
||||||
# type: (...) -> None
|
# type: (...) -> None
|
||||||
|
# pylint: disable=dangerous-default-value
|
||||||
self.type = message_type # MessageType
|
self.type = message_type # MessageType
|
||||||
self.request = None # HttpRequest
|
self.request = None # HttpRequest
|
||||||
self.response = None # HttpResponse
|
self.response = None # HttpResponse
|
||||||
|
@ -600,7 +601,7 @@ FormattedString = namedtuple(
|
||||||
['text', 'attributes']
|
['text', 'attributes']
|
||||||
)
|
)
|
||||||
|
|
||||||
Default_format_attributes = {
|
DEFAULT_ATRIBUTES = {
|
||||||
"bold": False,
|
"bold": False,
|
||||||
"italic": False,
|
"italic": False,
|
||||||
"underline": False,
|
"underline": False,
|
||||||
|
@ -1121,7 +1122,7 @@ def parse_input_line(line):
|
||||||
# type: (str) -> List[FormattedString]
|
# type: (str) -> List[FormattedString]
|
||||||
text = "" # type: str
|
text = "" # type: str
|
||||||
substrings = [] # type: List[FormattedString]
|
substrings = [] # type: List[FormattedString]
|
||||||
attributes = Default_format_attributes.copy()
|
attributes = DEFAULT_ATRIBUTES.copy()
|
||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
while i < len(line):
|
while i < len(line):
|
||||||
|
@ -1177,7 +1178,7 @@ def parse_input_line(line):
|
||||||
substrings.append(FormattedString(text, attributes.copy()))
|
substrings.append(FormattedString(text, attributes.copy()))
|
||||||
text = ""
|
text = ""
|
||||||
# Reset all the attributes
|
# Reset all the attributes
|
||||||
attributes = Default_format_attributes.copy()
|
attributes = DEFAULT_ATRIBUTES.copy()
|
||||||
i = i + 1
|
i = i + 1
|
||||||
# Italic
|
# Italic
|
||||||
elif line[i] == "\x1D":
|
elif line[i] == "\x1D":
|
||||||
|
@ -1206,7 +1207,7 @@ def parse_input_line(line):
|
||||||
|
|
||||||
def formatted(strings):
|
def formatted(strings):
|
||||||
for string in strings:
|
for string in strings:
|
||||||
if string.attributes != Default_format_attributes:
|
if string.attributes != DEFAULT_ATRIBUTES:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1320,7 +1321,7 @@ def formatted_to_html(strings):
|
||||||
# (strikethrough, quotes)?
|
# (strikethrough, quotes)?
|
||||||
def formatted_to_plain(strings):
|
def formatted_to_plain(strings):
|
||||||
# type: (List[FormattedString]) -> str
|
# type: (List[FormattedString]) -> str
|
||||||
def strip_atribute(string, name, value):
|
def strip_atribute(string, _, __):
|
||||||
return string
|
return string
|
||||||
|
|
||||||
def format_string(formatted_string):
|
def format_string(formatted_string):
|
||||||
|
@ -1342,7 +1343,7 @@ class MatrixHtmlParser(HTMLParser):
|
||||||
HTMLParser.__init__(self)
|
HTMLParser.__init__(self)
|
||||||
self.text = "" # type: str
|
self.text = "" # type: str
|
||||||
self.substrings = [] # type: List[FormattedString]
|
self.substrings = [] # type: List[FormattedString]
|
||||||
self.attributes = Default_format_attributes.copy()
|
self.attributes = DEFAULT_ATRIBUTES.copy()
|
||||||
|
|
||||||
def _toggle_attribute(self, attribute):
|
def _toggle_attribute(self, attribute):
|
||||||
if self.text:
|
if self.text:
|
||||||
|
@ -1544,8 +1545,7 @@ def handle_http_response(server, message):
|
||||||
"\n Send delay: {s} ms"
|
"\n Send delay: {s} ms"
|
||||||
"\n Receive delay: {r} ms"
|
"\n Receive delay: {r} ms"
|
||||||
"\n Handling time: {h} ms"
|
"\n Handling time: {h} ms"
|
||||||
"\n Total time: {total} ms"
|
"\n Total time: {total} ms").format(
|
||||||
).format(
|
|
||||||
t=message.type,
|
t=message.type,
|
||||||
c=creation_date,
|
c=creation_date,
|
||||||
s=(message.send_time - message.creation_time) * 1000,
|
s=(message.send_time - message.creation_time) * 1000,
|
||||||
|
@ -3568,7 +3568,7 @@ def matrix_command_pgup_cb(data, buffer, command):
|
||||||
|
|
||||||
@utf8_decode
|
@utf8_decode
|
||||||
def matrix_command_join_cb(data, buffer, command):
|
def matrix_command_join_cb(data, buffer, command):
|
||||||
def join(args):
|
def join(server, args):
|
||||||
split_args = args.split(" ", 1)
|
split_args = args.split(" ", 1)
|
||||||
|
|
||||||
# TODO handle join for non public rooms
|
# TODO handle join for non public rooms
|
||||||
|
@ -3585,10 +3585,10 @@ def matrix_command_join_cb(data, buffer, command):
|
||||||
|
|
||||||
for server in SERVERS.values():
|
for server in SERVERS.values():
|
||||||
if buffer in server.buffers.values():
|
if buffer in server.buffers.values():
|
||||||
join(command)
|
join(server, command)
|
||||||
return W.WEECHAT_RC_OK_EAT
|
return W.WEECHAT_RC_OK_EAT
|
||||||
elif buffer == server.server_buffer:
|
elif buffer == server.server_buffer:
|
||||||
join(command)
|
join(server, command)
|
||||||
return W.WEECHAT_RC_OK_EAT
|
return W.WEECHAT_RC_OK_EAT
|
||||||
|
|
||||||
return W.WEECHAT_RC_OK
|
return W.WEECHAT_RC_OK
|
||||||
|
|
Loading…
Reference in a new issue