From 1cfbde798b119a1678a7941d3702f52018f7e857 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Wed, 14 Feb 2024 22:37:05 -0800 Subject: [PATCH] =?utf8?q?Rename=20rfc1751=20=E2=86=92=20encode?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- rfc1751.py | 10 +++++----- rfc1751_test.py | 18 +++++++++--------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/rfc1751.py b/rfc1751.py index f855d9f..70bae6e 100644 --- a/rfc1751.py +++ b/rfc1751.py @@ -21,17 +21,17 @@ from rfc1751wordlist import WORD_LIST, WORD_LIST_SIZE # TODO: Decode -def rfc1751_actual(x: int) -> list[str]: - return [] if x <= 0 else rfc1751_actual( +def encode_actual(x: int) -> list[str]: + return [] if x <= 0 else encode_actual( x // WORD_LIST_SIZE) + [WORD_LIST[x % WORD_LIST_SIZE]] -def rfc1751(x: int) -> list[str]: - return [WORD_LIST[x]] if x == 0 else rfc1751_actual(x) +def encode(x: int) -> list[str]: + return [WORD_LIST[x]] if x == 0 else encode_actual(x) def main() -> None: - print(' '.join(rfc1751(int(sys.argv[1])))) + print(' '.join(encode(int(sys.argv[1])))) if __name__ == '__main__': diff --git a/rfc1751_test.py b/rfc1751_test.py index e4c2cd7..9999dac 100644 --- a/rfc1751_test.py +++ b/rfc1751_test.py @@ -15,21 +15,21 @@ import unittest -from rfc1751 import rfc1751 +from rfc1751 import encode class TestRFC1751(unittest.TestCase): def testRFC1751(self) -> None: - self.assertEqual(rfc1751(0), ['A']) - self.assertEqual(rfc1751(1), ['ABE']) - self.assertEqual(rfc1751(2), ['ACE']) - self.assertEqual(rfc1751(2047), ['YOKE']) - self.assertEqual(rfc1751(2048), ['ABE', 'A']) - self.assertEqual(rfc1751(2049), ['ABE', 'ABE']) - self.assertEqual(rfc1751(2050), ['ABE', 'ACE']) + self.assertEqual(encode(0), ['A']) + self.assertEqual(encode(1), ['ABE']) + self.assertEqual(encode(2), ['ACE']) + self.assertEqual(encode(2047), ['YOKE']) + self.assertEqual(encode(2048), ['ABE', 'A']) + self.assertEqual(encode(2049), ['ABE', 'ABE']) + self.assertEqual(encode(2050), ['ABE', 'ACE']) # Note: These can get NSFW - self.assertEqual(rfc1751(2112325), ['FIRM', 'COCK']) + self.assertEqual(encode(2112325), ['FIRM', 'COCK']) if __name__ == '__main__': -- 2.44.1