2014-12-16 20:26:00 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
table = {
|
|
|
|
"a": "alpha",
|
|
|
|
"b": "bravo",
|
|
|
|
"c": "charlie",
|
|
|
|
"d": "delta",
|
|
|
|
"e": "echo",
|
|
|
|
"f": "foxtrot",
|
|
|
|
"g": "golf",
|
|
|
|
"h": "hotel",
|
|
|
|
"i": "india",
|
|
|
|
"j": "juliett",
|
|
|
|
"k": "kilo",
|
|
|
|
"l": "lima",
|
|
|
|
"m": "mike",
|
|
|
|
"n": "november",
|
|
|
|
"o": "oscar",
|
|
|
|
"p": "papa",
|
|
|
|
"q": "quebec",
|
|
|
|
"r": "romeo",
|
|
|
|
"s": "sierra",
|
|
|
|
"t": "tango",
|
|
|
|
"u": "uniform",
|
|
|
|
"v": "victor",
|
|
|
|
"w": "whiskey",
|
|
|
|
"x": "x-ray",
|
|
|
|
"y": "yankee",
|
2016-08-06 16:18:59 +00:00
|
|
|
"z": "zulu",
|
|
|
|
"0": "Nadazero",
|
|
|
|
"1": "Unaone",
|
|
|
|
"2": "Bissotwo",
|
|
|
|
"3": "Terrathree",
|
|
|
|
"4": "Kartefour",
|
|
|
|
"5": "Pantafive",
|
|
|
|
"6": "Soxisix",
|
|
|
|
"7": "Setteseven",
|
|
|
|
"8": "Oktoeight",
|
2024-03-21 05:38:49 +00:00
|
|
|
"9": "Novenine",
|
|
|
|
}
|
|
|
|
|
2014-12-16 20:26:00 +00:00
|
|
|
|
|
|
|
class IllegalStringSize(Exception):
|
|
|
|
def __init__(self, msg):
|
|
|
|
super(Exception, self).__init__(msg)
|
|
|
|
|
2024-03-21 05:38:49 +00:00
|
|
|
|
2014-12-16 20:26:00 +00:00
|
|
|
def find_in_table(letter):
|
|
|
|
if len(letter) != 1:
|
|
|
|
raise IllegalStringSize(
|
2024-03-21 05:38:49 +00:00
|
|
|
"The letter parameter should only contains one character"
|
|
|
|
)
|
2014-12-16 20:26:00 +00:00
|
|
|
|
|
|
|
if letter in table:
|
2024-03-21 05:38:49 +00:00
|
|
|
res = table[letter]
|
2014-12-16 20:26:00 +00:00
|
|
|
elif letter.lower() in table:
|
|
|
|
res = table[letter.lower()].upper()
|
|
|
|
elif not letter or letter.isspace():
|
|
|
|
res = ""
|
|
|
|
else:
|
|
|
|
res = letter
|
|
|
|
return res
|
|
|
|
|
2024-03-21 05:38:49 +00:00
|
|
|
|
2014-12-16 20:26:00 +00:00
|
|
|
def convert(orig):
|
|
|
|
result = ""
|
|
|
|
for letter in orig:
|
|
|
|
res = find_in_table(letter)
|
|
|
|
if result:
|
|
|
|
result = "%s %s" % (result, res)
|
|
|
|
else:
|
|
|
|
result = res
|
|
|
|
return result
|
|
|
|
|
2024-03-21 05:38:49 +00:00
|
|
|
|
2014-12-16 20:26:00 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
orig = ""
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
for arg in sys.argv[1:]:
|
|
|
|
orig = orig + arg
|
|
|
|
elif not sys.stdin.isatty():
|
|
|
|
for arg in sys.stdin.readlines():
|
|
|
|
orig = orig + arg
|
|
|
|
if orig:
|
|
|
|
orig = orig.replace("\n", " ")
|
|
|
|
result = convert(orig)
|
|
|
|
|
2024-03-21 05:35:37 +00:00
|
|
|
print(f'{orig}:{result}')
|
2014-12-16 20:26:00 +00:00
|
|
|
else:
|
2024-03-21 05:35:37 +00:00
|
|
|
print("usage")
|
2014-12-16 20:26:00 +00:00
|
|
|
|
|
|
|
# vim: set ts=4 sw=4 expandtab:
|