[grep] raise an IMException if pattern not found

This commit is contained in:
nemunaire 2016-01-12 16:49:51 +01:00
parent 1d18305870
commit 9ff8a3a02b

View File

@ -76,8 +76,13 @@ def cmd_grep(msg):
only = "only" in msg.kwargs
return [m for m in grep(msg.args[0] if msg.args[0][0] == "^" else ".*?(" + msg.args[0] + ").*?",
msg.args[1][1:] if msg.args[1][0] == "!" else msg.args[1],
msg.args[2:],
msg,
only=only)]
l = [m for m in grep(msg.args[0] if msg.args[0][0] == "^" else ".*?(" + msg.args[0] + ").*?",
msg.args[1][1:] if msg.args[1][0] == "!" else msg.args[1],
msg.args[2:],
msg,
only=only) if m is not None]
if len(l) <= 0:
raise IMException("Pattern not found in output")
return l