mirror of
https://github.com/evennia/evennia.git
synced 2026-03-16 21:06:30 +01:00
Apply black on code
This commit is contained in:
parent
04ce4f6c5e
commit
0779ec82b6
70 changed files with 184 additions and 85 deletions
|
|
@ -16,13 +16,14 @@ 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
|
||||
|
|
@ -41,7 +42,13 @@ 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")
|
||||
|
||||
|
|
|
|||
|
|
@ -555,7 +555,7 @@ class DiscordBot(Bot):
|
|||
"""
|
||||
|
||||
factory_path = "evennia.server.portal.discord.DiscordWebsocketServerFactory"
|
||||
|
||||
|
||||
def _load_channels(self):
|
||||
self.ndb.ev_channels = {}
|
||||
if channel_links := self.db.channels:
|
||||
|
|
@ -594,7 +594,9 @@ class DiscordBot(Bot):
|
|||
if not channel.connect(self):
|
||||
logger.log_warn(f"{self} could not connect to Evennia channel {channel}.")
|
||||
if not channel.access(self, "send"):
|
||||
logger.log_warn(f"{self} doesn't have permission to send messages to Evennia channel {channel}.")
|
||||
logger.log_warn(
|
||||
f"{self} doesn't have permission to send messages to Evennia channel {channel}."
|
||||
)
|
||||
|
||||
# these will be made available as properties on the protocol factory
|
||||
configdict = {"uid": self.dbid}
|
||||
|
|
|
|||
|
|
@ -261,6 +261,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
|
|||
|
||||
class NoCmdSets(Exception):
|
||||
"No cmdsets found. Critical error."
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,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
|
||||
|
|
|
|||
|
|
@ -22,8 +22,9 @@ method. Otherwise all text will be returned to all connected sessions.
|
|||
import time
|
||||
from codecs import lookup as codecs_lookup
|
||||
|
||||
import evennia
|
||||
from django.conf import settings
|
||||
|
||||
import evennia
|
||||
from evennia.utils import create, logger, search, utils
|
||||
|
||||
COMMAND_DEFAULT_CLASS = utils.class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||
|
|
|
|||
|
|
@ -5,10 +5,11 @@ 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.locks.lockhandler import LockException
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ General Character commands usually available to all characters
|
|||
import re
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.objects.objects import DefaultObject
|
||||
from evennia.typeclasses.attributes import NickTemplateInvalid
|
||||
from evennia.utils import utils
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ from dataclasses import dataclass
|
|||
from itertools import chain
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.help.filehelp import FILE_HELP_ENTRIES
|
||||
from evennia.help.models import HelpEntry
|
||||
from evennia.help.utils import help_search_with_index, parse_entry_for_subcategories
|
||||
|
|
@ -20,7 +21,13 @@ from evennia.locks.lockhandler import LockException
|
|||
from evennia.utils import create, evmore
|
||||
from evennia.utils.ansi import ANSIString
|
||||
from evennia.utils.eveditor import EvEditor
|
||||
from evennia.utils.utils import class_from_module, dedent, format_grid, inherits_from, pad
|
||||
from evennia.utils.utils import (
|
||||
class_from_module,
|
||||
dedent,
|
||||
format_grid,
|
||||
inherits_from,
|
||||
pad,
|
||||
)
|
||||
|
||||
CMD_IGNORE_PREFIXES = settings.CMD_IGNORE_PREFIXES
|
||||
COMMAND_DEFAULT_CLASS = class_from_module(settings.COMMAND_DEFAULT_CLASS)
|
||||
|
|
|
|||
|
|
@ -7,15 +7,16 @@ System commands
|
|||
import code
|
||||
import datetime
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
import traceback
|
||||
|
||||
import django
|
||||
import evennia
|
||||
import subprocess
|
||||
import twisted
|
||||
from django.conf import settings
|
||||
|
||||
import evennia
|
||||
from evennia.accounts.models import AccountDB
|
||||
from evennia.scripts.taskhandler import TaskHandlerTask
|
||||
from evennia.utils import gametime, logger, search, utils
|
||||
|
|
|
|||
|
|
@ -14,27 +14,39 @@ 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 parameterized import parameterized
|
||||
from twisted.internet import task
|
||||
|
||||
from evennia.objects.objects import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.utils.search import search_object
|
||||
import evennia
|
||||
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
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.objects.objects import (
|
||||
DefaultCharacter,
|
||||
DefaultExit,
|
||||
DefaultObject,
|
||||
DefaultRoom,
|
||||
)
|
||||
from evennia.prototypes import prototypes as protlib
|
||||
from evennia.utils import create, gametime, utils
|
||||
from evennia.utils.search import search_object
|
||||
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
|
||||
from parameterized import parameterized
|
||||
from twisted.internet import task
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# Command testing
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ Unit testing for the Command system itself.
|
|||
"""
|
||||
|
||||
from django.test import override_settings
|
||||
|
||||
from evennia.commands import cmdparser
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.command import Command
|
||||
|
|
@ -990,9 +991,10 @@ class TestOptionTransferReplace(TestCase):
|
|||
|
||||
import sys
|
||||
|
||||
from evennia.commands import cmdhandler
|
||||
from twisted.trial.unittest import TestCase as TwistedTestCase
|
||||
|
||||
from evennia.commands import cmdhandler
|
||||
|
||||
|
||||
def _mockdelay(time, func, *args, **kwargs):
|
||||
return func(*args, **kwargs)
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ from django.contrib.contenttypes.models import ContentType
|
|||
from django.urls import reverse
|
||||
from django.utils.text import slugify
|
||||
|
||||
from evennia.objects.objects import DefaultObject
|
||||
from evennia.comms.managers import ChannelManager
|
||||
from evennia.comms.models import ChannelDB
|
||||
from evennia.objects.objects import DefaultObject
|
||||
from evennia.typeclasses.models import TypeclassBase
|
||||
from evennia.utils import create, logger
|
||||
from evennia.utils.utils import inherits_from, make_iter
|
||||
|
|
|
|||
|
|
@ -184,6 +184,7 @@ class Msg(SharedMemoryModel):
|
|||
|
||||
class Meta(object):
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Msg"
|
||||
|
||||
@lazy_property
|
||||
|
|
@ -712,6 +713,7 @@ class ChannelDB(TypedObject):
|
|||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Channel"
|
||||
verbose_name_plural = "Channels"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from django.test import SimpleTestCase
|
||||
|
||||
from evennia.comms.comms import DefaultChannel
|
||||
from evennia.commands.default.comms import CmdChannel
|
||||
from evennia.comms.comms import DefaultChannel
|
||||
from evennia.utils.create import create_message
|
||||
from evennia.utils.test_resources import BaseEvenniaTest
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for text2bbcode """
|
||||
"""Tests for text2bbcode"""
|
||||
|
||||
import mock
|
||||
from django.test import TestCase
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ class GodotWebSocketClient(webclient.WebSocketClient):
|
|||
def start_plugin_services(portal):
|
||||
class GodotWebsocket(WebSocketServerFactory):
|
||||
"Only here for better naming in logs"
|
||||
|
||||
pass
|
||||
|
||||
factory = GodotWebsocket()
|
||||
|
|
|
|||
|
|
@ -7,13 +7,18 @@ default ones in evennia core.
|
|||
|
||||
"""
|
||||
|
||||
from evennia.objects.objects import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
|
||||
from evennia.contrib.base_systems.ingame_python.callbackhandler import CallbackHandler
|
||||
from evennia.contrib.base_systems.ingame_python.utils import (
|
||||
phrase_event,
|
||||
register_events,
|
||||
time_event,
|
||||
)
|
||||
from evennia.objects.objects import (
|
||||
DefaultCharacter,
|
||||
DefaultExit,
|
||||
DefaultObject,
|
||||
DefaultRoom,
|
||||
)
|
||||
from evennia.utils.utils import inherits_from, lazy_property
|
||||
|
||||
# Character help
|
||||
|
|
|
|||
|
|
@ -7,12 +7,15 @@ These functions are to be used by developers to customize events and callbacks.
|
|||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.utils import logger
|
||||
from evennia.contrib.base_systems.custom_gametime import UNITS, gametime_to_realtime
|
||||
from evennia.contrib.base_systems.custom_gametime import (
|
||||
UNITS,
|
||||
gametime_to_realtime,
|
||||
)
|
||||
from evennia.contrib.base_systems.custom_gametime import (
|
||||
real_seconds_until as custom_rsu,
|
||||
)
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.create import create_script
|
||||
from evennia.utils.gametime import real_seconds_until as standard_rsu
|
||||
from evennia.utils.utils import class_from_module
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ The contrib can be further configured through two settings, `INGAME_REPORT_TYPES
|
|||
"""
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia import CmdSet
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
from evennia.comms.models import Msg
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
from unittest.mock import Mock, patch, MagicMock
|
||||
from evennia.utils import create
|
||||
from unittest.mock import MagicMock, Mock, patch
|
||||
|
||||
from evennia.comms.models import TempMsg
|
||||
from evennia.utils import create
|
||||
from evennia.utils.test_resources import EvenniaCommandTest
|
||||
|
||||
from . import menu, reports
|
||||
|
|
|
|||
|
|
@ -232,6 +232,7 @@ class MenuLoginEvMenu(EvMenu):
|
|||
|
||||
class UnloggedinCmdSet(CmdSet):
|
||||
"Cmdset for the unloggedin state"
|
||||
|
||||
key = "DefaultUnloggedin"
|
||||
priority = 0
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,9 @@ Admin/development commands
|
|||
|
||||
import re
|
||||
|
||||
import evennia
|
||||
from django.conf import settings
|
||||
|
||||
import evennia
|
||||
from evennia import default_cmds, syscmdkeys
|
||||
from evennia.commands.cmdset import CmdSet
|
||||
from evennia.commands.command import Command, InterruptCommand
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ The recognized fields for an achievement are:
|
|||
- name (str): The name of the achievement. This is not the key and does not need to be unique.
|
||||
- desc (str): The longer description of the achievement. Common uses for this would be flavor text
|
||||
or hints on how to complete it.
|
||||
- category (str): The category of conditions which this achievement tracks. It will most likely be
|
||||
- category (str): The category of conditions which this achievement tracks. It will most likely be
|
||||
an action and you will most likely specify it based on where you're checking from.
|
||||
e.g. killing 10 rats might have a category of "defeat", which you'd then check from your code
|
||||
that runs when a player defeats something.
|
||||
|
|
|
|||
|
|
@ -85,7 +85,9 @@ class TestClothingCmd(BaseEvenniaCommandTest):
|
|||
)
|
||||
|
||||
# Test remove command.
|
||||
self.call(clothing.CmdRemove(), "", "Usage: remove <worn clothing object>", caller=self.wearer)
|
||||
self.call(
|
||||
clothing.CmdRemove(), "", "Usage: remove <worn clothing object>", caller=self.wearer
|
||||
)
|
||||
self.call(
|
||||
clothing.CmdRemove(),
|
||||
"hat",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ To install, import and add the `ContainerCmdSet` to `CharacterCmdSet` in your `d
|
|||
|
||||
class CharacterCmdSet(default_cmds.CharacterCmdSet):
|
||||
# ...
|
||||
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
# ...
|
||||
self.add(ContainerCmdSet)
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ _RE_KEYS = re.compile(r"([\w\s]+)(?:\+*?)", re.U + re.I)
|
|||
|
||||
class DescValidateError(ValueError):
|
||||
"Used for tracebacks from desc systems"
|
||||
|
||||
pass
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
from evennia import CmdSet
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
from evennia.utils import list_to_string
|
||||
from evennia.utils.search import search_object_by_tag
|
||||
from evennia.commands.default.muxcommand import MuxCommand
|
||||
|
||||
SHARED_TAG_PREFIX = "shared"
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class TestIngameMap(BaseEvenniaCommandTest):
|
|||
create_object(
|
||||
exits.Exit,
|
||||
key="shopfront",
|
||||
aliases=["w","west"],
|
||||
aliases=["w", "west"],
|
||||
location=self.east_room,
|
||||
destination=self.west_room,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
"""
|
||||
Buffs - Tegiminis 2022
|
||||
|
||||
A buff is a timed object, attached to a game entity, that modifies values, triggers
|
||||
A buff is a timed object, attached to a game entity, that modifies values, triggers
|
||||
code, or both. It is a common design pattern in RPGs, particularly action games.
|
||||
|
||||
This contrib gives you a buff handler to apply to your objects, a buff class to extend them,
|
||||
|
|
@ -25,7 +25,7 @@ To make use of the handler, you will need:
|
|||
|
||||
### Applying a Buff
|
||||
|
||||
Call the handler `add(BuffClass)` method. This requires a class reference, and also contains a number of
|
||||
Call the handler `add(BuffClass)` method. This requires a class reference, and also contains a number of
|
||||
optional arguments to customize the buff's duration, stacks, and so on.
|
||||
|
||||
```python
|
||||
|
|
@ -36,8 +36,8 @@ self.buffs.add(ReflectBuff, to_cache={'reflect': 0.5}) # A single stack of Refl
|
|||
|
||||
### Modify
|
||||
|
||||
Call the handler `check(value, stat)` method wherever you want to see the modified value.
|
||||
This will return the value, modified by and relevant buffs on the handler's owner (identified by
|
||||
Call the handler `check(value, stat)` method wherever you want to see the modified value.
|
||||
This will return the value, modified by and relevant buffs on the handler's owner (identified by
|
||||
the `stat` string). For example:
|
||||
|
||||
```python
|
||||
|
|
@ -49,7 +49,7 @@ def take_damage(self, source, damage):
|
|||
|
||||
### Trigger
|
||||
|
||||
Call the handler `trigger(triggerstring)` method wherever you want an event call. This
|
||||
Call the handler `trigger(triggerstring)` method wherever you want an event call. This
|
||||
will call the `at_trigger` hook method on all buffs with the relevant trigger.
|
||||
|
||||
```python
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ Unit test module for Trait classes.
|
|||
from copy import copy
|
||||
|
||||
from anything import Something
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from evennia.objects.objects import DefaultCharacter
|
||||
from evennia.utils.test_resources import BaseEvenniaTestCase, EvenniaTest
|
||||
from mock import MagicMock, patch
|
||||
|
||||
from . import traits
|
||||
|
||||
|
|
|
|||
|
|
@ -456,9 +456,15 @@ from functools import total_ordering
|
|||
from time import time
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.dbserialize import _SaverDict
|
||||
from evennia.utils.utils import class_from_module, inherits_from, list_to_string, percent
|
||||
from evennia.utils.utils import (
|
||||
class_from_module,
|
||||
inherits_from,
|
||||
list_to_string,
|
||||
percent,
|
||||
)
|
||||
|
||||
# Available Trait classes.
|
||||
# This way the user can easily supply their own. Each
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ class CmdTalk(default_cmds.MuxCommand):
|
|||
|
||||
class TalkingCmdSet(CmdSet):
|
||||
"Stores the talk command."
|
||||
|
||||
key = "talkingcmdset"
|
||||
|
||||
def at_cmdset_creation(self):
|
||||
|
|
|
|||
|
|
@ -109,6 +109,7 @@ class HelpEntry(SharedMemoryModel):
|
|||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Help Entry"
|
||||
verbose_name_plural = "Help Entries"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ command test-suite).
|
|||
"""
|
||||
|
||||
from unittest import mock
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
from evennia.help import filehelp
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import re
|
|||
from django.conf import settings
|
||||
from lunr.stemmer import stemmer
|
||||
|
||||
|
||||
_RE_HELP_SUBTOPICS_START = re.compile(r"^\s*?#\s*?subtopics\s*?$", re.I + re.M)
|
||||
_RE_HELP_SUBTOPIC_SPLIT = re.compile(r"^\s*?(\#{2,6}\s*?\w+?[a-z0-9 \-\?!,\.]*?)$", re.M + re.I)
|
||||
_RE_HELP_SUBTOPIC_PARSE = re.compile(r"^(?P<nesting>\#{2,6})\s*?(?P<name>.*?)$", re.I + re.M)
|
||||
|
|
@ -80,12 +79,10 @@ class LunrSearch:
|
|||
before twisted's logging has been set up
|
||||
"""
|
||||
# Lunr-related imports
|
||||
from lunr import get_default_builder
|
||||
from lunr import lunr
|
||||
from lunr import stop_word_filter
|
||||
from lunr import get_default_builder, lunr, stop_word_filter
|
||||
from lunr.exceptions import QueryParseError
|
||||
from lunr.stemmer import stemmer
|
||||
from lunr.pipeline import Pipeline
|
||||
from lunr.stemmer import stemmer
|
||||
|
||||
# Store imported modules as instance attributes
|
||||
self.get_default_builder = get_default_builder
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ class ObjectDBManager(TypedObjectManager):
|
|||
)
|
||||
|
||||
# convert search term to partial-match regex
|
||||
search_regex = r".* ".join(r"\b" + re.escape(word) for word in ostring.split()) + r'.*'
|
||||
search_regex = r".* ".join(r"\b" + re.escape(word) for word in ostring.split()) + r".*"
|
||||
|
||||
# do the fuzzy search and return whatever it matches
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ from django.conf import settings
|
|||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.core.validators import validate_comma_separated_integer_list
|
||||
from django.db import models
|
||||
|
||||
from evennia.objects.manager import ObjectDBManager
|
||||
from evennia.typeclasses.models import TypedObject
|
||||
from evennia.utils import logger
|
||||
|
|
|
|||
|
|
@ -10,10 +10,11 @@ import time
|
|||
import typing
|
||||
from collections import defaultdict
|
||||
|
||||
import evennia
|
||||
import inflect
|
||||
from django.conf import settings
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
import evennia
|
||||
from evennia.commands import cmdset
|
||||
from evennia.commands.cmdsethandler import CmdSetHandler
|
||||
from evennia.objects.manager import ObjectManager
|
||||
|
|
|
|||
|
|
@ -1,7 +1,12 @@
|
|||
from unittest import skip
|
||||
|
||||
from evennia.objects.objects import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.objects.objects import (
|
||||
DefaultCharacter,
|
||||
DefaultExit,
|
||||
DefaultObject,
|
||||
DefaultRoom,
|
||||
)
|
||||
from evennia.typeclasses.attributes import AttributeProperty
|
||||
from evennia.typeclasses.tags import (
|
||||
AliasProperty,
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ from django.conf import settings
|
|||
from django.core.paginator import Paginator
|
||||
from django.db.models import Q
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from evennia.locks.lockhandler import check_lockstring, validate_lockstring
|
||||
from evennia.objects.models import ObjectDB
|
||||
from evennia.scripts.scripts import DefaultScript
|
||||
|
|
|
|||
|
|
@ -126,6 +126,7 @@ class ScriptDB(TypedObject):
|
|||
|
||||
class Meta(object):
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Script"
|
||||
|
||||
#
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ added to all game objects. You access it through the property
|
|||
"""
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.utils import create, logger
|
||||
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ ability to run timers.
|
|||
"""
|
||||
|
||||
from django.utils.translation import gettext as _
|
||||
from twisted.internet.defer import Deferred, maybeDeferred
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
from evennia.scripts.manager import ScriptManager
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.typeclasses.models import TypeclassBase
|
||||
from evennia.utils import create, logger
|
||||
from twisted.internet.defer import Deferred, maybeDeferred
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
__all__ = ["DefaultScript", "DoNothing", "Store"]
|
||||
|
||||
|
|
|
|||
|
|
@ -5,13 +5,14 @@ Module containing the task handler for Evennia deferred tasks, persistent or not
|
|||
from datetime import datetime, timedelta
|
||||
from pickle import PickleError
|
||||
|
||||
from evennia.server.models import ServerConfig
|
||||
from evennia.utils.dbserialize import dbserialize, dbunserialize
|
||||
from evennia.utils.logger import log_err
|
||||
from twisted.internet import reactor
|
||||
from twisted.internet.defer import CancelledError as DefCancelledError
|
||||
from twisted.internet.task import deferLater
|
||||
|
||||
from evennia.server.models import ServerConfig
|
||||
from evennia.utils.dbserialize import dbserialize, dbunserialize
|
||||
from evennia.utils.logger import log_err
|
||||
|
||||
TASK_HANDLER = None
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ Unit tests for the scripts package
|
|||
from collections import defaultdict
|
||||
from unittest import TestCase, mock
|
||||
|
||||
from parameterized import parameterized
|
||||
|
||||
from evennia import DefaultScript
|
||||
from evennia.objects.objects import DefaultObject
|
||||
from evennia.scripts.manager import ScriptDBManager
|
||||
|
|
@ -17,7 +19,6 @@ from evennia.scripts.tickerhandler import TickerHandler
|
|||
from evennia.utils.create import create_script
|
||||
from evennia.utils.dbserialize import dbserialize
|
||||
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaTest
|
||||
from parameterized import parameterized
|
||||
|
||||
|
||||
class TestScript(BaseEvenniaTest):
|
||||
|
|
|
|||
|
|
@ -69,12 +69,13 @@ call the handler's `save()` and `restore()` methods when the server reboots.
|
|||
import inspect
|
||||
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
from evennia.scripts.scripts import ExtendedLoopingCall
|
||||
from evennia.server.models import ServerConfig
|
||||
from evennia.utils import inherits_from, variable_from_module
|
||||
from evennia.utils.dbserialize import dbserialize, dbunserialize, pack_dbobj
|
||||
from evennia.utils.logger import log_err, log_trace
|
||||
from twisted.internet.defer import inlineCallbacks
|
||||
|
||||
_GA = object.__getattribute__
|
||||
_SA = object.__setattr__
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import importlib
|
|||
from codecs import lookup as codecs_lookup
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.accounts.models import AccountDB
|
||||
from evennia.commands.cmdhandler import cmdhandler
|
||||
from evennia.utils.logger import log_err
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ class ServerConfig(WeakSharedMemoryModel):
|
|||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Server Config value"
|
||||
verbose_name_plural = "Server Config values"
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ active players and so on.
|
|||
"""
|
||||
|
||||
import weakref
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.utils import utils
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ URL_SUB = re.compile(r"\|lu(.*?)\|lt(.*?)\|le", re.DOTALL)
|
|||
# MXP Telnet option
|
||||
MXP = bytes([91]) # b"\x5b"
|
||||
|
||||
MXP_TEMPSECURE = "\x1B[4z"
|
||||
MXP_TEMPSECURE = "\x1b[4z"
|
||||
MXP_SEND = MXP_TEMPSECURE + '<SEND HREF="\\1">' + "\\2" + MXP_TEMPSECURE + "</SEND>"
|
||||
MXP_URL = MXP_TEMPSECURE + '<A HREF="\\1">' + "\\2" + MXP_TEMPSECURE + "</A>"
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ client and update it when the size changes
|
|||
|
||||
"""
|
||||
|
||||
from codecs import encode as codecs_encode
|
||||
import weakref
|
||||
from codecs import encode as codecs_encode
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
|
@ -86,4 +86,6 @@ class Naws:
|
|||
width = options[0] + options[1]
|
||||
self.protocol().protocol_flags["SCREENWIDTH"][0] = int(codecs_encode(width, "hex"), 16)
|
||||
height = options[2] + options[3]
|
||||
self.protocol().protocol_flags["SCREENHEIGHT"][0] = int(codecs_encode(height, "hex"), 16)
|
||||
self.protocol().protocol_flags["SCREENHEIGHT"][0] = int(
|
||||
codecs_encode(height, "hex"), 16
|
||||
)
|
||||
|
|
|
|||
|
|
@ -223,6 +223,7 @@ class EvenniaPortalService(MultiService):
|
|||
|
||||
class Websocket(WebSocketServerFactory):
|
||||
"Only here for better naming in logs"
|
||||
|
||||
pass
|
||||
|
||||
factory = Websocket()
|
||||
|
|
|
|||
|
|
@ -41,9 +41,9 @@ class SuppressGA:
|
|||
self.protocol = weakref.ref(protocol)
|
||||
|
||||
self.protocol().protocol_flags["NOGOAHEAD"] = True
|
||||
self.protocol().protocol_flags["NOPROMPTGOAHEAD"] = (
|
||||
True # Used to send a GA after a prompt line only, set in TTYPE (per client)
|
||||
)
|
||||
self.protocol().protocol_flags[
|
||||
"NOPROMPTGOAHEAD"
|
||||
] = True # Used to send a GA after a prompt line only, set in TTYPE (per client)
|
||||
# tell the client that we prefer to suppress GA ...
|
||||
self.protocol().will(SUPPRESS_GA).addCallbacks(self.will_suppress_ga, self.wont_suppress_ga)
|
||||
|
||||
|
|
|
|||
|
|
@ -8,19 +8,20 @@ import time
|
|||
import traceback
|
||||
|
||||
import django
|
||||
import evennia
|
||||
from django.conf import settings
|
||||
from django.db import connection
|
||||
from django.db.utils import OperationalError
|
||||
from django.utils.translation import gettext as _
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.utils import get_evennia_version, make_iter, mod_import
|
||||
from twisted.application import internet
|
||||
from twisted.application.service import MultiService
|
||||
from twisted.internet import defer, reactor
|
||||
from twisted.internet.defer import Deferred
|
||||
from twisted.internet.task import LoopingCall
|
||||
|
||||
import evennia
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.utils import get_evennia_version, make_iter, mod_import
|
||||
|
||||
_SA = object.__setattr__
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ from copy import copy
|
|||
from django.conf import settings
|
||||
from django.db import models
|
||||
from django.utils.encoding import smart_str
|
||||
|
||||
from evennia.locks.lockhandler import LockHandler
|
||||
from evennia.utils.dbserialize import from_pickle, to_pickle
|
||||
from evennia.utils.idmapper.models import SharedMemoryModel
|
||||
|
|
@ -62,7 +63,7 @@ class IAttribute:
|
|||
return LockHandler(self)
|
||||
|
||||
key = property(lambda self: self.db_key)
|
||||
strvalue = property(lambda self: getattr(self, 'db_strvalue', None))
|
||||
strvalue = property(lambda self: getattr(self, "db_strvalue", None))
|
||||
category = property(lambda self: self.db_category)
|
||||
model = property(lambda self: self.db_model)
|
||||
attrtype = property(lambda self: self.db_attrtype)
|
||||
|
|
@ -411,6 +412,7 @@ class Attribute(IAttribute, SharedMemoryModel):
|
|||
|
||||
class Meta:
|
||||
"Define Django meta options"
|
||||
|
||||
verbose_name = "Attribute"
|
||||
|
||||
# Wrapper properties to easily set database fields. These are
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from collections import defaultdict
|
|||
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
from evennia.locks.lockfuncs import perm as perm_lockfunc
|
||||
from evennia.utils.utils import make_iter, to_str
|
||||
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ import re
|
|||
from collections import OrderedDict
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
from evennia.utils import logger, utils
|
||||
from evennia.utils.hex_colors import HexColors
|
||||
from evennia.utils.utils import to_str
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ from pickle import dumps
|
|||
|
||||
from django.conf import settings
|
||||
from django.db.utils import OperationalError, ProgrammingError
|
||||
|
||||
from evennia.scripts.models import ScriptDB
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.utils import callables_from_module, class_from_module
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ try:
|
|||
except ImportError:
|
||||
from pickle import dumps, loads
|
||||
|
||||
from enum import IntFlag
|
||||
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.core.exceptions import ObjectDoesNotExist
|
||||
from django.utils.safestring import SafeString
|
||||
|
|
@ -35,7 +37,6 @@ from django.utils.safestring import SafeString
|
|||
import evennia
|
||||
from evennia.utils import logger
|
||||
from evennia.utils.utils import is_iter, to_bytes, uses_database
|
||||
from enum import IntFlag
|
||||
|
||||
__all__ = ("to_pickle", "from_pickle", "do_pickle", "do_unpickle", "dbserialize", "dbunserialize")
|
||||
|
||||
|
|
|
|||
|
|
@ -1421,14 +1421,20 @@ def list_node(option_generator, select=None, pagesize=10):
|
|||
options.append(
|
||||
{
|
||||
"key": (_("|wp|Wrevious page|n"), "p"),
|
||||
"goto": (lambda caller: None, kwargs | {"optionpage_index": page_index - 1}),
|
||||
"goto": (
|
||||
lambda caller: None,
|
||||
kwargs | {"optionpage_index": page_index - 1},
|
||||
),
|
||||
}
|
||||
)
|
||||
if page_index < npages - 1:
|
||||
options.append(
|
||||
{
|
||||
"key": (_("|wn|Wext page|n"), "n"),
|
||||
"goto": (lambda caller: None, kwargs | {"optionpage_index": page_index + 1}),
|
||||
"goto": (
|
||||
lambda caller: None,
|
||||
kwargs | {"optionpage_index": page_index + 1},
|
||||
),
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ class CmdMore(Command):
|
|||
Implement the command
|
||||
"""
|
||||
more = self.caller.ndb._more
|
||||
if not more and hasattr(self.caller, 'account') and self.caller.account:
|
||||
if not more and hasattr(self.caller, "account") and self.caller.account:
|
||||
more = self.caller.account.ndb._more
|
||||
if not more:
|
||||
self.caller.msg("Error in loading the pager. Contact an admin.")
|
||||
|
|
@ -113,7 +113,7 @@ class CmdMoreExit(Command):
|
|||
Exit pager and re-fire the failed command.
|
||||
"""
|
||||
more = self.caller.ndb._more
|
||||
if not more and hasattr(self.caller, 'account') and self.caller.account:
|
||||
if not more and hasattr(self.caller, "account") and self.caller.account:
|
||||
more = self.caller.account.ndb._more
|
||||
if not more:
|
||||
self.caller.msg("Error in exiting the pager. Contact an admin.")
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ total runtime of the server and the current uptime.
|
|||
"""
|
||||
|
||||
import time
|
||||
import evennia
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from django.conf import settings
|
||||
from django.db.utils import OperationalError
|
||||
|
||||
import evennia
|
||||
from evennia.scripts.scripts import DefaultScript
|
||||
from evennia.server.models import ServerConfig
|
||||
from evennia.utils.create import create_script
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for batchprocessors """
|
||||
"""Tests for batchprocessors"""
|
||||
|
||||
import codecs
|
||||
import textwrap
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@ Tests for dbserialize module
|
|||
"""
|
||||
|
||||
from collections import defaultdict, deque
|
||||
from enum import IntFlag, auto
|
||||
|
||||
from django.test import TestCase
|
||||
from parameterized import parameterized
|
||||
|
||||
from evennia.objects.objects import DefaultObject
|
||||
from evennia.utils import dbserialize
|
||||
from enum import IntFlag, auto
|
||||
|
||||
|
||||
class TestDbSerialize(TestCase):
|
||||
|
|
@ -24,6 +24,7 @@ class TestDbSerialize(TestCase):
|
|||
def test_intflag(self):
|
||||
class TestFlag(IntFlag):
|
||||
foo = auto()
|
||||
|
||||
self.obj.db.test = TestFlag.foo
|
||||
self.assertEqual(self.obj.db.test, TestFlag.foo)
|
||||
self.obj.save()
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ from evennia.utils.test_resources import BaseEvenniaTest
|
|||
|
||||
class TestEvMenu(TestCase):
|
||||
"Run the EvMenu testing."
|
||||
|
||||
menutree = {} # can also be the path to the menu tree
|
||||
startnode = "start"
|
||||
cmdset_mergetype = "Replace"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for text2html """
|
||||
"""Tests for text2html"""
|
||||
|
||||
import unittest
|
||||
|
||||
|
|
|
|||
|
|
@ -821,13 +821,13 @@ class TestAtSearchResult(TestCase):
|
|||
class MockObject:
|
||||
def __init__(self, key):
|
||||
self.key = key
|
||||
self.aliases = ''
|
||||
self.aliases = ""
|
||||
|
||||
def get_display_name(self, looker, **kwargs):
|
||||
return self.key
|
||||
|
||||
|
||||
def get_extra_info(self, looker, **kwargs):
|
||||
return ''
|
||||
return ""
|
||||
|
||||
def __repr__(self):
|
||||
return f"MockObject({self.key})"
|
||||
|
|
@ -846,7 +846,7 @@ class TestAtSearchResult(TestCase):
|
|||
|
||||
def test_basic_multimatch(self):
|
||||
"""multiple matches with the same name should return a message with incrementing indices"""
|
||||
matches = [ self.MockObject("obj1") for _ in range(3) ]
|
||||
matches = [self.MockObject("obj1") for _ in range(3)]
|
||||
caller = mock.MagicMock()
|
||||
self.assertIsNone(utils.at_search_result(matches, caller, "obj1"))
|
||||
multimatch_msg = """\
|
||||
|
|
@ -858,7 +858,9 @@ More than one match for 'obj1' (please narrow target):
|
|||
|
||||
def test_partial_multimatch(self):
|
||||
"""multiple partial matches with different names should increment index by unique name"""
|
||||
matches = [ self.MockObject("obj1") for _ in range(3) ] + [ self.MockObject("obj2") for _ in range(2) ]
|
||||
matches = [self.MockObject("obj1") for _ in range(3)] + [
|
||||
self.MockObject("obj2") for _ in range(2)
|
||||
]
|
||||
caller = mock.MagicMock()
|
||||
self.assertIsNone(utils.at_search_result(matches, caller, "obj"))
|
||||
multimatch_msg = """\
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
"""Tests for validatorfuncs """
|
||||
"""Tests for validatorfuncs"""
|
||||
|
||||
import datetime
|
||||
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ def compress_whitespace(text, max_linebreaks=1, max_spacing=2):
|
|||
# this allows the blank-line compression to eliminate them if needed
|
||||
text = re_empty.sub("\n\n", text)
|
||||
# replace groups of extra spaces with the maximum number of spaces
|
||||
text = re.sub(fr"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text)
|
||||
text = re.sub(rf"(?<=\S) {{{max_spacing},}}", " " * max_spacing, text)
|
||||
# replace groups of extra newlines with the maximum number of newlines
|
||||
text = re.sub(f"\n{{{max_linebreaks},}}", "\n" * max_linebreaks, text)
|
||||
return text
|
||||
|
|
@ -2401,10 +2401,8 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
|||
grouped_matches = defaultdict(list)
|
||||
for item in matches:
|
||||
group_key = (
|
||||
item.get_display_name(caller)
|
||||
if hasattr(item, "get_display_name")
|
||||
else query
|
||||
)
|
||||
item.get_display_name(caller) if hasattr(item, "get_display_name") else query
|
||||
)
|
||||
grouped_matches[group_key].append(item)
|
||||
|
||||
for key, match_list in grouped_matches.items():
|
||||
|
|
@ -2415,7 +2413,9 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
|||
# result is a typeclassed entity where `.aliases` is an AliasHandler.
|
||||
aliases = result.aliases.all(return_objs=True)
|
||||
# remove pluralization aliases
|
||||
aliases = [alias.db_key for alias in aliases if alias.db_category != "plural_key"]
|
||||
aliases = [
|
||||
alias.db_key for alias in aliases if alias.db_category != "plural_key"
|
||||
]
|
||||
else:
|
||||
# result is likely a Command, where `.aliases` is a list of strings.
|
||||
aliases = result.aliases
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class HelpEntryForm(forms.ModelForm):
|
|||
@admin.register(HelpEntry)
|
||||
class HelpEntryAdmin(admin.ModelAdmin):
|
||||
"Sets up the admin manaager for help entries"
|
||||
|
||||
inlines = [HelpTagInline]
|
||||
list_display = ("id", "db_key", "db_help_category", "db_lock_storage", "db_date_created")
|
||||
list_display_links = ("id", "db_key")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue