Run black reformatter on code
This commit is contained in:
parent
4582eb4085
commit
bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions
|
|
@ -47,12 +47,12 @@ NULNUL = b"\x00\x00"
|
|||
AMP_MAXLEN = amp.MAX_VALUE_LENGTH # max allowed data length in AMP protocol (cannot be changed)
|
||||
|
||||
# amp internal
|
||||
ASK = b'_ask'
|
||||
ANSWER = b'_answer'
|
||||
ERROR = b'_error'
|
||||
ERROR_CODE = b'_error_code'
|
||||
ERROR_DESCRIPTION = b'_error_description'
|
||||
UNKNOWN_ERROR_CODE = b'UNKNOWN'
|
||||
ASK = b"_ask"
|
||||
ANSWER = b"_answer"
|
||||
ERROR = b"_error"
|
||||
ERROR_CODE = b"_error_code"
|
||||
ERROR_DESCRIPTION = b"_error_description"
|
||||
UNKNOWN_ERROR_CODE = b"UNKNOWN"
|
||||
|
||||
# buffers
|
||||
_SENDBATCH = defaultdict(list)
|
||||
|
|
@ -322,6 +322,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
|||
add a specific log of the problem on the erroring side.
|
||||
|
||||
"""
|
||||
|
||||
def formatAnswer(answerBox):
|
||||
answerBox[ANSWER] = box[ASK]
|
||||
return answerBox
|
||||
|
|
@ -350,6 +351,7 @@ class AMPMultiConnectionProtocol(amp.AMP):
|
|||
errorBox[ERROR_DESCRIPTION] = desc
|
||||
errorBox[ERROR_CODE] = code
|
||||
return errorBox
|
||||
|
||||
deferred = self.dispatchCommand(box)
|
||||
if ASK in box:
|
||||
deferred.addCallbacks(formatAnswer, formatError)
|
||||
|
|
|
|||
|
|
@ -244,7 +244,7 @@ class IRCBot(irc.IRCClient, Session):
|
|||
self.sendLine("NAMES %s" % self.channel)
|
||||
|
||||
def irc_RPL_NAMREPLY(self, prefix, params):
|
||||
""""Handles IRC NAME request returns (nicklist)"""
|
||||
""" "Handles IRC NAME request returns (nicklist)"""
|
||||
channel = params[2].lower()
|
||||
if channel != self.channel.lower():
|
||||
return
|
||||
|
|
|
|||
|
|
@ -358,8 +358,7 @@ if SSH_ENABLED:
|
|||
for port in SSH_PORTS:
|
||||
pstring = "%s:%s" % (ifacestr, port)
|
||||
factory = ssh.makeFactory(
|
||||
{"protocolFactory": _ssh_protocol,
|
||||
"protocolArgs": (), "sessions": PORTAL_SESSIONS}
|
||||
{"protocolFactory": _ssh_protocol, "protocolArgs": (), "sessions": PORTAL_SESSIONS}
|
||||
)
|
||||
factory.noisy = False
|
||||
ssh_service = internet.TCPServer(port, factory, interface=interface)
|
||||
|
|
|
|||
|
|
@ -37,8 +37,9 @@ DUMMYSESSION = namedtuple("DummySession", ["sessid"])(0)
|
|||
# Portal-SessionHandler class
|
||||
# -------------------------------------------------------------
|
||||
|
||||
DOS_PROTECTION_MSG = _("{servername} DoS protection is active."
|
||||
"You are queued to connect in {num} seconds ...")
|
||||
DOS_PROTECTION_MSG = _(
|
||||
"{servername} DoS protection is active." "You are queued to connect in {num} seconds ..."
|
||||
)
|
||||
|
||||
|
||||
class PortalSessionHandler(SessionHandler):
|
||||
|
|
@ -117,9 +118,12 @@ class PortalSessionHandler(SessionHandler):
|
|||
if len(_CONNECTION_QUEUE) > 1:
|
||||
session.data_out(
|
||||
text=(
|
||||
(DOS_PROTECTION_MSG.format(
|
||||
servername=settings.SERVERNAME,
|
||||
num=len(_CONNECTION_QUEUE) * _MIN_TIME_BETWEEN_CONNECTS),),
|
||||
(
|
||||
DOS_PROTECTION_MSG.format(
|
||||
servername=settings.SERVERNAME,
|
||||
num=len(_CONNECTION_QUEUE) * _MIN_TIME_BETWEEN_CONNECTS,
|
||||
),
|
||||
),
|
||||
{},
|
||||
)
|
||||
)
|
||||
|
|
@ -442,8 +446,8 @@ class PortalSessionHandler(SessionHandler):
|
|||
self.portal.amp_protocol.send_MsgPortal2Server(session, **kwargs)
|
||||
|
||||
# eventual local echo (text input only)
|
||||
if 'text' in kwargs and session.protocol_flags.get('LOCALECHO', False):
|
||||
self.data_out(session, text=kwargs['text'])
|
||||
if "text" in kwargs and session.protocol_flags.get("LOCALECHO", False):
|
||||
self.data_out(session, text=kwargs["text"])
|
||||
|
||||
def data_out(self, session, **kwargs):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ class SSHServerFactory(protocol.ServerFactory):
|
|||
This is only to name this better in logs
|
||||
|
||||
"""
|
||||
|
||||
noisy = False
|
||||
|
||||
def logPrefix(self):
|
||||
|
|
|
|||
|
|
@ -32,8 +32,8 @@ from evennia.utils import ansi
|
|||
from evennia.utils.utils import to_bytes, class_from_module
|
||||
|
||||
_RE_N = re.compile(r"\|n$")
|
||||
_RE_LEND = re.compile(br"\n$|\r$|\r\n$|\r\x00$|", re.MULTILINE)
|
||||
_RE_LINEBREAK = re.compile(br"\n\r|\r\n|\n|\r", re.DOTALL + re.MULTILINE)
|
||||
_RE_LEND = re.compile(rb"\n$|\r$|\r\n$|\r\x00$|", re.MULTILINE)
|
||||
_RE_LINEBREAK = re.compile(rb"\n\r|\r\n|\n|\r", re.DOTALL + re.MULTILINE)
|
||||
_RE_SCREENREADER_REGEX = re.compile(
|
||||
r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE
|
||||
)
|
||||
|
|
@ -63,6 +63,7 @@ class TelnetServerFactory(protocol.ServerFactory):
|
|||
This exists only to name this better in logs.
|
||||
|
||||
"""
|
||||
|
||||
noisy = False
|
||||
|
||||
def logPrefix(self):
|
||||
|
|
@ -92,6 +93,7 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
super().dataReceived(data)
|
||||
except ValueError as err:
|
||||
from evennia.utils import logger
|
||||
|
||||
logger.log_err(f"Malformed telnet input: {err}")
|
||||
|
||||
def connectionMade(self):
|
||||
|
|
@ -458,8 +460,9 @@ class TelnetProtocol(Telnet, StatefulTelnetProtocol, _BASE_SESSION_CLASS):
|
|||
prompt = mxp_parse(prompt)
|
||||
prompt = to_bytes(prompt, self)
|
||||
prompt = prompt.replace(IAC, IAC + IAC).replace(b"\n", b"\r\n")
|
||||
if not self.protocol_flags.get("NOPROMPTGOAHEAD",
|
||||
self.protocol_flags.get("NOGOAHEAD", True)):
|
||||
if not self.protocol_flags.get(
|
||||
"NOPROMPTGOAHEAD", self.protocol_flags.get("NOGOAHEAD", True)
|
||||
):
|
||||
prompt += IAC + GA
|
||||
self.transport.write(mccp_compress(self, prompt))
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -47,14 +47,14 @@ GMCP = bytes([201])
|
|||
# pre-compiled regexes
|
||||
# returns 2-tuple
|
||||
msdp_regex_table = re.compile(
|
||||
br"%s\s*(\w*?)\s*%s\s*%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_TABLE_OPEN, MSDP_TABLE_CLOSE)
|
||||
rb"%s\s*(\w*?)\s*%s\s*%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_TABLE_OPEN, MSDP_TABLE_CLOSE)
|
||||
)
|
||||
# returns 2-tuple
|
||||
msdp_regex_array = re.compile(
|
||||
br"%s\s*(\w*?)\s*%s\s*%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_ARRAY_OPEN, MSDP_ARRAY_CLOSE)
|
||||
rb"%s\s*(\w*?)\s*%s\s*%s(.*?)%s" % (MSDP_VAR, MSDP_VAL, MSDP_ARRAY_OPEN, MSDP_ARRAY_CLOSE)
|
||||
)
|
||||
msdp_regex_var = re.compile(br"%s" % MSDP_VAR)
|
||||
msdp_regex_val = re.compile(br"%s" % MSDP_VAL)
|
||||
msdp_regex_var = re.compile(rb"%s" % MSDP_VAR)
|
||||
msdp_regex_val = re.compile(rb"%s" % MSDP_VAL)
|
||||
|
||||
EVENNIA_TO_GMCP = {
|
||||
"client_options": "Core.Supports.Get",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue