You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
1.8 KiB
Python

#!/usr/bin/env python3
buchstabiertafel = {
"A": "Anton",
"B": "Berta",
"C": "Cäsar",
"D": "Dora",
"E": "Emil",
"F": "Friedrich",
"G": "Gustav",
"H": "Heinrich",
"I": "Ida",
"J": "Julius",
"K": "Kaufmann",
"L": "Ludwig",
"M": "Martha",
"N": "Nordpol",
"O": "Otto",
"P": "Paula",
"Q": "Quelle",
"R": "Richard",
"S": "Siegfried",
"T": "Theodor",
"U": "Ulrich",
"V": "Viktor",
"W": "Wilhelm",
"X": "Xanthippe",
"Y": "Ypsilon",
"Z": "Zacharias",
"Ä": "Ärger",
"Ö": "Ökonom",
"Ü": "Übermut",
"0": "Null",
"1": "Eins",
"2": "Zwo",
"3": "Drei",
"4": "Vier",
"5": "Fünf",
"6": "Sechs",
"7": "Sieben",
"8": "Acht",
"9": "Neun"
}
nato_tafel = {
"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",
"Z": "Zulu"
}
def to_buchstabierfassung(inputstring, tafel=buchstabiertafel):
output = inputstring + ": "
for letter in inputstring:
if letter == ' ': continue
try:
output += tafel[str.upper(letter)] + ' '
except KeyError:
output += letter + ' '
print(output)
def main():
import sys
if len(sys.argv) < 2:
to_buchstabierfassung("highQ")
to_buchstabierfassung("Computerlösungen")
print()
to_buchstabierfassung("Felix")
to_buchstabierfassung("Pankratz")
else:
if sys.argv[1] == '-n':
for word in sys.argv[2:]:
to_buchstabierfassung(word, tafel=nato_tafel)
else:
for word in sys.argv[1:]:
to_buchstabierfassung(word)
if __name__ == '__main__':
main()