mirror of
https://github.com/adulau/nato-converter.git
synced 2024-12-22 00:36:04 +00:00
commit
fac114dfa0
1 changed files with 11 additions and 7 deletions
|
@ -3,7 +3,6 @@
|
|||
|
||||
import sys
|
||||
|
||||
|
||||
table = {
|
||||
"a": "alpha",
|
||||
"b": "bravo",
|
||||
|
@ -40,17 +39,20 @@ table = {
|
|||
"6": "Soxisix",
|
||||
"7": "Setteseven",
|
||||
"8": "Oktoeight",
|
||||
"9": "Novenine"
|
||||
"9": "Novenine",
|
||||
}
|
||||
|
||||
|
||||
class IllegalStringSize(Exception):
|
||||
def __init__(self, msg):
|
||||
super(Exception, self).__init__(msg)
|
||||
|
||||
|
||||
def find_in_table(letter):
|
||||
if len(letter) != 1:
|
||||
raise IllegalStringSize(
|
||||
"The letter parameter should only contains one character")
|
||||
"The letter parameter should only contains one character"
|
||||
)
|
||||
|
||||
if letter in table:
|
||||
res = table[letter]
|
||||
|
@ -62,6 +64,7 @@ def find_in_table(letter):
|
|||
res = letter
|
||||
return res
|
||||
|
||||
|
||||
def convert(orig):
|
||||
result = ""
|
||||
for letter in orig:
|
||||
|
@ -72,6 +75,7 @@ def convert(orig):
|
|||
result = res
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
orig = ""
|
||||
if len(sys.argv) > 1:
|
||||
|
@ -84,8 +88,8 @@ if __name__ == '__main__':
|
|||
orig = orig.replace("\n", " ")
|
||||
result = convert(orig)
|
||||
|
||||
print "%s: %s" % (orig, result)
|
||||
print(f'{orig}:{result}')
|
||||
else:
|
||||
print "usage"
|
||||
print("usage")
|
||||
|
||||
# vim: set ts=4 sw=4 expandtab:
|
||||
|
|
Loading…
Reference in a new issue