diff --git a/evennia/accounts/accounts.py b/evennia/accounts/accounts.py index 8986d18473..49d3f550cc 100644 --- a/evennia/accounts/accounts.py +++ b/evennia/accounts/accounts.py @@ -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 [=description]|n - create new character") diff --git a/evennia/accounts/bots.py b/evennia/accounts/bots.py index 6c6a40d0db..420d96053d 100644 --- a/evennia/accounts/bots.py +++ b/evennia/accounts/bots.py @@ -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 diff --git a/evennia/commands/cmdhandler.py b/evennia/commands/cmdhandler.py index a0d9be8842..8ae1a7f285 100644 --- a/evennia/commands/cmdhandler.py +++ b/evennia/commands/cmdhandler.py @@ -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) diff --git a/evennia/commands/cmdsethandler.py b/evennia/commands/cmdsethandler.py index 4a746df33e..b2eb95c886 100644 --- a/evennia/commands/cmdsethandler.py +++ b/evennia/commands/cmdsethandler.py @@ -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 diff --git a/evennia/help/manager.py b/evennia/help/manager.py index 646758d202..398312a203 100644 --- a/evennia/help/manager.py +++ b/evennia/help/manager.py @@ -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): diff --git a/evennia/locks/lockhandler.py b/evennia/locks/lockhandler.py index 0f96b1d6a7..d2385a0aa7 100644 --- a/evennia/locks/lockhandler.py +++ b/evennia/locks/lockhandler.py @@ -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 diff --git a/evennia/objects/admin.py b/evennia/objects/admin.py index 5e18e8e0a4..59a1d85c68 100644 --- a/evennia/objects/admin.py +++ b/evennia/objects/admin.py @@ -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") diff --git a/evennia/server/portal/portal.py b/evennia/server/portal/portal.py index e16a9b6910..d883671d7f 100644 --- a/evennia/server/portal/portal.py +++ b/evennia/server/portal/portal.py @@ -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) diff --git a/evennia/server/portal/ssh.py b/evennia/server/portal/ssh.py index 73d9773583..19de7153da 100644 --- a/evennia/server/portal/ssh.py +++ b/evennia/server/portal/ssh.py @@ -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() diff --git a/evennia/server/portal/telnet.py b/evennia/server/portal/telnet.py index 62ef3d7338..ba6f025fed 100644 --- a/evennia/server/portal/telnet.py +++ b/evennia/server/portal/telnet.py @@ -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 diff --git a/evennia/server/session.py b/evennia/server/session.py index 1918c6998e..888b05ae45 100644 --- a/evennia/server/session.py +++ b/evennia/server/session.py @@ -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): """ diff --git a/evennia/server/sessionhandler.py b/evennia/server/sessionhandler.py index e315dc7a82..1a38d44279 100644 --- a/evennia/server/sessionhandler.py +++ b/evennia/server/sessionhandler.py @@ -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 diff --git a/evennia/settings_default.py b/evennia/settings_default.py index 67f6331e9c..28bb6cb97e 100644 --- a/evennia/settings_default.py +++ b/evennia/settings_default.py @@ -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" ###################################################################### diff --git a/evennia/typeclasses/managers.py b/evennia/typeclasses/managers.py index 4b83160e4c..fe2ffef3b2 100644 --- a/evennia/typeclasses/managers.py +++ b/evennia/typeclasses/managers.py @@ -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. diff --git a/evennia/utils/search.py b/evennia/utils/search.py index 45bdc86a87..c7231309ac 100644 --- a/evennia/utils/search.py +++ b/evennia/utils/search.py @@ -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 ) diff --git a/evennia/utils/utils.py b/evennia/utils/utils.py index 5b6aa0708b..dd8d7a2855 100644 --- a/evennia/utils/utils.py +++ b/evennia/utils/utils.py @@ -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 diff --git a/evennia/utils/validatorfuncs.py b/evennia/utils/validatorfuncs.py index e49bb716a8..3443c47d5c 100644 --- a/evennia/utils/validatorfuncs.py +++ b/evennia/utils/validatorfuncs.py @@ -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