Format code imports

This commit is contained in:
Griatch 2022-11-10 22:21:12 +01:00
parent 92834aacd0
commit a461a97576
361 changed files with 1019 additions and 754 deletions

View file

@ -5,16 +5,17 @@ This module acts as a central place for AMP-servers and -clients to get commands
"""
import pickle
import time
from functools import wraps
from twisted.protocols import amp
import zlib # Used in Compressed class
from collections import defaultdict, namedtuple
from functools import wraps
from io import BytesIO
from itertools import count
import zlib # Used in Compressed class
import pickle
from twisted.internet.defer import DeferredList, Deferred
from twisted.internet.defer import Deferred, DeferredList
from twisted.protocols import amp
from evennia.utils.utils import variable_from_module
# delayed import

View file

@ -6,10 +6,12 @@ these are the Evennia Server and the evennia launcher).
"""
import os
import sys
from twisted.internet import protocol
from evennia.server.portal import amp
from subprocess import STDOUT, Popen
from django.conf import settings
from subprocess import Popen, STDOUT
from twisted.internet import protocol
from evennia.server.portal import amp
from evennia.utils import logger
from evennia.utils.utils import class_from_module

View file

@ -10,12 +10,14 @@ the grapevine client to in-game channels.
"""
import json
from twisted.internet import protocol
from autobahn.twisted.websocket import WebSocketClientFactory, WebSocketClientProtocol, connectWS
from django.conf import settings
from twisted.internet import protocol
from evennia.server.session import Session
from evennia.utils import get_evennia_version
from evennia.utils.logger import log_info, log_err
from autobahn.twisted.websocket import WebSocketClientProtocol, WebSocketClientFactory, connectWS
from evennia.utils.logger import log_err, log_info
# There is only one at this time
GRAPEVINE_URI = "wss://grapevine.haus/socket"

View file

@ -5,12 +5,13 @@ more Evennia channels.
"""
import re
from twisted.application import internet
from twisted.words.protocols import irc
from twisted.internet import protocol, reactor
from evennia.server.session import Session
from evennia.utils import logger, utils, ansi
from twisted.application import internet
from twisted.internet import protocol, reactor
from twisted.words.protocols import irc
from evennia.server.session import Session
from evennia.utils import ansi, logger, utils
# IRC colors

View file

@ -11,6 +11,7 @@ active players and so on.
"""
from django.conf import settings
from evennia.utils import utils
MSSP = bytes([70]) # b"\x46"

View file

@ -14,6 +14,7 @@ http://www.gammon.com.au/mushclient/addingservermxp.htm
"""
import re
from django.conf import settings
LINKS_SUB = re.compile(r"\|lc(.*?)\|lt(.*?)\|le", re.DOTALL)

View file

@ -10,6 +10,7 @@ client and update it when the size changes
"""
from codecs import encode as codecs_encode
from django.conf import settings
NAWS = bytes([31]) # b"\x1f"

View file

@ -7,17 +7,16 @@ sets up all the networking features. (this is done automatically
by game/evennia.py).
"""
import sys
import os
import sys
import time
from os.path import dirname, abspath
from twisted.application import internet, service
from twisted.internet.task import LoopingCall
from twisted.internet import protocol, reactor
from twisted.logger import globalLogPublisher
from os.path import abspath, dirname
import django
from twisted.application import internet, service
from twisted.internet import protocol, reactor
from twisted.internet.task import LoopingCall
from twisted.logger import globalLogPublisher
django.setup()
from django.conf import settings
@ -27,11 +26,10 @@ import evennia
evennia._init()
from evennia.utils.utils import get_evennia_version, mod_import, make_iter, class_from_module
from evennia.server.portal.portalsessionhandler import PORTAL_SESSIONS
from evennia.utils import logger
from evennia.server.webserver import EvenniaReverseProxyResource
from evennia.utils import logger
from evennia.utils.utils import class_from_module, get_evennia_version, make_iter, mod_import
# we don't need a connection to the database so close it right away
try:
@ -394,9 +392,10 @@ if WEBSERVER_ENABLED:
if WEBSOCKET_CLIENT_ENABLED and not websocket_started:
# start websocket client port for the webclient
# we only support one websocket client
from evennia.server.portal import webclient # noqa
from autobahn.twisted.websocket import WebSocketServerFactory
from evennia.server.portal import webclient # noqa
w_interface = WEBSOCKET_CLIENT_INTERFACE
w_ifacestr = ""
if w_interface not in ("0.0.0.0", "::") or len(WEBSERVER_INTERFACES) > 1:

View file

@ -6,13 +6,15 @@ Sessionhandler for portal sessions.
import time
from collections import deque, namedtuple
from twisted.internet import reactor
from django.conf import settings
from django.utils.translation import gettext as _
from twisted.internet import reactor
from evennia.server.portal.amp import PCONN, PCONNSYNC, PDISCONN, PDISCONNALL
from evennia.server.sessionhandler import SessionHandler
from evennia.server.portal.amp import PCONN, PDISCONN, PCONNSYNC, PDISCONNALL
from evennia.utils.logger import log_trace
from evennia.utils.utils import class_from_module
from django.utils.translation import gettext as _
# module import
_MOD_IMPORT = None

View file

@ -5,8 +5,9 @@ This connects an RSS feed to an in-game Evennia channel, sending messages
to the channel whenever the feed updates.
"""
from twisted.internet import task, threads
from django.conf import settings
from twisted.internet import task, threads
from evennia.server.session import Session
from evennia.utils import logger

View file

@ -12,9 +12,9 @@ Using standard ssh client,
import os
import re
from twisted.conch.interfaces import IConchUser
from twisted.cred.checkers import credentials
from twisted.cred.portal import Portal
from twisted.conch.interfaces import IConchUser
_SSH_IMPORT_ERROR = """
ERROR: Missing crypto library for SSH. Install it with
@ -33,19 +33,19 @@ try:
except ImportError:
raise ImportError(_SSH_IMPORT_ERROR)
from twisted.conch.ssh.userauth import SSHUserAuthServer
from twisted.conch.ssh import common
from twisted.conch.insults import insults
from twisted.conch.manhole_ssh import TerminalRealm, _Glue, ConchFactory
from twisted.conch.manhole import Manhole, recvline
from twisted.internet import defer, protocol
from twisted.conch import interfaces as iconch
from twisted.python import components
from django.conf import settings
from twisted.conch import interfaces as iconch
from twisted.conch.insults import insults
from twisted.conch.manhole import Manhole, recvline
from twisted.conch.manhole_ssh import ConchFactory, TerminalRealm, _Glue
from twisted.conch.ssh import common
from twisted.conch.ssh.userauth import SSHUserAuthServer
from twisted.internet import defer, protocol
from twisted.python import components
from evennia.accounts.models import AccountDB
from evennia.utils import ansi
from evennia.utils.utils import to_str, class_from_module
from evennia.utils.utils import class_from_module, to_str
_RE_N = re.compile(r"\|n$")
_RE_SCREENREADER_REGEX = re.compile(

View file

@ -18,6 +18,7 @@ except ImportError as error:
raise ImportError(errstr.format(err=error))
from django.conf import settings
from evennia.utils.utils import class_from_module
_GAME_DIR = settings.GAME_DIR
@ -69,6 +70,7 @@ def verify_SSL_key_and_cert(keyfile, certfile):
if not (os.path.exists(keyfile) and os.path.exists(certfile)):
# key/cert does not exist. Create.
import subprocess
from Crypto.PublicKey import RSA
from twisted.conch.ssh.keys import Key

View file

@ -8,28 +8,31 @@ sessions etc.
"""
import re
from twisted.internet import protocol
from twisted.internet.task import LoopingCall
from twisted.conch.telnet import Telnet, StatefulTelnetProtocol
from django.conf import settings
from twisted.conch.telnet import (
IAC,
NOP,
LINEMODE,
GA,
WILL,
WONT,
ECHO,
NULL,
MODE,
GA,
IAC,
LINEMODE,
LINEMODE_EDIT,
LINEMODE_TRAPSIG,
MODE,
NOP,
NULL,
WILL,
WONT,
StatefulTelnetProtocol,
Telnet,
)
from django.conf import settings
from evennia.server.portal import ttype, mssp, telnet_oob, naws, suppress_ga
from evennia.server.portal.mccp import Mccp, mccp_compress, MCCP
from twisted.internet import protocol
from twisted.internet.task import LoopingCall
from evennia.server.portal import mssp, naws, suppress_ga, telnet_oob, ttype
from evennia.server.portal.mccp import MCCP, Mccp, mccp_compress
from evennia.server.portal.mxp import Mxp, mxp_parse
from evennia.utils import ansi
from evennia.utils.utils import to_bytes, class_from_module
from evennia.utils.utils import class_from_module, to_bytes
_RE_N = re.compile(r"\|n$")
_RE_LEND = re.compile(rb"\n$|\r$|\r\n$|\r\x00$|", re.MULTILINE)

View file

@ -23,13 +23,14 @@ This implements the following telnet OOB communication protocols:
----
"""
import re
import json
from evennia.utils.utils import is_iter
import re
# General Telnet
from twisted.conch.telnet import IAC, SB, SE
from evennia.utils.utils import is_iter
# MSDP-relevant telnet cmd/opt-codes
MSDP = bytes([69])
MSDP_VAR = bytes([1])

View file

@ -26,6 +26,7 @@ except ImportError as error:
raise ImportError(errstr.format(err=error))
from django.conf import settings
from evennia.server.portal.telnet import TelnetProtocol
_GAME_DIR = settings.GAME_DIR

View file

@ -8,35 +8,33 @@ try:
except ImportError:
import unittest
import sys
import string
import mock
import pickle
import json
import pickle
import string
import sys
import mock
from autobahn.twisted.websocket import WebSocketServerFactory
from mock import MagicMock, Mock
from twisted.conch.telnet import DO, DONT, IAC, NAWS, SB, SE, WILL
from twisted.internet.base import DelayedCall
from twisted.test import proto_helpers
from twisted.trial.unittest import TestCase as TwistedTestCase
from mock import Mock, MagicMock
from evennia.server.portal import irc
from evennia.utils.test_resources import BaseEvenniaTest
from twisted.conch.telnet import IAC, WILL, DONT, SB, SE, NAWS, DO
from twisted.test import proto_helpers
from twisted.trial.unittest import TestCase as TwistedTestCase
from twisted.internet.base import DelayedCall
from .telnet import TelnetServerFactory, TelnetProtocol
from .portal import PORTAL_SESSIONS
from .suppress_ga import SUPPRESS_GA
from .naws import DEFAULT_HEIGHT, DEFAULT_WIDTH
from .ttype import TTYPE, IS
from .amp import AMP_MAXLEN, AMPMultiConnectionProtocol, MsgPortal2Server, MsgServer2Portal
from .amp_server import AMPServerFactory
from .mccp import MCCP
from .mssp import MSSP
from .mxp import MXP
from .naws import DEFAULT_HEIGHT, DEFAULT_WIDTH
from .portal import PORTAL_SESSIONS
from .suppress_ga import SUPPRESS_GA
from .telnet import TelnetProtocol, TelnetServerFactory
from .telnet_oob import MSDP, MSDP_VAL, MSDP_VAR
from .amp import AMPMultiConnectionProtocol, MsgServer2Portal, MsgPortal2Server, AMP_MAXLEN
from .amp_server import AMPServerFactory
from autobahn.twisted.websocket import WebSocketServerFactory
from .ttype import IS, TTYPE
from .webclient import WebSocketClient

View file

@ -14,15 +14,17 @@ The most common inputfunc is "text", which takes just the text input
from the command line and interprets it as an Evennia Command: `["text", ["look"], {}]`
"""
import re
import json
import html
import json
import re
from autobahn.exception import Disconnected
from autobahn.twisted.websocket import WebSocketServerProtocol
from django.conf import settings
from evennia.utils.utils import mod_import, class_from_module
from evennia.utils.ansi import parse_ansi
from evennia.utils.text2html import parse_html
from autobahn.twisted.websocket import WebSocketServerProtocol
from autobahn.exception import Disconnected
from evennia.utils.utils import class_from_module, mod_import
_RE_SCREENREADER_REGEX = re.compile(
r"%s" % settings.SCREENREADER_REGEX_STRIP, re.DOTALL + re.MULTILINE

View file

@ -17,20 +17,21 @@ http://localhost:4001/webclient.)
to sessions connected over the webclient.
"""
import html
import json
import re
import time
import html
from twisted.web import server, resource
from twisted.internet.task import LoopingCall
from django.utils.functional import Promise
from django.conf import settings
from evennia.utils.ansi import parse_ansi
from evennia.utils import utils
from evennia.utils.utils import to_bytes
from evennia.utils.text2html import parse_html
from django.utils.functional import Promise
from twisted.internet.task import LoopingCall
from twisted.web import resource, server
from evennia.server import session
from evennia.utils import utils
from evennia.utils.ansi import parse_ansi
from evennia.utils.text2html import parse_html
from evennia.utils.utils import to_bytes
_CLIENT_SESSIONS = utils.mod_import(settings.SESSION_ENGINE).SessionStore
_RE_SCREENREADER_REGEX = re.compile(