Run black reformatter on code

This commit is contained in:
Griatch 2022-02-08 13:03:52 +01:00
parent 4582eb4085
commit bd3e31bf3c
178 changed files with 4511 additions and 3385 deletions

View file

@ -54,11 +54,12 @@ _CMDHANDLER = None
# Create throttles for too many account-creations and login attempts
CREATION_THROTTLE = Throttle(
name='creation', limit=settings.CREATION_THROTTLE_LIMIT,
timeout=settings.CREATION_THROTTLE_TIMEOUT
name="creation",
limit=settings.CREATION_THROTTLE_LIMIT,
timeout=settings.CREATION_THROTTLE_TIMEOUT,
)
LOGIN_THROTTLE = Throttle(
name='login', limit=settings.LOGIN_THROTTLE_LIMIT, timeout=settings.LOGIN_THROTTLE_TIMEOUT
name="login", limit=settings.LOGIN_THROTTLE_LIMIT, timeout=settings.LOGIN_THROTTLE_TIMEOUT
)
@ -802,8 +803,11 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
except Exception:
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
@ -879,7 +883,6 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
super().delete(*args, **kwargs)
return True
# methods inherited from database model
def msg(self, text=None, from_obj=None, session=None, options=None, **kwargs):
@ -968,9 +971,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
sessions = self.sessions.get()
session = sessions[0] if sessions else None
return _CMDHANDLER(
self, raw_string, callertype="account", session=session, **kwargs
)
return _CMDHANDLER(self, raw_string, callertype="account", session=session, **kwargs)
# channel receive hooks
@ -1000,11 +1001,11 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
"""
if senders:
sender_string = ', '.join(sender.get_display_name(self) for sender in senders)
sender_string = ", ".join(sender.get_display_name(self) for sender in senders)
message_lstrip = message.lstrip()
if message_lstrip.startswith((':', ';')):
if message_lstrip.startswith((":", ";")):
# this is a pose, should show as e.g. "User1 smiles to channel"
spacing = "" if message_lstrip[1:].startswith((':', '\'', ',')) else " "
spacing = "" if message_lstrip[1:].startswith((":", "'", ",")) else " "
message = f"{sender_string}{spacing}{message_lstrip[1:]}"
else:
# normal message
@ -1035,8 +1036,11 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
to customize the message for the receiver on the channel-level.
"""
self.msg(text=(message, {"from_channel": channel.id}),
from_obj=senders, options={"from_channel": channel.id})
self.msg(
text=(message, {"from_channel": channel.id}),
from_obj=senders,
options={"from_channel": channel.id},
)
def at_post_channel_msg(self, message, channel, senders=None, **kwargs):
"""
@ -1373,8 +1377,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
if _MUDINFO_CHANNEL is None:
if settings.CHANNEL_MUDINFO:
try:
_MUDINFO_CHANNEL = ChannelDB.objects.get(
db_key=settings.CHANNEL_MUDINFO["key"])
_MUDINFO_CHANNEL = ChannelDB.objects.get(db_key=settings.CHANNEL_MUDINFO["key"])
except ChannelDB.DoesNotExist:
logger.log_trace()
else:
@ -1383,7 +1386,8 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
if settings.CHANNEL_CONNECTINFO:
try:
_CONNECT_CHANNEL = ChannelDB.objects.get(
db_key=settings.CHANNEL_CONNECTINFO["key"])
db_key=settings.CHANNEL_CONNECTINFO["key"]
)
except ChannelDB.DoesNotExist:
logger.log_trace()
else:
@ -1661,7 +1665,8 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
if sess and sid:
result.append(
f"\n - |G{char.key}|n [{', '.join(char.permissions.all())}] "
f"(played by you in session {sid})")
f"(played by you in session {sid})"
)
else:
result.append(
f"\n - |R{char.key}|n [{', '.join(char.permissions.all())}] "

View file

@ -329,9 +329,7 @@ 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

View file

@ -276,8 +276,11 @@ class AccountDBManager(TypedObjectManager, UserManager):
new_account.set_password(password)
new_account._createdict = dict(
locks=locks, permissions=permissions,
report_to=report_to, tags=tags, attributes=attributes
locks=locks,
permissions=permissions,
report_to=report_to,
tags=tags,
attributes=attributes,
)
# saving will trigger the signal that calls the
# at_first_save hook on the typeclass, where the _createdict