Apply black to codes

This commit is contained in:
Griatch 2024-04-01 17:51:05 +02:00
parent 870c0f5f75
commit c5a4a34bac
180 changed files with 495 additions and 288 deletions

View file

@ -374,8 +374,12 @@ def setup(app):
# build toctree file
sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.dirname(__file__))))
from docs.pylib import (auto_link_remapper, contrib_readmes2docs,
update_default_cmd_index, update_dynamic_pages)
from docs.pylib import (
auto_link_remapper,
contrib_readmes2docs,
update_default_cmd_index,
update_dynamic_pages,
)
_no_autodoc = os.environ.get("NOAUTODOC")
update_default_cmd_index.run_update(no_autodoc=_no_autodoc)

View file

@ -16,6 +16,7 @@ to launch such a shell (using python or ipython depending on your install).
See www.evennia.com for full documentation.
"""
import evennia
# docstring header

View file

@ -10,18 +10,20 @@ character object, so you should customize that
instead for most things).
"""
import re
import time
import typing
from random import getrandbits
import evennia
from django.conf import settings
from django.contrib.auth import authenticate, password_validation
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.utils import timezone
from django.utils.module_loading import import_string
from django.utils.translation import gettext as _
import evennia
from evennia.accounts.manager import AccountManager
from evennia.accounts.models import AccountDB
from evennia.commands.cmdsethandler import CmdSetHandler
@ -29,17 +31,24 @@ from evennia.comms.models import ChannelDB
from evennia.objects.models import ObjectDB
from evennia.scripts.scripthandler import ScriptHandler
from evennia.server.models import ServerConfig
from evennia.server.signals import (SIGNAL_ACCOUNT_POST_CREATE,
SIGNAL_ACCOUNT_POST_LOGIN_FAIL,
SIGNAL_OBJECT_POST_PUPPET,
SIGNAL_OBJECT_POST_UNPUPPET)
from evennia.server.signals import (
SIGNAL_ACCOUNT_POST_CREATE,
SIGNAL_ACCOUNT_POST_LOGIN_FAIL,
SIGNAL_OBJECT_POST_PUPPET,
SIGNAL_OBJECT_POST_UNPUPPET,
)
from evennia.server.throttle import Throttle
from evennia.typeclasses.attributes import ModelAttributeBackend, NickHandler
from evennia.typeclasses.models import TypeclassBase
from evennia.utils import class_from_module, create, logger
from evennia.utils.optionhandler import OptionHandler
from evennia.utils.utils import (is_iter, lazy_property, make_iter, to_str,
variable_from_module)
from evennia.utils.utils import (
is_iter,
lazy_property,
make_iter,
to_str,
variable_from_module,
)
__all__ = ("DefaultAccount", "DefaultGuest")

View file

@ -7,6 +7,7 @@ import datetime
from django.conf import settings
from django.contrib.auth.models import UserManager
from django.utils import timezone
from evennia.server import signals
from evennia.typeclasses.managers import TypeclassManager, TypedObjectManager
from evennia.utils.utils import class_from_module, dbid_to_obj, make_iter

View file

@ -15,6 +15,7 @@ persistently store attributes of its own. This is ideal for extra
account info and OOC account configuration variables etc.
"""
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.db import models

View file

@ -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

View file

@ -6,7 +6,6 @@ same inputs as the default one.
"""
import re
from django.conf import settings

View file

@ -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 _

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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,

View file

@ -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,

View file

@ -1,6 +1,7 @@
"""
This module stores session-level commands.
"""
from evennia.commands.cmdset import CmdSet
from evennia.commands.default import account

View file

@ -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

View file

@ -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 = []

View file

@ -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

View file

@ -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):

View file

@ -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])

View file

@ -2,6 +2,7 @@
Commands that are available from the connect screen.
"""
import datetime
import re
from codecs import lookup as codecs_lookup

View file

@ -2,6 +2,7 @@
Base typeclass for in-game Channels.
"""
import re
from django.contrib.contenttypes.models import ContentType

View file

@ -4,7 +4,6 @@ Comm system components.
"""
from django.conf import settings
from django.db.models import Q

View file

@ -18,6 +18,7 @@ connect to channels by use of a ChannelConnect object (this object is
necessary to easily be able to delete connections on the fly).
"""
from django.conf import settings
from django.db import models
from django.utils import timezone

View file

