diff options
author | Pacien TRAN-GIRARD | 2017-05-11 21:29:51 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2017-05-11 21:29:51 +0200 |
commit | cc36c9613426507cb2b7e726e9c2d217bf862e2e (patch) | |
tree | 5b767da5d438d53c662ee422437e587e394e20fd | |
parent | 4aea92c4f85fceb4e2a920f7a8beb37ce7d8c04c (diff) | |
download | desktop-utilities-cc36c9613426507cb2b7e726e9c2d217bf862e2e.tar.gz |
Add phone speller script
-rwxr-xr-x | nato.py | 40 |
1 files changed, 40 insertions, 0 deletions
@@ -0,0 +1,40 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | nato = [ | ||
4 | 'Alfa', | ||
5 | 'Bravo', | ||
6 | 'Charlie', | ||
7 | 'Delta', | ||
8 | 'Echo', | ||
9 | 'Foxtrot', | ||
10 | 'Golf', | ||
11 | 'Hotel', | ||
12 | 'India', | ||
13 | 'Juliet', | ||
14 | 'Kilo', | ||
15 | 'Lima', | ||
16 | 'Mike', | ||
17 | 'November', | ||
18 | 'Oscar', | ||
19 | 'Papa', | ||
20 | 'Quebec', | ||
21 | 'Romeo', | ||
22 | 'Sierra', | ||
23 | 'Tango', | ||
24 | 'Uniform', | ||
25 | 'Victor', | ||
26 | 'Whiskey', | ||
27 | 'X-ray', | ||
28 | 'Yankee', | ||
29 | 'Zulu', | ||
30 | ] | ||
31 | |||
32 | alphabet = { w[0]: w for w in nato } | ||
33 | |||
34 | def str_to_telephony(phrase): | ||
35 | return [ alphabet[c] if c in alphabet else c for c in phrase.upper() ] | ||
36 | |||
37 | |||
38 | import sys | ||
39 | |||
40 | print('\n'.join(str_to_telephony(" ".join(sys.argv[1:])))) | ||