mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Run black on sources
This commit is contained in:
parent
dc81d275e6
commit
8b2b23873f
17 changed files with 102 additions and 59 deletions
|
|
@ -508,8 +508,10 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
if banned:
|
||||
# this is a banned IP or name!
|
||||
errors.append(
|
||||
_("|rYou have been banned and cannot continue from here."
|
||||
"\nIf you feel this ban is in error, please email an admin.|x")
|
||||
_(
|
||||
"|rYou have been banned and cannot continue from here."
|
||||
"\nIf you feel this ban is in error, please email an admin.|x"
|
||||
)
|
||||
)
|
||||
logger.log_sec(f"Authentication Denied (Banned): {username} (IP: {ip}).")
|
||||
LOGIN_THROTTLE.update(ip, "Too many sightings of banned artifact.")
|
||||
|
|
@ -716,9 +718,9 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
banned = cls.is_banned(username=username, ip=ip)
|
||||
if banned:
|
||||
# this is a banned IP or name!
|
||||
string = (
|
||||
_("|rYou have been banned and cannot continue from here."
|
||||
"\nIf you feel this ban is in error, please email an admin.|x")
|
||||
string = _(
|
||||
"|rYou have been banned and cannot continue from here."
|
||||
"\nIf you feel this ban is in error, please email an admin.|x"
|
||||
)
|
||||
errors.append(string)
|
||||
return None, errors
|
||||
|
|
@ -733,7 +735,9 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
|
||||
except Exception as e:
|
||||
errors.append(
|
||||
_("There was an error creating the Account. If this problem persists, contact an admin.")
|
||||
_(
|
||||
"There was an error creating the Account. If this problem persists, contact an admin."
|
||||
)
|
||||
)
|
||||
logger.log_trace()
|
||||
return None, errors
|
||||
|
|
@ -1305,7 +1309,9 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
|
||||
"""
|
||||
reason = f" ({reason if reason else ''})"
|
||||
self._send_to_connect_channel(_("|R{key} disconnected{reason}|n").format(key=self.key, reason=reason))
|
||||
self._send_to_connect_channel(
|
||||
_("|R{key} disconnected{reason}|n").format(key=self.key, reason=reason)
|
||||
)
|
||||
|
||||
def at_post_disconnect(self, **kwargs):
|
||||
"""
|
||||
|
|
@ -1454,7 +1460,9 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
|||
if is_su or len(characters) < charmax:
|
||||
if not characters:
|
||||
result.append(
|
||||
_("\n\n You don't have any characters yet. See |whelp @charcreate|n for creating one.")
|
||||
_(
|
||||
"\n\n You don't have any characters yet. See |whelp @charcreate|n for creating one."
|
||||
)
|
||||
)
|
||||
else:
|
||||
result.append("\n |w@charcreate <name> [=description]|n - create new character")
|
||||
|
|
|
|||
|
|
@ -329,7 +329,9 @@ class IRCBot(Bot):
|
|||
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
||||
nicklist = ", ".join(sorted(kwargs["nicklist"], key=lambda n: n.lower()))
|
||||
for obj in self._nicklist_callers:
|
||||
obj.msg(_("Nicks at {chstr}:\n {nicklist}").format(chstr=chstr, nicklist=nicklist))
|
||||
obj.msg(
|
||||
_("Nicks at {chstr}:\n {nicklist}").format(chstr=chstr, nicklist=nicklist)
|
||||
)
|
||||
self._nicklist_callers = []
|
||||
return
|
||||
|
||||
|
|
@ -338,7 +340,11 @@ class IRCBot(Bot):
|
|||
if hasattr(self, "_ping_callers") and self._ping_callers:
|
||||
chstr = f"{self.db.irc_channel} ({self.db.irc_network}:{self.db.irc_port})"
|
||||
for obj in self._ping_callers:
|
||||
obj.msg(_("IRC ping return from {chstr} took {time}s.").format(chstr=chstr, time=kwargs['timing']))
|
||||
obj.msg(
|
||||
_("IRC ping return from {chstr} took {time}s.").format(
|
||||
chstr=chstr, time=kwargs["timing"]
|
||||
)
|
||||
)
|
||||
self._ping_callers = []
|
||||
return
|
||||
|
||||
|
|
|
|||
|
|
@ -743,7 +743,9 @@ def cmdhandler(
|
|||
sysarg = raw_string
|
||||
else:
|
||||
# fallback to default error text
|
||||
sysarg = _("Command '{command}' is not available.").format(command=raw_string)
|
||||
sysarg = _("Command '{command}' is not available.").format(
|
||||
command=raw_string
|
||||
)
|
||||
suggestions = string_suggestions(
|
||||
raw_string,
|
||||
cmdset.get_all_cmd_keys_and_aliases(caller),
|
||||
|
|
@ -751,7 +753,9 @@ def cmdhandler(
|
|||
maxnum=3,
|
||||
)
|
||||
if suggestions:
|
||||
sysarg += _(" Maybe you meant {command}?").format(command=utils.list_to_string(suggestions, _("or"), addquote=True))
|
||||
sysarg += _(" Maybe you meant {command}?").format(
|
||||
command=utils.list_to_string(suggestions, _("or"), addquote=True)
|
||||
)
|
||||
else:
|
||||
sysarg += _(' Type "help" for help.')
|
||||
raise ExecSystemCommand(syscmd, sysarg)
|
||||
|
|
|
|||
|
|
@ -184,7 +184,9 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
|||
raise exc.with_traceback(tb)
|
||||
else:
|
||||
# try next suggested path
|
||||
errstring += _("\n(Unsuccessfully tried '{path}').").format(path=python_path)
|
||||
errstring += _("\n(Unsuccessfully tried '{path}').").format(
|
||||
path=python_path
|
||||
)
|
||||
continue
|
||||
try:
|
||||
cmdsetclass = getattr(module, classname)
|
||||
|
|
@ -194,7 +196,9 @@ def import_cmdset(path, cmdsetobj, emit_to_obj=None, no_logging=False):
|
|||
dum, dum, tb = sys.exc_info()
|
||||
raise exc.with_traceback(tb)
|
||||
else:
|
||||
errstring += _("\n(Unsuccessfully tried '{path}').").format(path=python_path)
|
||||
errstring += _("\n(Unsuccessfully tried '{path}').").format(
|
||||
path=python_path
|
||||
)
|
||||
continue
|
||||
_CACHED_CMDSETS[python_path] = cmdsetclass
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,9 @@ class HelpEntryManager(TypedObjectManager):
|
|||
for topic in topics:
|
||||
topic.help_category = default_category
|
||||
topic.save()
|
||||
string = _("Help database moved to category {default_category}").format(default_category=default_category)
|
||||
string = _("Help database moved to category {default_category}").format(
|
||||
default_category=default_category
|
||||
)
|
||||
logger.log_info(string)
|
||||
|
||||
def search_help(self, ostring, help_category=None):
|
||||
|
|
|
|||
|
|
@ -246,7 +246,11 @@ class LockHandler(object):
|
|||
evalstring = " ".join(_RE_OK.findall(evalstring))
|
||||
eval(evalstring % tuple(True for func in funclist), {}, {})
|
||||
except Exception:
|
||||
elist.append(_("Lock: definition '{lock_string}' has syntax errors.").format(lock_string=raw_lockstring))
|
||||
elist.append(
|
||||
_("Lock: definition '{lock_string}' has syntax errors.").format(
|
||||
lock_string=raw_lockstring
|
||||
)
|
||||
)
|
||||
continue
|
||||
if access_type in locks:
|
||||
duplicates += 1
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ from evennia.objects.models import ObjectDB
|
|||
from django.contrib.admin.utils import flatten_fieldsets
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
|
||||
class ObjectAttributeInline(AttributeInline):
|
||||
"""
|
||||
Defines inline descriptions of Attributes (experimental)
|
||||
|
|
@ -61,7 +62,7 @@ class ObjectCreateForm(forms.ModelForm):
|
|||
required=False,
|
||||
widget=forms.TextInput(attrs={"size": "78"}),
|
||||
help_text="Most non-character objects don't need a cmdset"
|
||||
" and can leave this field blank."
|
||||
" and can leave this field blank.",
|
||||
)
|
||||
raw_id_fields = ("db_destination", "db_location", "db_home")
|
||||
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ if TELNET_ENABLED:
|
|||
# Start telnet game connections
|
||||
|
||||
from evennia.server.portal import telnet
|
||||
|
||||
_telnet_protocol = class_from_module(settings.TELNET_PROTOCOL_CLASS)
|
||||
|
||||
for interface in TELNET_INTERFACES:
|
||||
|
|
@ -285,6 +286,7 @@ if SSL_ENABLED:
|
|||
# Start Telnet+SSL game connection (requires PyOpenSSL).
|
||||
|
||||
from evennia.server.portal import telnet_ssl
|
||||
|
||||
_ssl_protocol = class_from_module(settings.SSL_PROTOCOL_CLASS)
|
||||
|
||||
for interface in SSL_INTERFACES:
|
||||
|
|
@ -319,6 +321,7 @@ if SSH_ENABLED:
|
|||
# evennia/game if necessary.
|
||||
|
||||
from evennia.server.portal import ssh
|
||||
|
||||
_ssh_protocol = class_from_module(settings.SSH_PROTOCOL_CLASS)
|
||||
|
||||
for interface in SSH_INTERFACES:
|
||||
|
|
@ -328,11 +331,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)
|
||||
|
|
|
|||
|
|
@ -468,7 +468,11 @@ def getKeyPair(pubkeyfile, privkeyfile):
|
|||
from cryptography.hazmat.backends import default_backend
|
||||
from cryptography.hazmat.primitives.asymmetric import rsa
|
||||
|
||||
rsa_key = Key(rsa.generate_private_key(public_exponent=65537, key_size=_KEY_LENGTH, backend=default_backend()))
|
||||
rsa_key = Key(
|
||||
rsa.generate_private_key(
|
||||
public_exponent=65537, key_size=_KEY_LENGTH, backend=default_backend()
|
||||
)
|
||||
)
|
||||
public_key_string = rsa_key.public().toString(type="OPENSSH").decode()
|
||||
private_key_string = rsa_key.toString(type="OPENSSH").decode()
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,6 @@ _HTTP_WARNING = bytes(
|
|||
_BASE_SESSION_CLASS = class_from_module(settings.BASE_SESSION_CLASS)
|
||||
|
||||
|
||||
|
||||
class TelnetServerFactory(protocol.ServerFactory):
|
||||
"This is only to name this better in logs"
|
||||
noisy = False
|
||||
|
|
|
|||
|
|
@ -101,7 +101,9 @@ class Session(object):
|
|||
the keys given by self._attrs_to_sync.
|
||||
|
||||
"""
|
||||
return {attr: getattr(self, attr) for attr in settings.SESSION_SYNC_ATTRS if hasattr(self, attr)}
|
||||
return {
|
||||
attr: getattr(self, attr) for attr in settings.SESSION_SYNC_ATTRS if hasattr(self, attr)
|
||||
}
|
||||
|
||||
def load_sync_data(self, sessdata):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ from evennia.utils.utils import (
|
|||
make_iter,
|
||||
delay,
|
||||
callables_from_module,
|
||||
class_from_module
|
||||
class_from_module,
|
||||
)
|
||||
from evennia.server.portal import amp
|
||||
from evennia.server.signals import SIGNAL_ACCOUNT_POST_LOGIN, SIGNAL_ACCOUNT_POST_LOGOUT
|
||||
|
|
|
|||
|
|
@ -972,7 +972,7 @@ REST_FRAMEWORK = {
|
|||
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.LimitOffsetPagination",
|
||||
"PAGE_SIZE": 25,
|
||||
# require logged in users to call API so that access checks can work on them
|
||||
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated", ],
|
||||
"DEFAULT_PERMISSION_CLASSES": ["rest_framework.permissions.IsAuthenticated",],
|
||||
# These are the different ways people can authenticate for API requests - via
|
||||
# session or with user/password. Other ways are possible, such as via tokens
|
||||
# or oauth, but require additional dependencies.
|
||||
|
|
@ -1040,28 +1040,28 @@ PORTAL_SESSION_HANDLER_CLASS = "evennia.server.portal.portalsessionhandler.Porta
|
|||
# so the additions have somewhere to go. These must be simple things that
|
||||
# can be pickled - stuff you could serialize to JSON is best.
|
||||
SESSION_SYNC_ATTRS = (
|
||||
"protocol_key",
|
||||
"address",
|
||||
"suid",
|
||||
"sessid",
|
||||
"uid",
|
||||
"csessid",
|
||||
"uname",
|
||||
"logged_in",
|
||||
"puid",
|
||||
"conn_time",
|
||||
"cmd_last",
|
||||
"cmd_last_visible",
|
||||
"cmd_total",
|
||||
"protocol_flags",
|
||||
"server_data",
|
||||
"cmdset_storage_string"
|
||||
)
|
||||
"protocol_key",
|
||||
"address",
|
||||
"suid",
|
||||
"sessid",
|
||||
"uid",
|
||||
"csessid",
|
||||
"uname",
|
||||
"logged_in",
|
||||
"puid",
|
||||
"conn_time",
|
||||
"cmd_last",
|
||||
"cmd_last_visible",
|
||||
"cmd_total",
|
||||
"protocol_flags",
|
||||
"server_data",
|
||||
"cmdset_storage_string",
|
||||
)
|
||||
|
||||
# The following are used for the communications between the Portal and Server.
|
||||
# Very dragons territory.
|
||||
AMP_SERVER_PROTOCOL_CLASS = 'evennia.server.portal.amp_server.AMPServerProtocol'
|
||||
AMP_CLIENT_PROTOCOL_CLASS = 'evennia.server.amp_client.AMPServerClientProtocol'
|
||||
AMP_SERVER_PROTOCOL_CLASS = "evennia.server.portal.amp_server.AMPServerProtocol"
|
||||
AMP_CLIENT_PROTOCOL_CLASS = "evennia.server.amp_client.AMPServerClientProtocol"
|
||||
|
||||
|
||||
######################################################################
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
|||
# Attribute manager methods
|
||||
def get_attribute(
|
||||
self, key=None, category=None, value=None, strvalue=None, obj=None, attrtype=None, **kwargs
|
||||
|
||||
):
|
||||
"""
|
||||
Return Attribute objects by key, by category, by value, by
|
||||
|
|
@ -104,8 +103,9 @@ class TypedObjectManager(idmapper.manager.SharedMemoryManager):
|
|||
key=key, category=category, value=value, strvalue=strvalue, obj=obj
|
||||
)
|
||||
|
||||
def get_by_attribute(self, key=None, category=None, value=None,
|
||||
strvalue=None, attrtype=None, **kwargs):
|
||||
def get_by_attribute(
|
||||
self, key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
|
||||
):
|
||||
"""
|
||||
Return objects having attributes with the given key, category,
|
||||
value, strvalue or combination of those criteria.
|
||||
|
|
|
|||
|
|
@ -205,29 +205,33 @@ help_entries = search_help
|
|||
# not the attribute object itself (this is usually what you want)
|
||||
|
||||
|
||||
def search_object_attribute(key=None, category=None, value=None,
|
||||
strvalue=None, attrtype=None, **kwargs):
|
||||
def search_object_attribute(
|
||||
key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
|
||||
):
|
||||
return ObjectDB.objects.get_by_attribute(
|
||||
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||
)
|
||||
|
||||
|
||||
def search_account_attribute(key=None, category=None, value=None,
|
||||
strvalue=None, attrtype=None, **kwargs):
|
||||
def search_account_attribute(
|
||||
key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
|
||||
):
|
||||
return AccountDB.objects.get_by_attribute(
|
||||
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||
)
|
||||
|
||||
|
||||
def search_script_attribute(key=None, category=None, value=None,
|
||||
strvalue=None, attrtype=None, **kwargs):
|
||||
def search_script_attribute(
|
||||
key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
|
||||
):
|
||||
return ScriptDB.objects.get_by_attribute(
|
||||
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||
)
|
||||
|
||||
|
||||
def search_channel_attribute(key=None, category=None, value=None,
|
||||
strvalue=None, attrtype=None, **kwargs):
|
||||
def search_channel_attribute(
|
||||
key=None, category=None, value=None, strvalue=None, attrtype=None, **kwargs
|
||||
):
|
||||
return Channel.objects.get_by_attribute(
|
||||
key=key, category=category, value=value, strvalue=strvalue, attrtype=attrtype, **kwargs
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2041,7 +2041,9 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
|||
if multimatch_string:
|
||||
error = "%s\n" % multimatch_string
|
||||
else:
|
||||
error = _("More than one match for '{query}' (please narrow target):\n").format(query=query)
|
||||
error = _("More than one match for '{query}' (please narrow target):\n").format(
|
||||
query=query
|
||||
)
|
||||
|
||||
for num, result in enumerate(matches):
|
||||
# we need to consider Commands, where .aliases is a list
|
||||
|
|
|
|||
|
|
@ -67,7 +67,11 @@ def datetime(entry, option_key="Datetime", account=None, from_tz=None, **kwargs)
|
|||
try:
|
||||
from_tz = _pytz.timezone(acct_tz)
|
||||
except Exception as err:
|
||||
raise ValueError(_("Timezone string '{acct_tz}' is not a valid timezone ({err})").format(acct_tz=acct_tz, err=err))
|
||||
raise ValueError(
|
||||
_("Timezone string '{acct_tz}' is not a valid timezone ({err})").format(
|
||||
acct_tz=acct_tz, err=err
|
||||
)
|
||||
)
|
||||
else:
|
||||
from_tz = _pytz.UTC
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue