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