- bump python-version to 3.14 - bump streamlit to 1.52.2 - bump numpy to 2.4.0 - extra-script for generating special-wb's - rework of container to use a python-virtual-environment and create the special-wb's at first start of the container (no longer at first web-request) - adding links to source-code and docker-registry's in welcome-message - some more error-handling for ADFG(V)X
70 lines
3.4 KiB
Python
70 lines
3.4 KiB
Python
#!/usr/bin/env python3
|
|
# Copyright (c) 2025 Martin Kayser (tebarius)
|
|
# Licensed under the MIT License. See LICENSE file in the project root.
|
|
import os
|
|
|
|
def t9_generate_t9de():
|
|
alphabet = {'A': '2', 'B': '2', 'C': '2', 'D': '3', 'E': '3', 'F': '3', 'G': '4',
|
|
'H': '4', 'I': '4', 'J': '5', 'K': '5', 'L': '5', 'M': '6', 'N': '6',
|
|
'O': '6', 'P': '7', 'Q': '7', 'R': '7', 'S': '7', 'T': '8', 'U': '8',
|
|
'V': '8', 'W': '9', 'X': '9', 'Y': '9', 'Z': '9', '1': '1', '2': '2',
|
|
'3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9',
|
|
'0': '0', 'Ñ': '6', 'É': '3', 'È': '3', 'À': '2', 'Ü': '8', 'Ö': '6',
|
|
'Ä': '2', '@': '1', '?': '1', '=': '0', ':': '1', '/': '1', '.': '1',
|
|
'-': '1', ',': '1', '+': '0', ')': '1', '(': '1', 'SS': '7'}
|
|
ofile = open("./data/t9-de.dic", "a", encoding="iso-8859-15")
|
|
file = open("./data/german.dic", "r", encoding="iso-8859-15")
|
|
for zeile in file:
|
|
omsg = ""
|
|
zeile = zeile.rstrip()
|
|
try:
|
|
for char in zeile:
|
|
omsg = omsg + alphabet[char.upper()]
|
|
except KeyError:
|
|
continue
|
|
else:
|
|
ofile.write(omsg + "," + zeile + "\n")
|
|
file.close()
|
|
ofile.close()
|
|
|
|
def remorse_generate_morsede():
|
|
alphabet = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.',
|
|
'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.',
|
|
'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-',
|
|
'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '1': '.----',
|
|
'2': '..---', '3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
|
|
'8': '---..', '9': '----.', '0': '-----', 'Ñ': '--.--', 'É': '..-..', 'È': '.-..-',
|
|
'À': '.--.-', 'Ü': '..--', 'Ö': '---.', 'Ä': '.-.-', '_': '..--.-', '@': '.--.-.',
|
|
'?': '..--..', '=': '-...-', ';': '-.-.-.', ':': '---...', '/': '-..-.',
|
|
'.': '.-.-.-', '-': '-....-', ',': '--..--', '+': '.-.-.', ')': '-.--.-',
|
|
'(': '-.--.', "'": '.----.', 'SS': '...--..'}
|
|
with open("./data/morse-de.dic", "w", encoding="iso-8859-1") as ofile:
|
|
for symbol, morse in alphabet.items():
|
|
ofile.write(f"{morse},{symbol}\n")
|
|
with open("./data/german.dic", "r", encoding="iso-8859-1") as infile:
|
|
for line in infile:
|
|
word = line.strip()
|
|
try:
|
|
morse_word = ''.join(alphabet[char.upper()] for char in word)
|
|
ofile.write(f"{morse_word},{word}\n")
|
|
except KeyError:
|
|
# Überspringe Wörter mit nicht-unterstützten Zeichen
|
|
continue
|
|
infile.close()
|
|
ofile.close()
|
|
|
|
def generate_special_files():
|
|
if os.path.exists("./data/morse-de.dic"):
|
|
print("Übersprungen...[deutsches Re-Morse-Wörterbuch existiert bereits]")
|
|
else:
|
|
remorse_generate_morsede()
|
|
print("[deutsches Re-Morse-Wörterbuch wurde generiert]")
|
|
if os.path.exists("./data/t9-de.dic"):
|
|
print("Übersprungen...[deutsches T9-Wörterbuch wurde existiert bereits]")
|
|
else:
|
|
t9_generate_t9de()
|
|
print("[deutsches T9-Wörterbuch wurde generiert]")
|
|
|
|
if __name__ == "__main__":
|
|
generate_special_files()
|