Remove many uses of the short api from inside the library, to ease startup loops

This commit is contained in:
Griatch 2025-03-02 17:46:17 +01:00
parent 53b7ee8a90
commit 6117e85ac9
11 changed files with 26 additions and 43 deletions

View file

@ -16,14 +16,13 @@ import time
import typing import typing
from random import getrandbits from random import getrandbits
import evennia
from django.conf import settings from django.conf import settings
from django.contrib.auth import authenticate, password_validation from django.contrib.auth import authenticate, password_validation
from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.utils import timezone from django.utils import timezone
from django.utils.module_loading import import_string from django.utils.module_loading import import_string
from django.utils.translation import gettext as _ from django.utils.translation import gettext as _
import evennia
from evennia.accounts.manager import AccountManager from evennia.accounts.manager import AccountManager
from evennia.accounts.models import AccountDB from evennia.accounts.models import AccountDB
from evennia.commands.cmdsethandler import CmdSetHandler from evennia.commands.cmdsethandler import CmdSetHandler
@ -42,13 +41,7 @@ from evennia.typeclasses.attributes import ModelAttributeBackend, NickHandler
from evennia.typeclasses.models import TypeclassBase from evennia.typeclasses.models import TypeclassBase
from evennia.utils import class_from_module, create, logger from evennia.utils import class_from_module, create, logger
from evennia.utils.optionhandler import OptionHandler from evennia.utils.optionhandler import OptionHandler
from evennia.utils.utils import ( from evennia.utils.utils import is_iter, lazy_property, make_iter, to_str, variable_from_module
is_iter,
lazy_property,
make_iter,
to_str,
variable_from_module,
)
__all__ = ("DefaultAccount", "DefaultGuest") __all__ = ("DefaultAccount", "DefaultGuest")

View file

@ -5,8 +5,7 @@ General Character commands usually available to all characters
import re import re
from django.conf import settings from django.conf import settings
from evennia.objects.objects import DefaultObject
import evennia
from evennia.typeclasses.attributes import NickTemplateInvalid from evennia.typeclasses.attributes import NickTemplateInvalid
from evennia.utils import utils from evennia.utils import utils
@ -143,7 +142,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
def parse(self): def parse(self):
""" """
Support escaping of = with \= Support escaping of = with \\=
""" """
super().parse() super().parse()
args = (self.lhs or "") + (" = %s" % self.rhs if self.rhs else "") args = (self.lhs or "") + (" = %s" % self.rhs if self.rhs else "")
@ -153,7 +152,7 @@ class CmdNick(COMMAND_DEFAULT_CLASS):
self.lhs = parts[0].strip() self.lhs = parts[0].strip()
else: else:
self.lhs, self.rhs = [part.strip() for part in parts] self.lhs, self.rhs = [part.strip() for part in parts]
self.lhs = self.lhs.replace("\=", "=") self.lhs = self.lhs.replace("\\=", "=")
def func(self): def func(self):
"""Create the nickname""" """Create the nickname"""
@ -799,6 +798,6 @@ class CmdAccess(COMMAND_DEFAULT_CLASS):
string += "\n|wYour access|n:" string += "\n|wYour access|n:"
string += f"\nCharacter |c{caller.key}|n: {cperms}" string += f"\nCharacter |c{caller.key}|n: {cperms}"
if utils.inherits_from(caller, evennia.DefaultObject): if utils.inherits_from(caller, DefaultObject):
string += f"\nAccount |c{caller.account.key}|n: {pperms}" string += f"\nAccount |c{caller.account.key}|n: {pperms}"
caller.msg(string) caller.msg(string)

View file

@ -957,7 +957,7 @@ class CmdTickers(COMMAND_DEFAULT_CLASS):
locks = "cmd:perm(tickers) or perm(Builder)" locks = "cmd:perm(tickers) or perm(Builder)"
def func(self): def func(self):
from evennia import TICKER_HANDLER from evennia.scripts.tickerhandler import TICKER_HANDLER
all_subs = TICKER_HANDLER.all_display() all_subs = TICKER_HANDLER.all_display()
if not all_subs: if not all_subs:

View file

@ -18,14 +18,10 @@ import evennia
from anything import Anything from anything import Anything
from django.conf import settings from django.conf import settings
from django.test import override_settings from django.test import override_settings
from evennia import (
DefaultCharacter, from evennia.objects.objects import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
DefaultExit, from evennia.objects.models import ObjectDB
DefaultObject, from evennia.utils.search import search_object
DefaultRoom,
ObjectDB,
search_object,
)
from evennia.commands import cmdparser from evennia.commands import cmdparser
from evennia.commands.cmdset import CmdSet from evennia.commands.cmdset import CmdSet
from evennia.commands.command import Command, InterruptCommand from evennia.commands.command import Command, InterruptCommand
@ -37,7 +33,6 @@ from evennia.commands.default.muxcommand import MuxCommand
from evennia.prototypes import prototypes as protlib from evennia.prototypes import prototypes as protlib
from evennia.utils import create, gametime, utils from evennia.utils import create, gametime, utils
from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa from evennia.utils.test_resources import BaseEvenniaCommandTest # noqa
from evennia.utils.test_resources import BaseEvenniaTest, EvenniaCommandTest
from parameterized import parameterized from parameterized import parameterized
from twisted.internet import task from twisted.internet import task

