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