Skip to content

Commit

Permalink
Merge pull request #1 from evennia/master
Browse files Browse the repository at this point in the history
Updating before submitting PR.
  • Loading branch information
davewiththenicehat committed Sep 2, 2020
2 parents c3831ea + 4ba2f44 commit 094a100
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 22 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -70,6 +70,8 @@ without arguments starts a full interactive Python console.
- Make `INLINEFUNC_STACK_MAXSIZE` default visible in `settings_default.py`.
- 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.
- Make `cmd.at_post_cmd()` always run after `cmd.func()`, even when the latter uses delays
with yield.


## Evennia 0.9 (2018-2019)
Expand Down
2 changes: 1 addition & 1 deletion evennia/accounts/accounts.py
Expand Up @@ -1262,7 +1262,7 @@ def _send_to_connect_channel(self, message):
]
except Exception:
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)
if _MUDINFO_CHANNEL:
_MUDINFO_CHANNEL.tempmsg(f"[{_MUDINFO_CHANNEL.key}, {now}]: {message}")
Expand Down
31 changes: 21 additions & 10 deletions evennia/commands/cmdhandler.py
Expand Up @@ -206,7 +206,7 @@ def _progressive_cmd_run(cmd, generator, response=None):
else:
value = generator.send(response)
except StopIteration:
pass
raise
else:
if isinstance(value, (int, float)):
utils.delay(value, _progressive_cmd_run, cmd, generator)
Expand Down Expand Up @@ -631,20 +631,31 @@ def _run_command(cmd, cmdname, args, raw_cmdname, cmdset, session, account):
ret = cmd.func()
if isinstance(ret, types.GeneratorType):
# 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
else:
in_generator = False
ret = yield ret

# post-command hook
yield cmd.at_post_cmd()
if not in_generator:
# 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:
# store a reference to this command, possibly
# accessible by the next command.
caller.ndb.last_cmd = yield copy(cmd)
else:
caller.ndb.last_cmd = None
# post-command hook
yield cmd.at_post_cmd()

if cmd.save_for_next:
# store a reference to this command, possibly
# accessible by the next command.
caller.ndb.last_cmd = yield copy(cmd)
else:
caller.ndb.last_cmd = None

# return result to the deferred
returnValue(ret)
Expand Down
2 changes: 1 addition & 1 deletion evennia/commands/default/tests.py
Expand Up @@ -1146,7 +1146,7 @@ def test_script(self):
"= Obj",
"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(
building.CmdScript(), "/start Obj", "0 scripts started on Obj"
Expand Down
13 changes: 7 additions & 6 deletions evennia/objects/objects.py
Expand Up @@ -339,22 +339,23 @@ def get_numbered_name(self, count, looker, **kwargs):
singular (str): The singular form to display.
plural (str): The determined plural form of the key, including the count.
"""
plural_category = "plural_key"
key = kwargs.get("key", self.key)
key = ansi.ANSIString(key) # this is needed to allow inflection of colored names
try:
plural = _INFLECT.plural(key, 2)
plural = "%s %s" % (_INFLECT.number_to_words(count, threshold=12), plural)
plural = _INFLECT.plural(key, count)
plural = "{} {}".format(_INFLECT.number_to_words(count, threshold=12), plural)
except IndexError:
# this is raised by inflect if the input is not a proper noun
plural = 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
self.aliases.clear(category="plural_key")
self.aliases.add(plural, category="plural_key")
self.aliases.clear(category=plural_category)
self.aliases.add(plural, category=plural_category)
# save the singular form as an alias here too so we can display "an egg" and also
# look at 'an egg'.
self.aliases.add(singular, category="plural_key")
self.aliases.add(singular, category=plural_category)
return singular, plural

def search(
Expand Down
4 changes: 2 additions & 2 deletions evennia/server/evennia_launcher.py
Expand Up @@ -1368,10 +1368,10 @@ def create_settings_file(init=True, secret_settings=False):
if not init:
# if not --init mode, settings file may already exist from before
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":
print("Aborted.")
return
sys.exit()
else:
print("Reset the settings file.")

Expand Down
2 changes: 1 addition & 1 deletion evennia/typeclasses/attributes.py
Expand Up @@ -186,7 +186,7 @@ def __str__(self):
def __repr__(self):
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.
Expand Down
2 changes: 1 addition & 1 deletion evennia/utils/tests/test_create_functions.py
Expand Up @@ -159,7 +159,7 @@ def test_create_msg__custom(self):
locks=locks,
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.assertEqual(msg.tags.all(), tags)

Expand Down
4 changes: 4 additions & 0 deletions evennia/utils/utils.py
Expand Up @@ -1917,6 +1917,10 @@ def at_search_result(matches, caller, query="", quiet=False, **kwargs):
for num, result in enumerate(matches):
# we need to consider Commands, where .aliases is a list
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(
number=num + 1,
name=result.get_display_name(caller)
Expand Down

0 comments on commit 094a100

Please sign in to comment.