about summary refs log tree commit diff stats
path: root/sys/nixpkgs/pkgs/scripts/source/small_functions/nato.py
blob: e9d15f5638dc8907c894cd7ab5bb439c7ba2ac37 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/usr/bin/env python3
# originally from here: https://cgit.pacien.net/desktop-utilities/

import sys

alphabet = {
    "nato": {
        "A": "Alfa",  # No idea why this is not just '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",
        "Z": "Zulu",
        "0": "Nadazero",
        "1": "Unaone",
        "2": "Bissotwo",
        "3": "Terrathree",
        "4": "Kartefour",
        "5": "Pantafive",
        "6": "Soxisix",
        "7": "Setteseven",
        "8": "Oktoeight",
        "9": "Novenine",
        ",": "Comma",
        "/": "Forward slash",
        ".": "Stop/Decimal",
    },
    "german": {
        "A": "Aachen",
        "Ä": "Umlaut Aachen",
        "B": "Berlin",
        "C": "Chemnitz",
        "D": "Düsseldorf",
        "E": "Essen",
        "F": "Frankfurt",
        "G": "Goslar",
        "H": "Hamburg",
        "I": "Ingelheim",
        "J": "Jena",
        "K": "Köln",
        "L": "Leipzig",
        "M": "München",
        "N": "Nürnberg",
        "O": "Offenbach",
        "Ö": "Umlaut Offenbach",
        "P": "Potsdam",
        "Q": "Quickborn",
        "R": "Rostock",
        "S": "Salzwedel",
        "ẞ": "Eszett",
        "T": "Tübingen",
        "U": "Unna",
        "Ü": "Umlaut Unna",
        "V": "Völklingen",
        "W": "Wuppertal",
        "X": "Xanten",
        "Y": "Ypsilon",
        "Z": "Zwickau",
    },
}


def str_to_telephony(phrase, language):
    language_alphabet = alphabet[language]

    return [
        language_alphabet[c] if c in language_alphabet else c for c in phrase.upper()
    ]


language = sys.argv[1]
if language not in ["nato", "german"]:
    print(
        f"Langugae '{language}' is not a valid language, only 'nato' and 'german' are!",
        file=sys.stderr,
    )
    exit(1)

print(
    "\n".join(
        str_to_telephony(
            " ".join(sys.argv[2:]),
            language,
        )
    )
)