Apply black to codes
This commit is contained in:
parent
870c0f5f75
commit
c5a4a34bac
180 changed files with 495 additions and 288 deletions
|
|
@ -36,13 +36,14 @@ from weakref import WeakValueDictionary
|
|||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.task import deferLater
|
||||
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.command import InterruptCommand
|
||||
from evennia.utils import logger, utils
|
||||
from evennia.utils.utils import string_suggestions
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet.defer import inlineCallbacks, returnValue
|
||||
from twisted.internet.task import deferLater
|
||||
|
||||
_IN_GAME_ERRORS = settings.IN_GAME_ERRORS
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ same inputs as the default one.
|
|||
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ Set theory.
|
|||
to affect the low-priority cmdset. Ex: A1,A3 + B1,B2,B4,B5 = B2,B4,B5
|
||||
|
||||
"""
|
||||
|
||||
from weakref import WeakKeyDictionary
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ example, you can have a 'On a boat' set, onto which you then tack on
|
|||
the 'Fishing' set. Fishing from a boat? No problem!
|
||||
|
||||
"""
|
||||
|
||||
import sys
|
||||
from importlib import import_module
|
||||
from inspect import trace
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ The base Command class.
|
|||
All commands in Evennia inherit from the 'Command' class in this module.
|
||||
|
||||
"""
|
||||
|
||||
import inspect
|
||||
import math
|
||||
import re
|
||||
|
|
@ -11,6 +12,7 @@ import re
|
|||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.utils.text import slugify
|
||||
|
||||
from evennia.locks.lockhandler import LockHandler
|
||||
from evennia.utils.ansi import ANSIString
|
||||
from evennia.utils.evtable import EvTable
|
||||
|
|
@ -19,9 +21,7 @@ from evennia.utils.utils import fill, is_iter, lazy_property, make_iter
|
|||
CMD_IGNORE_PREFIXES = settings.CMD_IGNORE_PREFIXES
|
||||
|
||||
|
||||
|
||||
class InterruptCommand(Exception):
|
||||
|
||||
"""Cleanly interrupt a command."""
|
||||
|
||||
pass
|
||||
|
|
@ -491,22 +491,22 @@ class Command(metaclass=CommandMeta):
|
|||
Command \"{cmdname}\" has no defined `func()` method. Available properties on this command are:
|
||||
|
||||
{variables}"""
|
||||
variables = [" |w{}|n ({}): {}".format(
|
||||
key, type(val), f'"{val}"' if isinstance(val, str) else val
|
||||
variables = [
|
||||
" |w{}|n ({}): {}".format(key, type(val), f'"{val}"' if isinstance(val, str) else val)
|
||||
for key, val in (
|
||||
("self.key", self.key),
|
||||
("self.cmdname", self.cmdstring),
|
||||
("self.raw_cmdname", self.raw_cmdname),
|
||||
("self.raw_string", self.raw_string),
|
||||
("self.aliases", self.aliases),
|
||||
("self.args", self.args),
|
||||
("self.caller", self.caller),
|
||||
("self.obj", self.obj),
|
||||
("self.session", self.session),
|
||||
("self.locks", self.locks),
|
||||
("self.help_category", self.help_category),
|
||||
("self.cmdset", self.cmdset),
|
||||
)
|
||||
for key, val in
|
||||
(("self.key", self.key),
|
||||
("self.cmdname", self.cmdstring),
|
||||
("self.raw_cmdname", self.raw_cmdname),
|
||||
("self.raw_string", self.raw_string),
|
||||
("self.aliases", self.aliases),
|
||||
("self.args", self.args),
|
||||
("self.caller", self.caller),
|
||||
("self.obj", self.obj),
|
||||
("self.session", self.session),
|
||||
("self.locks", self.locks),
|
||||
("self.help_category", self.help_category),
|
||||
("self.cmdset", self.cmdset))
|
||||
]
|
||||
output = output_string.format(cmdname=self.key, variables="\n ".join(variables))
|
||||
self.msg(output)
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ self.msg() and similar methods to reroute returns to the correct
|
|||
method. Otherwise all text will be returned to all connected sessions.
|
||||
|
||||
"""
|
||||
|
||||
import time
|
||||
from codecs import lookup as codecs_lookup
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ the Evennia API. It is also a severe security risk and should
|
|||
therefore always be limited to superusers only.
|
||||
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
"""
|
||||
Building and world design commands
|
||||
"""
|
||||
|
||||
import re
|
||||
import typing
|
||||
|
||||
import evennia
|
||||
from django.conf import settings
|
||||
from django.core.paginator import Paginator
|
||||
from django.db.models import Max, Min, Q
|
||||
|
||||
import evennia
|
||||
from evennia import InterruptCommand
|
||||
from evennia.commands.cmdhandler import (generate_cmdset_providers,
|
||||
get_and_merge_cmdsets)
|
||||
from evennia.commands.cmdhandler import generate_cmdset_providers, get_and_merge_cmdsets
|
||||
from evennia.locks.lockhandler import LockException
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.prototypes import menus as olc_menus
|
||||
|
|
@ -23,10 +24,18 @@ from evennia.utils.dbserialize import deserialize
|
|||
from evennia.utils.eveditor import EvEditor
|
||||
from evennia.utils.evmore import EvMore
|
||||
from evennia.utils.evtable import EvTable
|
||||
from evennia.utils.utils import (class_from_module, crop, dbref, display_len,
|
||||
format_grid, get_all_typeclasses,
|
||||
inherits_from, interactive, list_to_string,
|
||||
variable_from_module)
|
||||
from evennia.utils.utils import (
|
||||
class_from_module,
|
||||
crop,
|
||||
dbref,
|
||||
display_len,
|
||||
format_grid,
|
||||
get_all_typeclasses,
|
||||
inherits_from,
|
||||
interactive,
|
||||
list_to_string,
|
||||
variable_from_module,
|
||||
)
|
||||
|
||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||
|
||||
|
|
@ -259,7 +268,7 @@ class CmdSetObjAlias(COMMAND_DEFAULT_CLASS):
|
|||
obj = caller.search(objname)
|
||||
if not obj:
|
||||
return
|
||||
if self.rhs is None and 'delete' not in self.switches:
|
||||
if self.rhs is None and "delete" not in self.switches:
|
||||
# no =, and not deleting, so we just list aliases on object.
|
||||
aliases = obj.aliases.all(return_key_and_category=True)
|
||||
if aliases:
|
||||
|
|
@ -300,7 +309,7 @@ class CmdSetObjAlias(COMMAND_DEFAULT_CLASS):
|
|||
if "delete" in self.switches:
|
||||
# delete all matching keys, regardless of category
|
||||
existed = False
|
||||
for key, category in obj.aliases.all(return_key_and_category=True):
|
||||
for key, category in obj.aliases.all(return_key_and_category=True):
|
||||
if key == self.rhs:
|
||||
obj.aliases.remove(key=self.rhs, category=category)
|
||||
existed = True
|
||||
|
|
@ -2956,9 +2965,9 @@ class CmdExamine(ObjManipCommand):
|
|||
):
|
||||
objdata["Stored Cmdset(s)"] = self.format_stored_cmdsets(obj)
|
||||
objdata["Merged Cmdset(s)"] = self.format_merged_cmdsets(obj, current_cmdset)
|
||||
objdata[
|
||||
f"Commands available to {obj.key} (result of Merged Cmdset(s))"
|
||||
] = self.format_current_cmds(obj, current_cmdset)
|
||||
objdata[f"Commands available to {obj.key} (result of Merged Cmdset(s))"] = (
|
||||
self.format_current_cmds(obj, current_cmdset)
|
||||
)
|
||||
if self.object_type == "script":
|
||||
objdata["Description"] = self.format_script_desc(obj)
|
||||
objdata["Persistent"] = self.format_script_is_persistent(obj)
|
||||
|
|
@ -3415,9 +3424,11 @@ class ScriptEvMore(EvMore):
|
|||
|
||||
table.add_row(
|
||||
f"#{script.id}",
|
||||
f"{script.obj.key}({script.obj.dbref})"
|
||||
if (hasattr(script, "obj") and script.obj)
|
||||
else "<Global>",
|
||||
(
|
||||
f"{script.obj.key}({script.obj.dbref})"
|
||||
if (hasattr(script, "obj") and script.obj)
|
||||
else "<Global>"
|
||||
),
|
||||
script.key,
|
||||
script.interval if script.interval > 0 else "--",
|
||||
nextrep,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ available (i.e. IC commands). Note that some commands, such as
|
|||
communication-commands are instead put on the account level, in the
|
||||
Account cmdset. Account commands remain available also to Characters.
|
||||
"""
|
||||
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.default import (
|
||||
admin,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
"""
|
||||
This module stores session-level commands.
|
||||
"""
|
||||
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.default import account
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ This module describes the unlogged state of the default game.
|
|||
The setting STATE_UNLOGGED should be set to the python path
|
||||
of the state instance in this module.
|
||||
"""
|
||||
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.default import unloggedin
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ Communication commands:
|
|||
|
||||
from django.conf import settings
|
||||
from django.db.models import Q
|
||||
|
||||
from evennia.accounts import bots
|
||||
from evennia.accounts.models import AccountDB
|
||||
from evennia.comms.comms import DefaultChannel
|
||||
|
|
@ -1412,13 +1413,17 @@ class CmdPage(COMMAND_DEFAULT_CLASS):
|
|||
message = f"{caller.key} {message.strip(':').strip()}"
|
||||
|
||||
# create the persistent message object
|
||||
create.create_message(caller, message, receivers=targets,
|
||||
locks=(f"read:id({caller.id}) or perm(Admin);"
|
||||
f"delete:id({caller.id}) or perm(Admin);"
|
||||
f"edit:id({caller.id}) or perm(Admin)"
|
||||
),
|
||||
tags = [("page", "comms")],
|
||||
)
|
||||
create.create_message(
|
||||
caller,
|
||||
message,
|
||||
receivers=targets,
|
||||
locks=(
|
||||
f"read:id({caller.id}) or perm(Admin);"
|
||||
f"delete:id({caller.id}) or perm(Admin);"
|
||||
f"edit:id({caller.id}) or perm(Admin)"
|
||||
),
|
||||
tags=[("page", "comms")],
|
||||
)
|
||||
|
||||
# tell the accounts they got a message.
|
||||
received = []
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
"""
|
||||
General Character commands usually available to all characters
|
||||
"""
|
||||
|
||||
import re
|
||||
|
||||
import evennia
|
||||
from django.conf import settings
|
||||
|
||||
import evennia
|
||||
from evennia.typeclasses.attributes import NickTemplateInvalid
|
||||
from evennia.utils import utils
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ System commands
|
|||
|
||||
"""
|
||||
|
||||
|
||||
import code
|
||||
import datetime
|
||||
import os
|
||||
|
|
@ -112,7 +111,6 @@ class CmdReset(COMMAND_DEFAULT_CLASS):
|
|||
|
||||
|
||||
class CmdShutdown(COMMAND_DEFAULT_CLASS):
|
||||
|
||||
"""
|
||||
stop the server completely
|
||||
|
||||
|
|
@ -277,7 +275,6 @@ def evennia_local_vars(caller):
|
|||
|
||||
|
||||
class EvenniaPythonConsole(code.InteractiveConsole):
|
||||
|
||||
"""Evennia wrapper around a Python interactive console."""
|
||||
|
||||
def __init__(self, caller):
|
||||
|
|
|
|||
|
|
@ -14,17 +14,32 @@ main test suite started with
|
|||
import datetime
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
import evennia
|
||||
from anything import Anything
|
||||
from django.conf import settings
|
||||
from django.test import override_settings
|
||||
from evennia import (DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom,
|
||||
ObjectDB, search_object)
|
||||
from parameterized import parameterized
|
||||
from twisted.internet import task
|
||||
|
||||
import evennia
|
||||
from evennia import (
|
||||
DefaultCharacter,
|
||||
DefaultExit,
|
||||
DefaultObject,
|
||||
DefaultRoom,
|
||||
ObjectDB,
|
||||
search_object,
|
||||
)
|
||||
from evennia.commands import cmdparser
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.command import Command, InterruptCommand
|
||||
from evennia.commands.default import (account, admin, batchprocess, building,
|
||||
comms, general)
|
||||
from evennia.commands.default import (
|
||||
account,
|
||||
admin,
|
||||
batchprocess,
|
||||
building,
|
||||
comms,
|
||||
general,
|
||||
)
|
||||
from evennia.commands.default import help as help_module
|
||||
from evennia.commands.default import syscommands, system, unloggedin
|
||||
from evennia.commands.default.cmdset_character import CharacterCmdSet
|
||||
|
|
@ -33,8 +48,6 @@ from evennia.prototypes import prototypes as protlib
|
|||
from evennia.utils import create, gametime, utils
|
||||
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
|
||||
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
|
||||
from parameterized import parameterized
|
||||
from twisted.internet import task
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Command testing
|
||||
|
|
@ -368,8 +381,7 @@ class TestCmdTasks(BaseEvenniaCommandTest):
|
|||
self.timedelay = 5
|
||||
global _TASK_HANDLER
|
||||
if _TASK_HANDLER is None:
|
||||
from evennia.scripts.taskhandler import \
|
||||
TASK_HANDLER as _TASK_HANDLER
|
||||
from evennia.scripts.taskhandler import TASK_HANDLER as _TASK_HANDLER
|
||||
_TASK_HANDLER.clock = task.Clock()
|
||||
self.task_handler = _TASK_HANDLER
|
||||
self.task_handler.clear()
|
||||
|
|
@ -787,19 +799,20 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(building.CmdSetObjAlias(), "Obj2 =", "No aliases to clear.")
|
||||
|
||||
self.call(building.CmdSetObjAlias(), "Obj =", "Cleared aliases from Obj: testobj1b")
|
||||
self.call(building.CmdSetObjAlias(),
|
||||
self.call(
|
||||
building.CmdSetObjAlias(),
|
||||
"/category Obj = testobj1b:category1",
|
||||
"Alias(es) for 'Obj' set to 'testobj1b' (category: 'category1')."
|
||||
"Alias(es) for 'Obj' set to 'testobj1b' (category: 'category1').",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetObjAlias(),
|
||||
"/category Obj = testobj1b:category2",
|
||||
"Alias(es) for 'Obj' set to 'testobj1b,testobj1b' (category: 'category2')."
|
||||
"Alias(es) for 'Obj' set to 'testobj1b,testobj1b' (category: 'category2').",
|
||||
)
|
||||
self.call(
|
||||
building.CmdSetObjAlias(), # delete both occurences of alias 'testobj1b'
|
||||
building.CmdSetObjAlias(), # delete both occurences of alias 'testobj1b'
|
||||
"/delete Obj = testobj1b",
|
||||
"Alias 'testobj1b' deleted from Obj."
|
||||
"Alias 'testobj1b' deleted from Obj.",
|
||||
)
|
||||
self.call(building.CmdSetObjAlias(), "Obj =", "No aliases to clear.")
|
||||
|
||||
|
|
@ -1773,8 +1786,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"{'prototype_key':'GOBLIN', 'typeclass':'evennia.objects.objects.DefaultCharacter', "
|
||||
"'key':'goblin', 'location':'%s'}"
|
||||
% spawnLoc.dbref,
|
||||
"'key':'goblin', 'location':'%s'}" % spawnLoc.dbref,
|
||||
"Spawned goblin",
|
||||
)
|
||||
goblin = get_object(self, "goblin")
|
||||
|
|
@ -1822,8 +1834,7 @@ class TestBuilding(BaseEvenniaCommandTest):
|
|||
self.call(
|
||||
building.CmdSpawn(),
|
||||
"/noloc {'prototype_parent':'TESTBALL', 'key': 'Ball', 'prototype_key': 'foo',"
|
||||
" 'location':'%s'}"
|
||||
% spawnLoc.dbref,
|
||||
" 'location':'%s'}" % spawnLoc.dbref,
|
||||
"Spawned Ball",
|
||||
)
|
||||
ball = get_object(self, "Ball")
|
||||
|
|
@ -2068,6 +2079,7 @@ class TestComms(BaseEvenniaCommandTest):
|
|||
receiver=self.account,
|
||||
)
|
||||
from evennia.comms.models import Msg
|
||||
|
||||
msgs = Msg.objects.filter(db_tags__db_key="page", db_tags__db_category="comms")
|
||||
self.assertEqual(msgs[0].senders, [self.account])
|
||||
self.assertEqual(msgs[0].receivers, [self.account2])
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
Commands that are available from the connect screen.
|
||||
|
||||
"""
|
||||
|
||||
import datetime
|
||||
import re
|
||||
from codecs import lookup as codecs_lookup
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue