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
def test_smartdict_variable_namespace(): res = ("%(foo.lower())s" % smartdict(foo='FOO')) print res assert res == "foo"
def test_smartdict_expr_evaluation(): res = ("%('foo'.upper())s" % smartdict()) print res assert res == "FOO"
def collapseToText(self, state, obj): state.sendEventLine(self.message % smartdict({'actor': self.actor, 'target': self.target}))
def test_smartdict_variable_namespace(): res = ("%(foo.lower())s" % smartdict(foo = 'FOO')) print res assert res == "foo"