View file

@ -9,7 +9,7 @@ from django.contrib.contenttypes.models import ContentType
from django.urls import reverse from django.urls import reverse
from django.utils.text import slugify from django.utils.text import slugify
import evennia from evennia.objects.objects import DefaultObject
from evennia.comms.managers import ChannelManager from evennia.comms.managers import ChannelManager
from evennia.comms.models import ChannelDB from evennia.comms.models import ChannelDB
from evennia.typeclasses.models import TypeclassBase from evennia.typeclasses.models import TypeclassBase
@ -231,7 +231,7 @@ class DefaultChannel(ChannelDB, metaclass=TypeclassBase):
""" """
has_sub = self.subscriptions.has(subscriber) has_sub = self.subscriptions.has(subscriber)
if not has_sub and inherits_from(subscriber, evennia.DefaultObject): if not has_sub and inherits_from(subscriber, DefaultObject):
# it's common to send an Object when we # it's common to send an Object when we
# by default only allow Accounts to subscribe. # by default only allow Accounts to subscribe.
has_sub = self.subscriptions.has(subscriber.account) has_sub = self.subscriptions.has(subscriber.account)

View file

@ -1,6 +1,6 @@
from django.test import SimpleTestCase from django.test import SimpleTestCase
from evennia import DefaultChannel from evennia.comms.comms import DefaultChannel
from evennia.commands.default.comms import CmdChannel from evennia.commands.default.comms import CmdChannel
from evennia.utils.create import create_message from evennia.utils.create import create_message
from evennia.utils.test_resources import BaseEvenniaTest from evennia.utils.test_resources import BaseEvenniaTest

View file

@ -7,14 +7,14 @@ default ones in evennia core.
""" """
from evennia import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom, ScriptDB 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.callbackhandler import CallbackHandler
from evennia.contrib.base_systems.ingame_python.utils import ( from evennia.contrib.base_systems.ingame_python.utils import (
phrase_event, phrase_event,
register_events, register_events,
time_event, time_event,
) )
from evennia.utils.utils import delay, inherits_from, lazy_property from evennia.utils.utils import inherits_from, lazy_property
# Character help # Character help
CHARACTER_CAN_DELETE = """ CHARACTER_CAN_DELETE = """

View file

@ -7,7 +7,8 @@ These functions are to be used by developers to customize events and callbacks.
from django.conf import settings from django.conf import settings
from evennia import ScriptDB, logger 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 ( from evennia.contrib.base_systems.custom_gametime import (
real_seconds_until as custom_rsu, real_seconds_until as custom_rsu,

View file

@ -29,16 +29,11 @@ Admin/development commands
import re import re
import evennia
from django.conf import settings from django.conf import settings
from evennia import default_cmds, syscmdkeys
from evennia import ( from evennia.commands.cmdset import CmdSet
SESSION_HANDLER, from evennia.commands.command import Command, InterruptCommand
CmdSet,
Command,
InterruptCommand,
default_cmds,
syscmdkeys,
)
from evennia.utils import variable_from_module from evennia.utils import variable_from_module
from .utils import create_evscaperoom_object from .utils import create_evscaperoom_object
@ -300,7 +295,7 @@ class CmdWho(CmdEvscapeRoom, default_cmds.CmdWho):
if self.args == "all": if self.args == "all":
table = self.style_table("|wName", "|wRoom") table = self.style_table("|wName", "|wRoom")
sessions = SESSION_HANDLER.get_sessions() sessions = evennia.SESSION_HANDLER.get_sessions()
for session in sessions: for session in sessions:
puppet = session.get_puppet() puppet = session.get_puppet()
if puppet: if puppet:

View file

@ -1,6 +1,6 @@
from unittest import skip from unittest import skip
from evennia import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom from evennia.objects.objects import DefaultCharacter, DefaultExit, DefaultObject, DefaultRoom
from evennia.objects.models import ObjectDB from evennia.objects.models import ObjectDB
from evennia.typeclasses.attributes import AttributeProperty from evennia.typeclasses.attributes import AttributeProperty
from evennia.typeclasses.tags import ( from evennia.typeclasses.tags import (

View file

@ -8,13 +8,13 @@ total runtime of the server and the current uptime.
""" """
import time import time
import evennia
from datetime import datetime, timedelta from datetime import datetime, timedelta
from django.conf import settings from django.conf import settings
from django.db.utils import OperationalError from django.db.utils import OperationalError
import evennia from evennia.scripts.scripts import DefaultScript
from evennia import DefaultScript
from evennia.server.models import ServerConfig from evennia.server.models import ServerConfig
from evennia.utils.create import create_script from evennia.utils.create import create_script