Finalize nick-templating; still issues with other places using nicks, such as channels.

This commit is contained in:
Griatch 2016-06-26 00:41:57 +02:00
parent b1de659e8b
commit fba6e079c1
4 changed files with 9 additions and 9 deletions

View file

@ -100,9 +100,9 @@ class TestGeneral(CommandTest):
self.call(general.CmdPose(), "looks around", "Char looks around")
def test_nick(self):
self.call(general.CmdNick(), "testalias = testaliasedstring1", "Nick set:")
self.call(general.CmdNick(), "/player testalias = testaliasedstring2", "Nick set:")
self.call(general.CmdNick(), "/object testalias = testaliasedstring3", "Nick set:")
self.call(general.CmdNick(), "testalias = testaliasedstring1", "Nick 'testalias' mapped to 'testaliasedstring1'.")
self.call(general.CmdNick(), "/player testalias = testaliasedstring2", "Nick 'testalias' mapped to 'testaliasedstring2'.")
self.call(general.CmdNick(), "/object testalias = testaliasedstring3", "Nick 'testalias' mapped to 'testaliasedstring3'.")
self.assertEqual(u"testaliasedstring1", self.char1.nicks.get("testalias"))
self.assertEqual(u"testaliasedstring2", self.char1.nicks.get("testalias", category="player"))
self.assertEqual(u"testaliasedstring3", self.char1.nicks.get("testalias", category="object"))

View file

@ -393,6 +393,7 @@ class ChannelDBManager(TypedObjectManager):
case sensitive) match.
"""
print("channel_search", ostring)
channels = []
if not ostring: return channels
try:

View file

@ -63,7 +63,7 @@ def text(session, *args, **kwargs):
return
# this is treated as a command input
# handle the 'idle' command
if text.strip() in _IDLE_COMMAND:
if text.strip() == _IDLE_COMMAND:
session.update_session_counters(idle=True)
return
if session.player:

View file

@ -596,6 +596,8 @@ def initialize_nick_templates(in_template, out_template):
# create the regex for in_template
regex_string = fnmatch.translate(in_template)
# we must account for a possible line break coming over the wire
regex_string = regex_string[:-7] + r"(?:[\n\r]*?)\Z(?ms)"
# validate the templates
regex_args = [match.group(2) for match in _RE_NICK_ARG.finditer(regex_string)]
@ -733,16 +735,13 @@ class NickHandler(AttributeHandler):
for nick in make_iter(self.obj.player.nicks.get(category=category, return_obj=True))
if nick and nick.key})
for key, nick in nicks.iteritems():
print "iterting over nicks:", key
nick_regex, template, _, _ = nick.value
regex = self._regex_cache.get(nick_regex)
if not regex:
regex = re.compile(nick_regex, re.I + re.DOTALL)
regex = re.compile(nick_regex, re.I + re.DOTALL + re.U)
self._regex_cache[nick_regex] = regex
print "before parse_nick_template:", nick.value
is_match, raw_string = parse_nick_template(raw_string, regex, template)
print "is_match:", is_match, raw_string
is_match, raw_string = parse_nick_template(raw_string.strip(), regex, template)
if is_match:
break
return raw_string