Fix :UU and :UU usage in EvEditor. Resolve #3262

This commit is contained in:
Griatch 2024-04-01 14:05:45 +02:00
parent 0c072dab02
commit 763699ea14
5 changed files with 84 additions and 82 deletions

View file

@ -36,14 +36,13 @@ 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

@ -11,7 +11,6 @@ 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
@ -20,6 +19,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."""
@ -487,31 +487,29 @@ class Command(metaclass=CommandMeta):
purposes when making commands.
"""
variables = "\n".join(
" |w{}|n ({}): {}".format(key, type(val), val) for key, val in self.__dict__.items()
)
string = f"""
Command {self} has no defined `func()` - showing on-command variables:
{variables}
"""
# a simple test command to show the available properties
string += "-" * 50
string += "\n|w%s|n - Command variables from evennia:\n" % self.key
string += "-" * 50
string += "\nname of cmd (self.key): |w%s|n\n" % self.key
string += "cmd aliases (self.aliases): |w%s|n\n" % self.aliases
string += "cmd locks (self.locks): |w%s|n\n" % self.locks
string += "help category (self.help_category): |w%s|n\n" % self.help_category.capitalize()
string += "object calling (self.caller): |w%s|n\n" % self.caller
string += "object storing cmdset (self.obj): |w%s|n\n" % self.obj
string += "command string given (self.cmdstring): |w%s|n\n" % self.cmdstring
# show cmdset.key instead of cmdset to shorten output
string += fill(
"current cmdset (self.cmdset): |w%s|n\n"
% (self.cmdset.key if self.cmdset.key else self.cmdset.__class__)
)
output_string = """
Command \"{cmdname}\" has no defined `func()` method. Available properties on this command are:
self.msg(string)
{variables}"""
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))
]
output = output_string.format(cmdname=self.key, variables="\n ".join(variables))
self.msg(output)
def func(self):
"""