bugfix
This commit is contained in:
@@ -653,8 +653,8 @@ def is_valid_wikipedia_article_url(wiki_url):
|
|||||||
# Komplette Funktion process_wiki_updates_from_chatgpt (Syntaxfehler behoben)
|
# Komplette Funktion process_wiki_updates_from_chatgpt (Syntaxfehler behoben)
|
||||||
def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=None):
|
def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=None):
|
||||||
"""
|
"""
|
||||||
Identifiziert Zeilen (S nicht OK/Updated/Copied), prüft ob U eine *valide* und *andere* Wiki-URL ist.
|
Identifiziert Zeilen (S nicht OK/Updated/Copied/Invalid), prüft ob U eine *valide* und *andere* Wiki-URL ist.
|
||||||
- Wenn ja: Kopiert U->M, markiert S='X (URL Copied)', U='URL übernommen', löscht TS/Version, setzt ReEval-Flag A.
|
- Wenn ja: Kopiert U->M, markiert S='X (URL Copied)', U='URL übernommen', löscht TS/Version, SETZT ReEval-Flag A='x'.
|
||||||
- Wenn nein (U keine URL, U==M, oder U ungültig): LÖSCHT den Inhalt von U und markiert S als 'X (Invalid Suggestion)'.
|
- Wenn nein (U keine URL, U==M, oder U ungültig): LÖSCHT den Inhalt von U und markiert S als 'X (Invalid Suggestion)'.
|
||||||
Verarbeitet maximal row_limit Zeilen.
|
Verarbeitet maximal row_limit Zeilen.
|
||||||
"""
|
"""
|
||||||
@@ -666,7 +666,7 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
header_rows = 5
|
header_rows = 5
|
||||||
data_rows = all_data[header_rows:]
|
data_rows = all_data[header_rows:]
|
||||||
|
|
||||||
# --- Indizes holen (Korrigierte Schleife) ---
|
# --- Indizes holen (inkl. ReEval Flag) ---
|
||||||
required_keys = [
|
required_keys = [
|
||||||
"Chat Wiki Konsistenzprüfung", "Chat Vorschlag Wiki Artikel", "Wiki URL",
|
"Chat Wiki Konsistenzprüfung", "Chat Vorschlag Wiki Artikel", "Wiki URL",
|
||||||
"Wikipedia Timestamp", "Wiki Verif. Timestamp", "Timestamp letzte Prüfung", "Version",
|
"Wikipedia Timestamp", "Wiki Verif. Timestamp", "Timestamp letzte Prüfung", "Version",
|
||||||
@@ -674,26 +674,18 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
]
|
]
|
||||||
col_indices = {}
|
col_indices = {}
|
||||||
all_keys_found = True
|
all_keys_found = True
|
||||||
# --- KORRIGIERTE SCHLEIFE ---
|
|
||||||
for key in required_keys:
|
for key in required_keys:
|
||||||
idx = COLUMN_MAP.get(key)
|
idx = COLUMN_MAP.get(key)
|
||||||
col_indices[key] = idx # Speichere den Index (kann auch None sein)
|
col_indices[key] = idx
|
||||||
if idx is None:
|
if idx is None: debug_print(f"FEHLER: Key '{key}' fehlt!"); all_keys_found = False
|
||||||
debug_print(f"FEHLER: Schlüssel '{key}' für Spaltenindex fehlt in COLUMN_MAP!")
|
if not all_keys_found: return debug_print("Breche Wiki-Updates ab.")
|
||||||
all_keys_found = False
|
|
||||||
# --- ENDE KORRIGIERTE SCHLEIFE ---
|
|
||||||
|
|
||||||
if not all_keys_found:
|
|
||||||
debug_print("Breche Wiki-Updates ab, da Spaltenindizes fehlen.")
|
|
||||||
return
|
|
||||||
# --- Ende Indizes holen ---
|
# --- Ende Indizes holen ---
|
||||||
|
|
||||||
all_sheet_updates = []
|
all_sheet_updates = []
|
||||||
processed_rows_count = 0 # Zählt jetzt beide Arten von Updates
|
processed_rows_count = 0 # Zählt jetzt beide Arten von Updates
|
||||||
updated_url_count = 0
|
updated_url_count = 0
|
||||||
cleared_suggestion_count = 0
|
cleared_suggestion_count = 0
|
||||||
error_rows_count = 0 # Behalte Fehlerzählung bei
|
# error_rows_count = 0 # Nicht mehr benötigt bei aktueller Struktur
|
||||||
# wiki_scraper wird nicht mehr benötigt
|
|
||||||
|
|
||||||
for idx, row in enumerate(data_rows):
|
for idx, row in enumerate(data_rows):
|
||||||
row_num_in_sheet = idx + header_rows + 1
|
row_num_in_sheet = idx + header_rows + 1
|
||||||
@@ -703,13 +695,9 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
break
|
break
|
||||||
|
|
||||||
def get_value(key):
|
def get_value(key):
|
||||||
index = col_indices.get(key)
|
index = col_indices.get(key); return row[index] if index is not None and len(row) > index else ""
|
||||||
if index is not None and len(row) > index: return row[index]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
konsistenz_s = get_value("Chat Wiki Konsistenzprüfung")
|
konsistenz_s = get_value("Chat Wiki Konsistenzprüfung"); vorschlag_u = get_value("Chat Vorschlag Wiki Artikel"); url_m = get_value("Wiki URL")
|
||||||
vorschlag_u = get_value("Chat Vorschlag Wiki Artikel")
|
|
||||||
url_m = get_value("Wiki URL")
|
|
||||||
|
|
||||||
# Bedingungen prüfen
|
# Bedingungen prüfen
|
||||||
is_update_candidate = False; new_url = ""
|
is_update_candidate = False; new_url = ""
|
||||||
@@ -724,22 +712,23 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
new_url = vorschlag_u_cleaned
|
new_url = vorschlag_u_cleaned
|
||||||
condition3_u_differs_m = new_url != url_m_cleaned
|
condition3_u_differs_m = new_url != url_m_cleaned
|
||||||
if condition3_u_differs_m:
|
if condition3_u_differs_m:
|
||||||
# debug_print(f"Zeile {row_num_in_sheet}: Potenzieller Kandidat. Prüfe Validität von URL: {new_url}...") # Weniger Lärm
|
condition4_u_is_valid = is_valid_wikipedia_article_url(new_url)
|
||||||
condition4_u_is_valid = is_valid_wikipedia_article_url(new_url) # Annahme: Funktion existiert
|
# if not condition4_u_is_valid: debug_print(...) # Weniger Lärm
|
||||||
# if not condition4_u_is_valid: debug_print(f"Zeile {row_num_in_sheet}: URL '{new_url}' ist KEIN valider Artikel.") # Weniger Lärm
|
|
||||||
|
|
||||||
is_update_candidate = condition1_status_nok and condition2_u_is_url and condition3_u_differs_m and condition4_u_is_valid
|
is_update_candidate = condition1_status_nok and condition2_u_is_url and condition3_u_differs_m and condition4_u_is_valid
|
||||||
|
|
||||||
# Behandlung ungültiger/unpassender Vorschläge
|
|
||||||
clear_invalid_suggestion = condition1_status_nok and not is_update_candidate
|
clear_invalid_suggestion = condition1_status_nok and not is_update_candidate
|
||||||
|
|
||||||
# --- Verarbeitung des Kandidaten ODER Löschen des Vorschlags ---
|
# (Debugging kann bleiben)
|
||||||
|
if row_num_in_sheet in [28, 40, 42] or idx < 2:
|
||||||
|
debug_print(f"\n--- DEBUG Zeile {row_num_in_sheet} ---"); # ... (Rest Debug) ...
|
||||||
|
|
||||||
|
# --- Verarbeitung ---
|
||||||
if is_update_candidate:
|
if is_update_candidate:
|
||||||
# Fall 1: Gültiges Update durchführen
|
# Fall 1: Gültiges Update durchführen
|
||||||
debug_print(f"Zeile {row_num_in_sheet}: Update-Kandidat VALIDIERUNG ERFOLGREICH. Setze ReEval-Flag und bereite Updates vor.")
|
debug_print(f"Zeile {row_num_in_sheet}: Update-Kandidat VALIDIERUNG ERFOLGREICH. Setze ReEval-Flag und bereite Updates vor.")
|
||||||
processed_rows_count += 1
|
processed_rows_count += 1
|
||||||
updated_url_count += 1
|
updated_url_count += 1
|
||||||
# Updates sammeln (M, S, U, Timestamps/Version löschen, A setzen)
|
# Updates sammeln (M, S="X (URL Copied)", U="URL übernommen", Timestamps/Version löschen, A="x")
|
||||||
m_l=sheet_handler._get_col_letter(col_indices["Wiki URL"]+1); s_l=sheet_handler._get_col_letter(col_indices["Chat Wiki Konsistenzprüfung"]+1); u_l=sheet_handler._get_col_letter(col_indices["Chat Vorschlag Wiki Artikel"]+1); an_l=sheet_handler._get_col_letter(col_indices["Wikipedia Timestamp"]+1); ax_l=sheet_handler._get_col_letter(col_indices["Wiki Verif. Timestamp"]+1); ao_l=sheet_handler._get_col_letter(col_indices["Timestamp letzte Prüfung"]+1); ap_l=sheet_handler._get_col_letter(col_indices["Version"]+1); a_l=sheet_handler._get_col_letter(col_indices["ReEval Flag"]+1)
|
m_l=sheet_handler._get_col_letter(col_indices["Wiki URL"]+1); s_l=sheet_handler._get_col_letter(col_indices["Chat Wiki Konsistenzprüfung"]+1); u_l=sheet_handler._get_col_letter(col_indices["Chat Vorschlag Wiki Artikel"]+1); an_l=sheet_handler._get_col_letter(col_indices["Wikipedia Timestamp"]+1); ax_l=sheet_handler._get_col_letter(col_indices["Wiki Verif. Timestamp"]+1); ao_l=sheet_handler._get_col_letter(col_indices["Timestamp letzte Prüfung"]+1); ap_l=sheet_handler._get_col_letter(col_indices["Version"]+1); a_l=sheet_handler._get_col_letter(col_indices["ReEval Flag"]+1)
|
||||||
row_updates = [
|
row_updates = [
|
||||||
{'range': f'{m_l}{row_num_in_sheet}', 'values': [[new_url]]},
|
{'range': f'{m_l}{row_num_in_sheet}', 'values': [[new_url]]},
|
||||||
@@ -749,6 +738,7 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
{'range': f'{ax_l}{row_num_in_sheet}', 'values': [[""]]},
|
{'range': f'{ax_l}{row_num_in_sheet}', 'values': [[""]]},
|
||||||
{'range': f'{ao_l}{row_num_in_sheet}', 'values': [[""]]},
|
{'range': f'{ao_l}{row_num_in_sheet}', 'values': [[""]]},
|
||||||
{'range': f'{ap_l}{row_num_in_sheet}', 'values': [[""]]},
|
{'range': f'{ap_l}{row_num_in_sheet}', 'values': [[""]]},
|
||||||
|
# --- WIEDER HINZUGEFÜGT: Setze 'x' in Spalte A ---
|
||||||
{'range': f'{a_l}{row_num_in_sheet}', 'values': [["x"]]},
|
{'range': f'{a_l}{row_num_in_sheet}', 'values': [["x"]]},
|
||||||
]
|
]
|
||||||
all_sheet_updates.extend(row_updates)
|
all_sheet_updates.extend(row_updates)
|
||||||
@@ -756,16 +746,16 @@ def process_wiki_updates_from_chatgpt(sheet_handler, data_processor, row_limit=N
|
|||||||
elif clear_invalid_suggestion:
|
elif clear_invalid_suggestion:
|
||||||
# Fall 2: Ungültigen Vorschlag löschen/markieren
|
# Fall 2: Ungültigen Vorschlag löschen/markieren
|
||||||
debug_print(f"Zeile {row_num_in_sheet}: Status S war '{konsistenz_s}', aber Vorschlag U ('{vorschlag_u_cleaned}') ist ungültig/identisch. Lösche U und setze Status S.")
|
debug_print(f"Zeile {row_num_in_sheet}: Status S war '{konsistenz_s}', aber Vorschlag U ('{vorschlag_u_cleaned}') ist ungültig/identisch. Lösche U und setze Status S.")
|
||||||
processed_rows_count += 1 # Zähle auch diese Aktion
|
processed_rows_count += 1
|
||||||
cleared_suggestion_count += 1
|
cleared_suggestion_count += 1
|
||||||
# Updates sammeln (S="X (Invalid Suggestion)", U="")
|
|
||||||
s_l=sheet_handler._get_col_letter(col_indices["Chat Wiki Konsistenzprüfung"]+1)
|
s_l=sheet_handler._get_col_letter(col_indices["Chat Wiki Konsistenzprüfung"]+1)
|
||||||
u_l=sheet_handler._get_col_letter(col_indices["Chat Vorschlag Wiki Artikel"]+1)
|
u_l=sheet_handler._get_col_letter(col_indices["Chat Vorschlag Wiki Artikel"]+1)
|
||||||
row_updates = [
|
row_updates = [
|
||||||
{'range': f'{s_l}{row_num_in_sheet}', 'values': [["X (Invalid Suggestion)"]]}, # Neuer Status
|
{'range': f'{s_l}{row_num_in_sheet}', 'values': [["X (Invalid Suggestion)"]]},
|
||||||
{'range': f'{u_l}{row_num_in_sheet}', 'values': [[""]]} # Leere Spalte U
|
{'range': f'{u_l}{row_num_in_sheet}', 'values': [[""]]}
|
||||||
]
|
]
|
||||||
all_sheet_updates.extend(row_updates)
|
all_sheet_updates.extend(row_updates)
|
||||||
|
# --- KEIN ReEval-Flag setzen ---
|
||||||
|
|
||||||
# --- Batch Update am Ende ---
|
# --- Batch Update am Ende ---
|
||||||
if all_sheet_updates:
|
if all_sheet_updates:
|
||||||
|
|||||||
Reference in New Issue
Block a user