"Refactor duplicate data handling for improved performance"
This commit is contained in:
parent
500caa2c2f
commit
1927305673
6931
backend/app/app.py
6931
backend/app/app.py
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@ -1 +1,56 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Script zur Entfernung der Duplikationen in app.py
|
||||
Behält nur die erste Occurrence von jeder Funktion/Route.
|
||||
"""
|
||||
|
||||
def fix_app_duplicates():
|
||||
"""Entfernt Duplikationen in app.py und behält nur die erste Version."""
|
||||
|
||||
# Lese die Originaldatei
|
||||
with open('app.py', 'r', encoding='utf-8') as f:
|
||||
lines = f.readlines()
|
||||
|
||||
print(f"Original: {len(lines)} Zeilen")
|
||||
|
||||
# Finde die Zeile mit der ersten Duplikation (Login Manager)
|
||||
duplicate_start = None
|
||||
main_section_start = None
|
||||
|
||||
for i, line in enumerate(lines):
|
||||
# Suche nach der doppelten Login Manager Definition
|
||||
if duplicate_start is None and i > 1000 and "# Login-Manager initialisieren" in line:
|
||||
duplicate_start = i
|
||||
print(f"Duplikation beginnt bei Zeile {i+1}: {line.strip()}")
|
||||
|
||||
# Suche nach Main-Sektion
|
||||
if "# ===== STARTUP UND MAIN =====" in line:
|
||||
main_section_start = i
|
||||
print(f"Main-Sektion beginnt bei Zeile {i+1}: {line.strip()}")
|
||||
break
|
||||
|
||||
if duplicate_start and main_section_start:
|
||||
# Erstelle neue Datei ohne Duplikation
|
||||
new_lines = []
|
||||
|
||||
# Alles bis zur Duplikation
|
||||
new_lines.extend(lines[:duplicate_start])
|
||||
|
||||
# Main-Sektion und alles danach
|
||||
new_lines.extend(lines[main_section_start:])
|
||||
|
||||
print(f"Bereinigt: {len(new_lines)} Zeilen")
|
||||
print(f"Entfernt: {len(lines) - len(new_lines)} Zeilen")
|
||||
|
||||
# Schreibe bereinigte Datei
|
||||
with open('app.py', 'w', encoding='utf-8') as f:
|
||||
f.writelines(new_lines)
|
||||
|
||||
print("✅ Duplikationen erfolgreich entfernt!")
|
||||
return True
|
||||
else:
|
||||
print("❌ Duplikations-Marker nicht gefunden!")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
fix_app_duplicates()
|
Loading…
x
Reference in New Issue
Block a user