예제 #1
0
def _respondline(line, new = True):
    #would caching be a good idea?
    line = _prepare_line(line)
    hits = []
    for pattern, responsetemps in responses:
        try:
            result, = pattern.parseString(line)
        except ParseException:
            continue
        else:
            hits.append((responsetemps, result))
    if hits:
        temps, result = choice(hits)
        temp = choice(temps)
        return temp % smartdict({'res': bettertranslate(result,
                                                        reflections)})
    else:
        raise _NoResponse
예제 #2
0
def test_smartdict_variable_namespace():
    res = ("%(foo.lower())s" % smartdict(foo='FOO'))
    print res
    assert res == "foo"
예제 #3
0
def test_smartdict_expr_evaluation():
    res = ("%('foo'.upper())s" % smartdict())
    print res
    assert res == "FOO"
예제 #4
0
파일: emote.py 프로젝트: ViKingIX/grailmud
 def collapseToText(self, state, obj):
     state.sendEventLine(self.message % smartdict({'actor': self.actor,
                                                   'target': self.target}))
예제 #5
0
def test_smartdict_variable_namespace():
    res = ("%(foo.lower())s" % smartdict(foo = 'FOO'))
    print res
    assert res == "foo"
예제 #6
0
def test_smartdict_expr_evaluation():
    res = ("%('foo'.upper())s" % smartdict())
    print res
    assert res == "FOO"