Fix Typos, whitespace, docstring, long lines

This commit is contained in:
BlauFeuer 2017-03-07 07:36:53 -05:00 committed by GitHub
parent dee1cdb646
commit 9aa8bfdf7b

View file

@ -7,7 +7,7 @@ The separation works like this:
Portal - (AMP client) handles protocols. It contains a list of connected Portal - (AMP client) handles protocols. It contains a list of connected
sessions in a dictionary for identifying the respective player sessions in a dictionary for identifying the respective player
connected. If it looses the AMP connection it will automatically connected. If it loses the AMP connection it will automatically
try to reconnect. try to reconnect.
Server - (AMP server) Handles all mud operations. The server holds its own list Server - (AMP server) Handles all mud operations. The server holds its own list
@ -32,6 +32,7 @@ from twisted.internet import protocol
from twisted.internet.defer import Deferred from twisted.internet.defer import Deferred
from evennia.utils import logger from evennia.utils import logger
from evennia.utils.utils import to_str, variable_from_module from evennia.utils.utils import to_str, variable_from_module
import zlib # Used in Compressed class
DUMMYSESSION = namedtuple('DummySession', ['sessid'])(0) DUMMYSESSION = namedtuple('DummySession', ['sessid'])(0)
@ -58,7 +59,6 @@ BATCH_TIMEOUT = 0.5 # how often to poll to empty batch queue, in seconds
_SENDBATCH = defaultdict(list) _SENDBATCH = defaultdict(list)
_MSGBUFFER = defaultdict(list) _MSGBUFFER = defaultdict(list)
import zlib
def get_restart_mode(restart_file): def get_restart_mode(restart_file):
""" """
@ -323,9 +323,9 @@ dumps = lambda data: to_str(pickle.dumps(to_str(data), pickle.HIGHEST_PROTOCOL))
loads = lambda data: pickle.loads(to_str(data)) loads = lambda data: pickle.loads(to_str(data))
#------------------------------------------------------------ # -------------------------------------------------------------
# Core AMP protocol for communication Server <-> Portal # Core AMP protocol for communication Server <-> Portal
#------------------------------------------------------------ # -------------------------------------------------------------
class AMPProtocol(amp.AMP): class AMPProtocol(amp.AMP):
""" """
@ -385,7 +385,6 @@ class AMPProtocol(amp.AMP):
""" """
pass pass
# Error handling # Error handling
def errback(self, e, info): def errback(self, e, info):
@ -447,7 +446,7 @@ class AMPProtocol(amp.AMP):
Access method called by the Portal and executed on the Portal. Access method called by the Portal and executed on the Portal.
Args: Args:
sessid (int): Unique Session id. session (session): Session
kwargs (any, optional): Optional data. kwargs (any, optional): Optional data.
Returns: Returns:
@ -473,7 +472,6 @@ class AMPProtocol(amp.AMP):
self.factory.portal.sessions.data_out(session, **kwargs) self.factory.portal.sessions.data_out(session, **kwargs)
return {} return {}
def send_MsgServer2Portal(self, session, **kwargs): def send_MsgServer2Portal(self, session, **kwargs):
""" """
Access method - executed on the Server for sending data Access method - executed on the Server for sending data
@ -506,7 +504,7 @@ class AMPProtocol(amp.AMP):
# create a new session and sync it # create a new session and sync it
server_sessionhandler.portal_connect(kwargs.get("sessiondata")) server_sessionhandler.portal_connect(kwargs.get("sessiondata"))
elif operation == PCONNSYNC: #portal_session_sync elif operation == PCONNSYNC: # portal_session_sync
server_sessionhandler.portal_session_sync(kwargs.get("sessiondata")) server_sessionhandler.portal_session_sync(kwargs.get("sessiondata"))
elif operation == PDISCONN: # portal_session_disconnect elif operation == PDISCONN: # portal_session_disconnect
@ -545,7 +543,7 @@ class AMPProtocol(amp.AMP):
""" """
return self.send_data(AdminPortal2Server, session.sessid, operation=operation, **kwargs) return self.send_data(AdminPortal2Server, session.sessid, operation=operation, **kwargs)
# Portal administraton from the Server side # Portal administration from the Server side
@AdminServer2Portal.responder @AdminServer2Portal.responder
def portal_receive_adminserver2portal(self, packed_data): def portal_receive_adminserver2portal(self, packed_data):
@ -562,7 +560,6 @@ class AMPProtocol(amp.AMP):
operation = kwargs.pop("operation") operation = kwargs.pop("operation")
portal_sessionhandler = self.factory.portal.sessions portal_sessionhandler = self.factory.portal.sessions
if operation == SLOGIN: # server_session_login if operation == SLOGIN: # server_session_login
# a session has authenticated; sync it. # a session has authenticated; sync it.
session = portal_sessionhandler.get(sessid) session = portal_sessionhandler.get(sessid)
@ -665,4 +662,5 @@ class AMPProtocol(amp.AMP):
module=modulepath, module=modulepath,
function=functionname, function=functionname,
args=dumps(args), args=dumps(args),
kwargs=dumps(kwargs)).addCallback(lambda r: loads(r["result"])).addErrback(self.errback, "FunctionCall") kwargs=dumps(kwargs)).addCallback(
lambda r: loads(r["result"])).addErrback(self.errback, "FunctionCall")