fix(import): Foto-Generations-Shift beim Stammbaum-Import beheben
Fotos liegen in den Stammbaum-xlsx je nach Datei links, rechts oder auf der Namenszelle. Die alte Seiten-Erkennung hing an festen Spalten (col 1 / col 4): Blätter ohne solche Anker wurden als Rechts-Layout fehlgedeutet, wodurch jedes Foto eine Generation zum Probanden hin verrutschte. Folge: Kazuya trug das Foto seines Vaters (Wilbur), Wilbur das seines Großvaters (Elay), Elay hatte keins. Fix (extract._attach_photos): beide Interpretationen (links/rechts) durchrechnen und die wählen, die jedes Foto am nächsten an die Namensspalte seines Tiers legt (minimale horizontale Fehlausrichtung). Diagnose über alle 42 Dateien: keine ist echt rechts-seitig; ~21 waren fehlklassifiziert. Selbstjustierend statt fester Spalten-Annahme. Regressionstest in test_extract.py: Kazuya ohne Foto, Wilbur/Elay mit ihren eigenen (gated auf vorhandene Quelldatei). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -396,6 +396,27 @@ if os.path.exists(danako_path):
|
||||
else:
|
||||
print("\nWarning: Danako stammbaum file not found, skipping integration checks.")
|
||||
|
||||
# --- Stammbaum von Kazuya: photo generation-shift regression (PHOTO-LEFT-STYLE) ---
|
||||
# This sheet has neither col-1 nor col-4 image anchors, so the old fixed-column
|
||||
# heuristic misread it as right-style and shifted every photo one generation
|
||||
# toward the proband: Kazuya wore his father's (Wilbur's) photo, Wilbur wore the
|
||||
# grandfather's (Elay's). The fix picks the layout that places photos closest to
|
||||
# their animal's name column → photos land on the correct generation.
|
||||
kazuya_path = r"C:\Users\gulum\dev\Sttammbäume\Stammbaum von Kazuya.xlsx"
|
||||
if os.path.exists(kazuya_path):
|
||||
print(f"\nFound Kazuya stammbaum, running photo generation-shift validation...")
|
||||
kz = {a["name"]: a for a in e.extract_stammbaum(kazuya_path)}
|
||||
if "Kazuya" in kz:
|
||||
check("Kazuya (proband) has NO photo of his own", kz["Kazuya"]["photos"] == [])
|
||||
if "Wilbur" in kz:
|
||||
check("Wilbur (father) gets his own photo (image7), not the grandfather's",
|
||||
kz["Wilbur"]["photos"] == ["photos/wilbur-19032017/image7.jpeg"])
|
||||
if "Elay" in kz:
|
||||
check("Elay (grandfather) gets his own photo (image2)",
|
||||
kz["Elay"]["photos"] == ["photos/elay-16032016/image2.jpeg"])
|
||||
else:
|
||||
print("\nWarning: Kazuya stammbaum file not found, skipping photo-shift checks.")
|
||||
|
||||
if failed:
|
||||
print(f"\n{failed} test(s) FAILED")
|
||||
sys.exit(1)
|
||||
|
||||
Reference in New Issue
Block a user