-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds retro versions for all the transformers * Test for retro function * Bumping version Let's see if closing a PR with a new version number auto-releases Co-authored-by: Seth Rider <seth@thumbquat.com>
- Loading branch information
Showing
8 changed files
with
104 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
#!/usr/bin/env python3 | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from .zalgo import Zalgo | ||
from .uwu import Uwu | ||
from .crytyping import CryTyping | ||
from .sarcasm import Sarcasm | ||
from .substitute import Substitute | ||
from .character_helpers import \ | ||
BUBBLE_MAP, MEDIEVAL_MAP, UPSIDE_DOWN_MAP, FULLWIDTH_MAP | ||
|
||
TRANSFORMERS = { | ||
'bubble': lambda: Substitute(BUBBLE_MAP), | ||
'crytyping': lambda: CryTyping(), | ||
'medieval': lambda: Substitute(MEDIEVAL_MAP), | ||
'fullwidth': lambda: Substitute(FULLWIDTH_MAP), | ||
'uwu': lambda: Uwu(intense=False), | ||
'UwU': lambda: Uwu(intense=True), | ||
'sarcasm': lambda: Sarcasm(), | ||
'upsidedown': lambda: Substitute(UPSIDE_DOWN_MAP), | ||
'zalgo': lambda minimum=1, maximum=3: Zalgo(int(minimum), | ||
int(maximum)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from plover.formatting import _Context, _Action | ||
|
||
from .common import TRANSFORMERS | ||
|
||
|
||
def fancytext_retro(ctx: _Context, cmdline: str) -> _Action: | ||
action = ctx.copy_last_action() | ||
args = cmdline.split(':') | ||
|
||
# should be <numwords>:mode:<any extra mode args> | ||
count = int(args.pop(0)) | ||
mode = args.pop(0) | ||
|
||
transformer = TRANSFORMERS[mode](*args) | ||
|
||
last_words = ''.join(ctx.last_words(count=count)) | ||
|
||
action.word = None | ||
action.text = transformer.format(last_words) | ||
|
||
action.prev_replace = last_words | ||
action.prev_attach = True | ||
|
||
return action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from unittest import TestCase | ||
from .retro import fancytext_retro | ||
|
||
from plover.formatting import _Action | ||
|
||
|
||
class FakeContext(): | ||
def __init__(self, actions): | ||
self.actions = actions | ||
|
||
def copy_last_action(self): | ||
return self.actions[-1] | ||
|
||
def last_words(self, count): | ||
return [a.word for a in self.actions[-count:]] | ||
|
||
|
||
class TestRetro(TestCase): | ||
|
||
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters