def test_replace_action(self): s = Sarcasm() a = [ _Action(text="previous text"), _Action(prev_replace="previous text", text="new text") ] s.process_actions(a) self.assertTrue(a[0].text.endswith(a[1].prev_replace))
def test_retro_sarcasm(self): action = _Action(word="fancy", text="fancy") retroed = fancytext_retro(FakeContext([action]), "1:sarcasm") self.assertEqual(retroed.prev_replace, "fancy") self.assertEqual(retroed.text, "fANcY") self.assertIsNone(retroed.word) self.assertTrue(retroed.prev_attach)
def action(**kwargs): # Support using something like `text_and_word='stuff'` # as a shortcut for `text='stuff', word='stuff'`. for k, v in list(kwargs.items()): if '_and_' in k: del kwargs[k] for k in k.split('_and_'): kwargs[k] = v return formatting._Action(**kwargs)
def action(**kwargs): # Suport using something like `text_and_word='stuff'` # as a shortcut for `text='stuff', word='stuff'`. for k, v in list(kwargs.items()): if '_and_' in k: del kwargs[k] for k in k.split('_and_'): kwargs[k] = v return formatting._Action(**kwargs)
def reset(self, full=False, output=True): self._log.debug('reset steno state (full=%s)' % full) state = _State() state.tail = self._translator.get_state().last() if full or state.tail is None: state.tail = Translation([Stroke('*')], None) state.tail.formatting = [_Action(attach=True)] self._translator.set_state(state) if output: self._output.reset()
def action(**kwargs): return formatting._Action(**kwargs)
def _get_orthography_thing(self): return [ _Action(text="the", word="the"), _Action(text="ing", word="thing", prev_replace="e") ]
def _get_action_return(self, str): return [_Action(text=str, word=str), _Action(combo="Return")]