@ -221,7 +221,6 @@ def get_available_overwrite_name(name, max_length):
@deconstructible
class S3Boto3StorageFile(File):
"""
The default file object used by the S3Boto3Storage backend.
This file implements file streaming using boto's multipart

View file

@ -2,5 +2,6 @@
Build-menu contrib - vincent-lg 2018
"""
from .building_menu import BuildingMenu # noqa
from .building_menu import GenericBuildingCmd # noqa

View file

@ -331,7 +331,6 @@ def menu_edit(caller, choice, obj):
class CmdNoInput(Command):
"""No input has been found."""
key = _CMD_NOINPUT
@ -352,7 +351,6 @@ class CmdNoInput(Command):
class CmdNoMatch(Command):
"""No input has been found."""
key = _CMD_NOMATCH
@ -394,7 +392,6 @@ class CmdNoMatch(Command):
class BuildingMenuCmdSet(CmdSet):
"""Building menu CmdSet."""
key = "building_menu"
@ -421,7 +418,6 @@ class BuildingMenuCmdSet(CmdSet):
class Choice:
"""A choice object, created by `add_choice`."""
def __init__(
@ -557,7 +553,6 @@ class Choice:
class BuildingMenu:
"""
Class allowing to create and set building menus to edit specific objects.
@ -1200,7 +1195,6 @@ class BuildingMenu:
# Generic building menu and command
class GenericBuildingMenu(BuildingMenu):
"""A generic building menu, allowing to edit any object.
This is more a demonstration menu. By default, it allows to edit the
@ -1241,7 +1235,6 @@ class GenericBuildingMenu(BuildingMenu):
class GenericBuildingCmd(Command):
"""
Generic building command.

View file

@ -7,6 +7,7 @@ This helps writing isolated code and reusing it over multiple objects.
See the docs for more information.
"""
from . import exceptions # noqa
from .component import Component # noqa
from .dbfield import DBField, NDBField, TagField # noqa

View file

@ -3,6 +3,7 @@ Components - ChrisLR 2022
This file contains the Descriptors used to set Fields in Components
"""
import typing
from evennia.typeclasses.attributes import AttributeProperty, NAttributeProperty

View file

@ -309,7 +309,6 @@ def schedule(callback, repeat=False, **kwargs):
class GametimeScript(DefaultScript):
"""Gametime-sensitive script."""
def at_script_creation(self):

View file

@ -10,6 +10,7 @@ You could also pass extra data to this client for advanced functionality.
See the docs for more information.
"""
from evennia.contrib.base_systems.godotwebsocket.text2bbcode import (
BBCODE_PARSER,
parse_to_bbcode,

View file

@ -3,6 +3,7 @@ Godot Websocket - ChrisLR 2022
This file contains the necessary code and data to convert text with color tags to bbcode (For godot)
"""
from evennia.utils.ansi import *
from evennia.utils.text2html import TextToHTMLparser

View file

@ -4,6 +4,7 @@ Godot Websocket - ChrisLR 2022
This file contains the code necessary to dedicate a port to communicate with Godot via Websockets.
It uses the plugin system and should be plugged via settings as detailed in the readme.
"""
import json
from autobahn.twisted import WebSocketServerFactory

View file

@ -6,7 +6,6 @@ from collections import namedtuple
class CallbackHandler(object):
"""
The callback handler for a specific object.

View file

@ -70,7 +70,6 @@ Use the /del switch to remove callbacks that should not be connected.
class CmdCallback(COMMAND_DEFAULT_CLASS):
"""
Command to edit callbacks.
"""

View file

@ -27,7 +27,6 @@ RE_LINE_ERROR = re.compile(r'^ File "\<string\>", line (\d+)')
class EventHandler(DefaultScript):
"""
The event handler that contains all events in a global script.
@ -600,7 +599,6 @@ class EventHandler(DefaultScript):
# Script to call time-related events
class TimeEventScript(DefaultScript):
"""Gametime-sensitive script."""
def at_script_creation(self):

View file

@ -25,7 +25,6 @@ OLD_EVENTS = {}
class TestEventHandler(BaseEvenniaTest):
"""
Test cases of the event handler to add, edit or delete events.
"""
@ -259,7 +258,6 @@ class TestEventHandler(BaseEvenniaTest):
class TestCmdCallback(BaseEvenniaCommandTest):
"""Test the @callback command."""
def setUp(self):
@ -448,7 +446,6 @@ class TestCmdCallback(BaseEvenniaCommandTest):
class TestDefaultCallbacks(BaseEvenniaCommandTest):
"""Test the default callbacks."""
def setUp(self):

View file

@ -166,7 +166,6 @@ Variables you can use in this event:
@register_events
class EventCharacter(DefaultCharacter):
"""Typeclass to represent a character and call event types."""
_events = {
@ -625,7 +624,6 @@ Variables you can use in this event:
@register_events
class EventExit(DefaultExit):
"""Modified exit including management of events."""
_events = {
@ -721,7 +719,6 @@ Variables you can use in this event:
@register_events
class EventObject(DefaultObject):
"""Default object with management of events."""
_events = {
@ -892,7 +889,6 @@ Variables you can use in this event:
@register_events
class EventRoom(DefaultRoom):
"""Default room with management of events."""
_events = {

View file

@ -251,7 +251,6 @@ def phrase_event(callbacks, parameters):
class InterruptEvent(RuntimeError):
"""
Interrupt the current event.

View file

@ -21,10 +21,14 @@ called automatically when a new user connects.
"""
from django.conf import settings
from evennia import CmdSet, Command, syscmdkeys
from evennia.utils.evmenu import EvMenu
from evennia.utils.utils import (callables_from_module, class_from_module,
random_string_from_module)
from evennia.utils.utils import (
callables_from_module,
class_from_module,
random_string_from_module,
)
_CONNECTION_SCREEN_MODULE = settings.CONNECTION_SCREEN_MODULE
_GUEST_ENABLED = settings.GUEST_ENABLED

View file

@ -41,6 +41,7 @@ class CharacterCmdSet(default_cmds.CharacterCmdSet):
```
"""
from django.conf import settings
from evennia.commands.cmdset import CmdSet

View file

@ -9,7 +9,6 @@ from .unixcommand import UnixCommand
class CmdDummy(UnixCommand):
"""A dummy UnixCommand."""
key = "dummy"

View file

@ -72,14 +72,12 @@ from evennia.utils.ansi import raw
class ParseError(Exception):
"""An error occurred during parsing."""
pass
class UnixCommandParser(argparse.ArgumentParser):
"""A modifier command parser for unix commands.
This parser is used to replace `argparse.ArgumentParser`. It
@ -183,7 +181,6 @@ class UnixCommandParser(argparse.ArgumentParser):
class HelpAction(argparse.Action):
"""Override the -h/--help action in the default parser.
Using the default -h/--help will call the exit function in different

View file

@ -7,6 +7,7 @@ Here player user can set their own description as well as select to create a
new room (to start from scratch) or join an existing room (with other players).
"""
from evennia import EvMenu
from evennia.utils import create, justify, list_to_string, logger
from evennia.utils.evmenu import list_node

View file

@ -43,6 +43,7 @@ Available parents:
- Positionable (supports sit/lie/knee/climb at once)
"""
import inspect
import re

View file

@ -2,6 +2,7 @@
Unit tests for the Evscaperoom
"""
import inspect
import pkgutil
from os import path

View file

@ -72,9 +72,11 @@ with which to test the system:
wear shirt
"""
from collections import defaultdict
from django.conf import settings
from evennia import DefaultCharacter, DefaultObject, default_cmds
from evennia.commands.default.muxcommand import MuxCommand
from evennia.utils import (

View file

@ -30,6 +30,7 @@ or implement the same locks/hooks in your own typeclasses.
at_pre_get_from(getter, target, **kwargs) - called with the pre-get hooks
at_pre_put_in(putter, target, **kwargs) - called with the pre-put hooks
"""
from django.conf import settings
from evennia import AttributeProperty, CmdSet, DefaultObject

View file

@ -615,9 +615,11 @@ class CraftingRecipe(CraftingRecipeBase):
)
else:
self.output_names = [
prot.get("key", prot.get("typeclass", "unnamed"))
if isinstance(prot, dict)
else str(prot)
(
prot.get("key", prot.get("typeclass", "unnamed"))
if isinstance(prot, dict)
else str(prot)
)
for prot in self.output_prototypes
]

View file

@ -3,7 +3,6 @@ Test gendersub contrib.
"""
from mock import patch
from evennia.commands.default.tests import BaseEvenniaCommandTest

View file

@ -25,6 +25,7 @@ Reload the server and you should have the +desc command available (it
will replace the default `desc` command).
"""
import re
from evennia import default_cmds

View file

@ -47,8 +47,17 @@ from collections import deque
from django.conf import settings
from django.db.models import Q
from evennia import (CmdSet, DefaultRoom, EvEditor, FuncParser,
InterruptCommand, default_cmds, gametime, utils)
from evennia import (
CmdSet,
DefaultRoom,
EvEditor,
FuncParser,
InterruptCommand,
default_cmds,
gametime,
utils,
)
from evennia.typeclasses.attributes import AttributeProperty
from evennia.utils.utils import list_to_string, repeat
@ -814,7 +823,6 @@ class CmdExtendedRoomDesc(default_cmds.CmdDesc):
class CmdExtendedRoomDetail(default_cmds.MuxCommand):
"""
sets a detail on a room

View file

@ -6,11 +6,12 @@ Testing of ExtendedRoom contrib
import datetime
from django.conf import settings
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaCommandTest, EvenniaTestCase
from mock import Mock, patch
from parameterized import parameterized
from evennia import create_object
from evennia.utils.test_resources import BaseEvenniaCommandTest, EvenniaTestCase
from . import extended_room

View file

@ -56,6 +56,7 @@ This changes the default map width/height. 2-5 for most clients is sensible.
If you don't want the player to be able to specify the size of the map, ignore any
arguments passed into the Map command.
"""
import time
from django.conf import settings

View file

@ -3,7 +3,6 @@ Tests of ingame_map_display.
"""
from typeclasses import exits, rooms
from evennia.commands.default.tests import BaseEvenniaCommandTest

View file

@ -3,7 +3,6 @@ Tests of simpledoor.
"""
from evennia.commands.default.tests import BaseEvenniaCommandTest
from . import simpledoor

View file

@ -2,6 +2,7 @@
XYZGrid - Griatch 2021
"""
from . import (
example,
launchcmd,

View file

@ -14,6 +14,7 @@ and/or
{'prototype_parent': 'xyz_exit', ...}
"""
from django.conf import settings
try:

View file

@ -3,14 +3,15 @@
Tests for the XYZgrid system.
"""
from random import randint
from unittest import mock
from django.test import TestCase
from evennia.utils.test_resources import (BaseEvenniaCommandTest,
BaseEvenniaTest)
from parameterized import parameterized
from evennia.utils.test_resources import BaseEvenniaCommandTest, BaseEvenniaTest
from . import commands, xymap, xymap_legend, xyzgrid, xyzroom
MAP1 = """

View file

@ -92,6 +92,7 @@ See `./example.py` for a full grid example.
----
"""
import pickle
from collections import defaultdict
from os import mkdir
@ -108,6 +109,7 @@ except ImportError as err:
"the SciPy package. Install with `pip install scipy'."
)
from django.conf import settings
from evennia.prototypes import prototypes as protlib
from evennia.prototypes.spawner import flatten_prototype
from evennia.utils import logger
@ -172,6 +174,7 @@ class XYMap:
but recommended for readability!
"""
mapcorner_symbol = "+"
max_pathfinding_length = 500
empty_symbol = " "
@ -475,10 +478,10 @@ class XYMap:
max_X, max_Y = max(max_X, iX), max(max_Y, iY)
node_index += 1
xygrid[ix][iy] = XYgrid[iX][iY] = node_index_map[
node_index
] = mapnode_or_link_class(
x=ix, y=iy, Z=self.Z, node_index=node_index, symbol=char, xymap=self
xygrid[ix][iy] = XYgrid[iX][iY] = node_index_map[node_index] = (
mapnode_or_link_class(
x=ix, y=iy, Z=self.Z, node_index=node_index, symbol=char, xymap=self
)
)
else:
@ -668,8 +671,7 @@ class XYMap:
"""
global _XYZROOMCLASS
if not _XYZROOMCLASS:
from evennia.contrib.grid.xyzgrid.xyzroom import \
XYZRoom as _XYZROOMCLASS
from evennia.contrib.grid.xyzgrid.xyzroom import XYZRoom as _XYZROOMCLASS
x, y = xy
wildcard = "*"
spawned = []

View file

@ -20,11 +20,11 @@ import uuid
from collections import defaultdict
from django.core import exceptions as django_exceptions
from evennia.prototypes import spawner
from evennia.utils.utils import class_from_module
from .utils import (BIGVAL, MAPSCAN, REVERSE_DIRECTIONS, MapError,
MapParserError)
from .utils import BIGVAL, MAPSCAN, REVERSE_DIRECTIONS, MapError, MapParserError
NodeTypeclass = None
ExitTypeclass = None
@ -844,6 +844,7 @@ class SmartRerouterMapLink(MapLink):
/|
"""
multilink = True
def get_direction(self, start_direction):

View file

@ -16,6 +16,7 @@ The grid has three main functions:
"""
from evennia.scripts.scripts import DefaultScript
from evennia.utils import logger
from evennia.utils.utils import variable_from_module

View file

@ -1,4 +1,3 @@
from .buff import (BaseBuff, BuffableProperty, BuffHandler, CmdBuff, # noqa
Mod, cleanup_buffs, tick_buff)
from .samplebuffs import (Exploit, Exploited, Leeching, Poison, Sated, # noqa
StatBuff)
from .buff import CmdBuff # noqa
from .buff import BaseBuff, BuffableProperty, BuffHandler, Mod, cleanup_buffs, tick_buff
from .samplebuffs import Exploit, Exploited, Leeching, Poison, Sated, StatBuff # noqa

View file

@ -98,6 +98,7 @@ You can see all the features of the `BaseBuff` class below, or browse `samplebuf
many attributes and hook methods you can overload to create complex, interrelated buffs.
"""
import time
from random import random

View file

@ -1,6 +1,7 @@
"""
Tests for the buff system contrib
"""
from unittest.mock import Mock, call, patch
from evennia import DefaultObject, create_object

View file

@ -15,6 +15,7 @@ and examples, including how to allow players to choose and confirm
character names from within the menu.
"""
import string
from random import choices

View file

@ -57,6 +57,7 @@ of the roll separately:
"""
import re
from ast import literal_eval
from random import randint

View file

@ -137,6 +137,7 @@ This allows to quickly build a large corpus of translated words
that never change (if this is desired).
"""
import re
from collections import defaultdict
from random import choice, randint

View file

@ -148,19 +148,25 @@ Extra Installation Instructions:
`type/reset/force me = typeclasses.characters.Character`
"""
import re
from collections import defaultdict
from string import punctuation
import inflect
from django.conf import settings
from evennia.commands.cmdset import CmdSet
from evennia.commands.command import Command
from evennia.objects.models import ObjectDB
from evennia.objects.objects import DefaultCharacter, DefaultObject
from evennia.utils import ansi, logger
from evennia.utils.utils import (iter_to_str, lazy_property, make_iter,
variable_from_module)
from evennia.utils.utils import (
iter_to_str,
lazy_property,
make_iter,
variable_from_module,
)
_INFLECT = inflect.engine()

View file

@ -2,9 +2,11 @@
Tests for RP system
"""
import time
from anything import Anything
from evennia import DefaultObject, create_object, default_cmds
from evennia.commands.default import building
from evennia.commands.default.tests import BaseEvenniaCommandTest
@ -426,11 +428,11 @@ class TestRPSystemCommands(BaseEvenniaCommandTest):
self.call(default_cmds.CmdLook(), "Mushroom-2", expected_third_call) # FAILS
expected_fourth_call = "Alias(es) for 'Mushroom' set to 'fungus'."
self.call(building.CmdSetObjAlias(), "Mushroom-1 = fungus", expected_fourth_call) #PASSES
self.call(building.CmdSetObjAlias(), "Mushroom-1 = fungus", expected_fourth_call) # PASSES
expected_fifth_call = [
"More than one match for 'Mushroom' (please narrow target):",
f" Mushroom-1 [fungus]",
f" Mushroom-2",
]
self.call(default_cmds.CmdLook(), "Mushroom", "\n".join(expected_fifth_call)) # PASSES
self.call(default_cmds.CmdLook(), "Mushroom", "\n".join(expected_fifth_call)) # PASSES

View file

@ -452,7 +452,6 @@ class Character(DefaultCharacter):
"""
from functools import total_ordering
from time import time

View file

@ -13,6 +13,7 @@ The script will only send messages to the object it is stored on, so
make sure to put it on yourself or you won't see any messages!
"""
import random
from evennia import DefaultScript

View file

@ -2,6 +2,7 @@
Tests for the bodyfunctions.
"""
from mock import Mock, patch
from evennia.utils.test_resources import BaseEvenniaTest

View file

@ -49,9 +49,9 @@ class AIHandler:
def __init__(self, obj):
self.obj = obj
self.ai_state = obj.attributes.get(self.attribute_name,
category=self.attribute_category,
default="idle")
self.ai_state = obj.attributes.get(
self.attribute_name, category=self.attribute_category, default="idle"
)
def set_state(self, state):
self.ai_state = state
@ -122,6 +122,7 @@ class AIMixin:
of multiple inheritance. In a real game, you would probably want to use a mixin like this.
"""
@lazy_property
def ai(self):
return AIHandler(self)

View file

@ -2,6 +2,7 @@
EvAdventure character generation.
"""
from django.conf import settings
from evennia.objects.models import ObjectDB

View file

@ -18,7 +18,6 @@ action that takes several vulnerable turns to complete.
"""
import random
from collections import defaultdict
@ -26,9 +25,15 @@ from evennia import AttributeProperty, CmdSet, Command, EvMenu
from evennia.utils import inherits_from, list_to_string
from .characters import EvAdventureCharacter
from .combat_base import (CombatAction, CombatActionAttack, CombatActionHold,
CombatActionStunt, CombatActionUseItem,
CombatActionWield, EvAdventureCombatBaseHandler)
from .combat_base import (
CombatAction,
CombatActionAttack,
CombatActionHold,
CombatActionStunt,
CombatActionUseItem,
CombatActionWield,
EvAdventureCombatBaseHandler,
)
from .enums import Ability

View file

@ -6,15 +6,27 @@ This implements a 'twitch' (aka DIKU or other traditional muds) style of MUD com
----
"""
from evennia import AttributeProperty, CmdSet, default_cmds
from evennia.commands.command import Command, InterruptCommand
from evennia.utils.utils import (display_len, inherits_from, list_to_string,
pad, repeat, unrepeat)
from evennia.utils.utils import (
display_len,
inherits_from,
list_to_string,
pad,
repeat,
unrepeat,
)
from .characters import EvAdventureCharacter
from .combat_base import (CombatActionAttack, CombatActionHold,
CombatActionStunt, CombatActionUseItem,
CombatActionWield, EvAdventureCombatBaseHandler)
from .combat_base import (
CombatActionAttack,
CombatActionHold,
CombatActionStunt,
CombatActionUseItem,
CombatActionWield,
EvAdventureCombatBaseHandler,
)
from .enums import ABILITY_REVERSE_MAP

View file

@ -105,10 +105,10 @@ class EvAdventureDungeonRoom(EvAdventureRoom):
"""
self.tags.add("not_clear", category="dungeon_room")
def clear_room(self):
self.tags.remove("not_clear", category="dungeon_room")
@property
def is_room_clear(self):
return not bool(self.tags.get("not_clear", category="dungeon_room"))
@ -146,9 +146,7 @@ class EvAdventureDungeonExit(DefaultExit):
dungeon_branch = self.location.db.dungeon_branch
if target_location == self.location:
# destination points back to us - create a new room
self.destination = target_location = dungeon_branch.new_room(
self
)
self.destination = target_location = dungeon_branch.new_room(self)
dungeon_branch.register_exit_traversed(self)
super().at_traverse(traversing_object, target_location, **kwargs)

View file

@ -17,6 +17,7 @@ To get the `value` of an enum (must always be hashable, useful for Attribute loo
----
"""
from enum import Enum

View file

@ -2,6 +2,7 @@
EvAdventure NPCs. This includes both friends and enemies, only separated by their AI.
"""
from random import choice
from evennia import DefaultCharacter
@ -253,6 +254,7 @@ class EvAdventureMob(EvAdventureNPC):
Mob (mobile) NPC; this is usually an enemy.
"""
# change this to make the mob more or less likely to perform different actions
combat_probabilities = {
"hold": 0.0,

View file

@ -59,7 +59,6 @@ class EvAdventureQuest:
desc = "This is the base quest class"
start_step = "start"
# help entries for quests (could also be methods)
help_start = "You need to start first"
help_end = "You need to end the quest"
@ -191,8 +190,9 @@ class EvAdventureQuest:
"""
if self.status in ("abandoned", "completed", "failed"):
help_resource = getattr(self, f"help_{self.status}",
f"You have {self.status} this quest.")
help_resource = getattr(
self, f"help_{self.status}", f"You have {self.status} this quest."
)
else:
help_resource = getattr(self, f"help_{self.current_step}", "No help available.")
@ -203,7 +203,6 @@ class EvAdventureQuest:
# normally it's just a string
return str(help_resource)
# step methods and hooks
def step_start(self, *args, **kwargs):
@ -377,6 +376,7 @@ class CmdQuests(Command):
quest <questname>
"""
key = "quests"
aliases = ["quest"]
@ -399,4 +399,3 @@ class CmdQuests(Command):
for quest in quests:
self.msg(f"Quest {quest.key}: {quest.status}")

View file

@ -7,6 +7,7 @@ and determining what the outcome is.
----
"""
from random import randint
from .enums import Ability

View file

@ -2,6 +2,7 @@
Test the ai module.
"""
from unittest.mock import Mock, patch
from evennia import create_object

View file

@ -3,7 +3,6 @@ Test the EvAdventure equipment handler.
"""
from unittest.mock import MagicMock, patch
from parameterized import parameterized

View file

@ -17,7 +17,6 @@ Attacks using |w{attack_type_name}|n against |w{defense_type_name}|n
Damage roll: |w{damage_roll}|n""".strip()
def get_obj_stats(obj, owner=None):
"""
Get a string of stats about the object.

View file

@ -31,6 +31,7 @@ Timers are handled by persistent delays on the button. These are examples of
such as when closing the lid and un-blinding a character.
"""
import random
from evennia import CmdSet, Command, DefaultObject

View file

@ -2,6 +2,7 @@
Tutorial - talking NPC tests.
"""
from evennia.commands.default.tests import BaseEvenniaCommandTest
from evennia.utils.create import create_object

View file

@ -9,7 +9,6 @@ in a separate module (e.g. if they could have been re-used elsewhere.)
"""
import random
# the system error-handling module is defined in the settings. We load the

View file

@ -13,6 +13,7 @@ the easiest place to do it. Write a method and invoke it via
Evennia contribution - Johnny 2017
"""
import json
import syslog

View file

@ -5,6 +5,7 @@ user inputs and system outputs.
Evennia contribution - Johnny 2017
"""
import os
import re
import socket

View file

@ -138,6 +138,7 @@ Optional:
object dbrefs). For boolean fields, return '0' or '1' to set
the field to False or True.
"""
import evennia
from evennia import Command
from evennia.utils import delay, evmenu, evtable, list_to_string, logger

View file

@ -59,7 +59,6 @@ from evennia.utils.create import create_script
class RejectedRegex(RuntimeError):
"""The provided regular expression has been rejected.
More details regarding why this error occurred will be provided in
@ -72,14 +71,12 @@ class RejectedRegex(RuntimeError):
class ExhaustedGenerator(RuntimeError):
"""The generator hasn't any available strings to generate anymore."""
pass
class RandomStringGeneratorScript(DefaultScript):
"""
The global script to hold all generators.
@ -99,7 +96,6 @@ class RandomStringGeneratorScript(DefaultScript):
class RandomStringGenerator:
"""
A generator class to generate pseudo-random strings with a rule.

View file

@ -7,6 +7,7 @@ is setup to be the "default" character type created by the default
creation commands.
"""
from evennia.objects.objects import DefaultCharacter
from .objects import ObjectParent

View file

@ -6,6 +6,7 @@ set and has a single command defined on itself with the same name as its key,
for allowing Characters to traverse the exit to its destination.
"""
from evennia.objects.objects import DefaultExit
from .objects import ObjectParent

View file

@ -10,6 +10,7 @@ the other types, you can do so by adding this as a multiple
inheritance.
"""
from evennia.objects.objects import DefaultObject

View file

@ -6,7 +6,6 @@ The main web/urls.py includes these routes for all urls starting with `admin/`
"""
from django.urls import path
from evennia.web.admin.urls import urlpatterns as evennia_admin_urlpatterns

View file

@ -12,6 +12,7 @@ should modify urls.py in those sub directories.
Search the Django documentation for "URL dispatcher" for more help.
"""
from django.urls import include, path
# default evennia patterns

View file

@ -1,6 +1,7 @@
"""
Custom manager for HelpEntry objects.
"""
from django.db import IntegrityError
from evennia.server import signals

View file

@ -9,6 +9,7 @@ forms of help that do not concern commands, like information about the
game world, policy info, rules and similar.
"""
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.urls import reverse

View file

@ -5,6 +5,7 @@ sub-categories.
This is used primarily by the default `help` command.
"""
import re
from django.conf import settings

Some files were not shown because too many files have changed in this diff Show more