Merge pull request #1 from evennia/master
Updating before submitting PR.
This commit is contained in:
commit
2818b90f89
9 changed files with 40 additions and 22 deletions
|
|
@ -70,6 +70,8 @@ without arguments starts a full interactive Python console.
|
||||||
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
|
||||||
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
- Change how `ic` finds puppets; non-priveleged users will use `_playable_characters` list as
|
||||||
candidates, Builders+ will use list, local search and only global search if no match found.
|
candidates, Builders+ will use list, local search and only global search if no match found.
|
||||||
|
- Make `cmd.at_post_cmd()` always run after `cmd.func()`, even when the latter uses delays
|
||||||
|
with yield.
|
||||||
|
|
||||||
|
|
||||||
## Evennia 0.9 (2018-2019)
|
## Evennia 0.9 (2018-2019)
|
||||||
|
|
|
||||||
|
|
@ -1262,7 +1262,7 @@ class DefaultAccount(AccountDB, metaclass=TypeclassBase):
|
||||||
]
|
]
|
||||||
except Exception:
|
except Exception:
|
||||||
logger.log_trace()
|
logger.log_trace()
|
||||||
now = timezone.now()
|
now = timezone.localtime()
|
||||||
now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month, now.day, now.hour, now.minute)
|
now = "%02i-%02i-%02i(%02i:%02i)" % (now.year, now.month, now.day, now.hour, now.minute)
|
||||||
if _MUDINFO_CHANNEL:
|
if _MUDINFO_CHANNEL:
|
||||||
_MUDINFO_CHANNEL.tempmsg(f"[{_MUDINFO_CHANNEL.key}, {now}]: {message}")
|
_MUDINFO_CHANNEL.tempmsg(f"[{_MUDINFO_CHANNEL.key}, {now}]: {message}")
|
||||||
|
|
|
||||||
|
|
@ -206,7 +206,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
|
||||||
else:
|
else:
|
||||||
value = generator.send(response)
|
value = generator.send(response)
|
||||||
except StopIteration:
|
except StopIteration:
|
||||||
pass
|
raise
|
||||||
else:
|
else:
|
||||||
if isinstance(value, (int, float)):
|
if isinstance(value, (int, float)):
|
||||||
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
utils.delay(value, _progressive_cmd_run, cmd, generator)
|
||||||
|
|
@ -631,20 +631,31 @@ def cmdhandler(
|
||||||
ret = cmd.func()
|
ret = cmd.func()
|
||||||
if isinstance(ret, types.GeneratorType):
|
if isinstance(ret, types.GeneratorType):
|
||||||
# cmd.func() is a generator, execute progressively
|
# cmd.func() is a generator, execute progressively
|
||||||
_progressive_cmd_run(cmd, ret)
|
in_generator = True
|
||||||
|
try:
|
||||||
|
_progressive_cmd_run(cmd, ret)
|
||||||
|
except StopIteration:
|
||||||
|
# this means func() has run its course
|
||||||
|
in_generator = False
|
||||||
yield None
|
yield None
|
||||||
else:
|
else:
|
||||||
|
in_generator = False
|
||||||
ret = yield ret
|
ret = yield ret
|
||||||
|
|
||||||
# post-command hook
|
if not in_generator:
|
||||||
yield cmd.at_post_cmd()
|
# this will only run if we are out of the generator for this
|
||||||
|
# cmd, otherwise we would have at_post_cmd run before a delayed
|
||||||
|
# func() finished
|
||||||
|
|
||||||
if cmd.save_for_next:
|
# post-command hook
|
||||||
# store a reference to this command, possibly
|
yield cmd.at_post_cmd()
|
||||||
# accessible by the next command.
|
|
||||||
caller.ndb.last_cmd = yield copy(cmd)
|
if cmd.save_for_next:
|
||||||
else:
|
# store a reference to this command, possibly
|
||||||
caller.ndb.last_cmd = None
|
# accessible by the next command.
|
||||||
|
caller.ndb.last_cmd = yield copy(cmd)
|
||||||
|
else:
|
||||||
|
caller.ndb.last_cmd = None
|
||||||
|
|
||||||
# return result to the deferred
|
# return result to the deferred
|
||||||
returnValue(ret)
|
returnValue(ret)
|
||||||
|
|
|
||||||
|
|
@ -1146,7 +1146,7 @@ class TestBuilding(CommandTest):
|
||||||
"= Obj",
|
"= Obj",
|
||||||
"To create a global script you need scripts/add <typeclass>.",
|
"To create a global script you need scripts/add <typeclass>.",
|
||||||
)
|
)
|
||||||
self.call(building.CmdScript(), "Obj = ", "dbref obj")
|
self.call(building.CmdScript(), "Obj ", "dbref ")
|
||||||
|
|
||||||
self.call(
|
self.call(
|
||||||
building.CmdScript(), "/start Obj", "0 scripts started on Obj"
|
building.CmdScript(), "/start Obj", "0 scripts started on Obj"
|
||||||
|
|
|
||||||
|
|
@ -339,22 +339,23 @@ class DefaultObject(ObjectDB, metaclass=TypeclassBase):
|
||||||
singular (str): The singular form to display.
|
singular (str): The singular form to display.
|
||||||
plural (str): The determined plural form of the key, including the count.
|
plural (str): The determined plural form of the key, including the count.
|
||||||
"""
|
"""
|
||||||
|
plural_category = "plural_key"
|
||||||
key = kwargs.get("key", self.key)
|
key = kwargs.get("key", self.key)
|
||||||
key = ansi.ANSIString(key) # this is needed to allow inflection of colored names
|
key = ansi.ANSIString(key) # this is needed to allow inflection of colored names
|
||||||
try:
|
try:
|
||||||
plural = _INFLECT.plural(key, 2)
|
plural = _INFLECT.plural(key, count)
|
||||||
plural = "%s %s" % (_INFLECT.number_to_words(count, threshold=12), plural)
|
plural = "{} {}".format(_INFLECT.number_to_words(count, threshold=12), plural)
|
||||||
except IndexError:
|
except IndexError:
|
||||||
# this is raised by inflect if the input is not a proper noun
|
# this is raised by inflect if the input is not a proper noun
|
||||||
plural = key
|
plural = key
|
||||||
singular = _INFLECT.an(key)
|
singular = _INFLECT.an(key)
|
||||||
if not self.aliases.get(plural, category="plural_key"):
|
if not self.aliases.get(plural, category=plural_category):
|
||||||
# we need to wipe any old plurals/an/a in case key changed in the interrim
|
# we need to wipe any old plurals/an/a in case key changed in the interrim
|
||||||
self.aliases.clear(category="plural_key")
|
self.aliases.clear(category=plural_category)
|
||||||
self.aliases.add(plural, category="plural_key")
|
self.aliases.add(plural, category=plural_category)
|
||||||
# save the singular form as an alias here too so we can display "an egg" and also
|
# save the singular form as an alias here too so we can display "an egg" and also
|
||||||
# look at 'an egg'.
|
# look at 'an egg'.
|
||||||
self.aliases.add(singular, category="plural_key")
|
self.aliases.add(singular, category=plural_category)
|
||||||
return singular, plural
|
return singular, plural
|
||||||
|
|
||||||
def search(
|
def search(
|
||||||
|
|
|
||||||
|
|
@ -1368,10 +1368,10 @@ def create_settings_file(init=True, secret_settings=False):
|
||||||
if not init:
|
if not init:
|
||||||
# if not --init mode, settings file may already exist from before
|
# if not --init mode, settings file may already exist from before
|
||||||
if os.path.exists(settings_path):
|
if os.path.exists(settings_path):
|
||||||
inp = eval(input("%s already exists. Do you want to reset it? y/[N]> " % settings_path))
|
inp = input("%s already exists. Do you want to reset it? y/[N]> " % settings_path)
|
||||||
if not inp.lower() == "y":
|
if not inp.lower() == "y":
|
||||||
print("Aborted.")
|
print("Aborted.")
|
||||||
return
|
sys.exit()
|
||||||
else:
|
else:
|
||||||
print("Reset the settings file.")
|
print("Reset the settings file.")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,7 +186,7 @@ class Attribute(SharedMemoryModel):
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "%s(%s)" % (self.db_key, self.id)
|
return "%s(%s)" % (self.db_key, self.id)
|
||||||
|
|
||||||
def access(self, accessing_obj, access_type="read", default=False, **kwargs):
|
def access(self, accessing_obj, access_type="attrread", default=False, **kwargs):
|
||||||
"""
|
"""
|
||||||
Determines if another object has permission to access.
|
Determines if another object has permission to access.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ class TestCreateMessage(EvenniaTest):
|
||||||
locks=locks,
|
locks=locks,
|
||||||
tags=tags,
|
tags=tags,
|
||||||
)
|
)
|
||||||
self.assertEqual(msg.receivers, [self.char1, self.char2])
|
self.assertEqual(set(msg.receivers), set([self.char1, self.char2]))
|
||||||
self.assertTrue(all(lock in msg.locks.all() for lock in locks.split(";")))
|
self.assertTrue(all(lock in msg.locks.all() for lock in locks.split(";")))
|
||||||
self.assertEqual(msg.tags.all(), tags)
|
self.assertEqual(msg.tags.all(), tags)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1917,6 +1917,10 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
|
||||||
for num, result in enumerate(matches):
|
for num, result in enumerate(matches):
|
||||||
# we need to consider Commands, where .aliases is a list
|
# we need to consider Commands, where .aliases is a list
|
||||||
aliases = result.aliases.all() if hasattr(result.aliases, "all") else result.aliases
|
aliases = result.aliases.all() if hasattr(result.aliases, "all") else result.aliases
|
||||||
|
# remove any pluralization aliases
|
||||||
|
aliases = [alias for alias in aliases if
|
||||||
|
hasattr(alias, "category")
|
||||||
|
and alias.category not in ("plural_key", )]
|
||||||
error += _MULTIMATCH_TEMPLATE.format(
|
error += _MULTIMATCH_TEMPLATE.format(
|
||||||
number=num + 1,
|
number=num + 1,
|
||||||
name=result.get_display_name(caller)
|
name=result.get_display_name(caller)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue