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))
Beispiel #2
0
    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)
Beispiel #3
0
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)
Beispiel #4
0
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)
Beispiel #5
0
 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()
Beispiel #6
0
def action(**kwargs):
    return formatting._Action(**kwargs)
Beispiel #7
0
 def _get_orthography_thing(self):
     return [
         _Action(text="the", word="the"),
         _Action(text="ing", word="thing", prev_replace="e")
     ]
Beispiel #8
0
 def _get_action_return(self, str):
     return [_Action(text=str, word=str), _Action(combo="Return")]