]> git.scottworley.com Git - rfc1751/blame - rfc1751.py
Move word list to separate file
[rfc1751] / rfc1751.py
CommitLineData
27ff981f
SW
1import sys
2
33598cc5 3from rfc1751wordlist import WORD_LIST, WORD_LIST_SIZE
27ff981f 4
27ff981f
SW
5
6# TODO: Decode
7
8
9def encode(x: int) -> str:
10 return WORD_LIST[x]
11
12
13def rfc1751_actual(x: int) -> list[str]:
14 return [] if x <= 0 else rfc1751_actual(
15 x // WORD_LIST_SIZE) + [encode(x % WORD_LIST_SIZE)]
16
17
18def rfc1751(x: int) -> list[str]:
19 return [WORD_LIST[x]] if x == 0 else rfc1751_actual(x)
20
21
22def main() -> None:
23 print(' '.join(rfc1751(int(sys.argv[1]))))
24
25
26if __name__ == '__main__':
27 main()