Adding more lenient checks of TTYPE to avoid a visible traceback. The error with TTYPE utf-8 tracebacks seems to be in an older version of tintin++, newer versions don't show this behaviour. Older versions of tintin++ will display one Huh? (with logged traceback) after which everything will work. This is reported in issue 219.

This commit is contained in:
Griatch 2012-03-21 19:56:04 +01:00
parent 6aac9e6c2b
commit 8ada50fcb7
3 changed files with 25 additions and 14 deletions

View file

@ -5,6 +5,8 @@ replacing cmdparser function. The replacement parser must
return a CommandCandidates object.
"""
from src.utils.logger import log_trace
def cmdparser(raw_string, cmdset, caller, match_index=None):
"""
This function is called by the cmdhandler once it has
@ -46,11 +48,15 @@ def cmdparser(raw_string, cmdset, caller, match_index=None):
# match everything that begins with a matching cmdname.
l_raw_string = raw_string.lower()
for cmd in cmdset:
matches.extend([create_match(cmdname, raw_string, cmd)
for cmdname in [cmd.key] + cmd.aliases
if cmdname and l_raw_string.startswith(cmdname.lower())
and (not cmd.arg_regex or
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
try:
matches.extend([create_match(cmdname, raw_string, cmd)
for cmdname in [cmd.key] + cmd.aliases
if cmdname and l_raw_string.startswith(cmdname.lower())
and (not cmd.arg_regex or
cmd.arg_regex.match(l_raw_string[len(cmdname):]))])
except Exception:
log_trace()
if not matches:
# no matches found.
if '-' in raw_string: