From cc8e0be6ef1653dff4d76c96be2b5ec07d79d831 Mon Sep 17 00:00:00 2001 From: Master Date: Fri, 19 Jun 2026 16:28:57 +0200 Subject: [PATCH] feat: lecture des .pptx dans inputs/ via python-pptx --- facilitator_v8.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/facilitator_v8.py b/facilitator_v8.py index 238bcba..bb889bb 100644 --- a/facilitator_v8.py +++ b/facilitator_v8.py @@ -299,6 +299,34 @@ def _read_docx(path: Path) -> str: return "" +def _read_pptx(path: Path) -> str: + """Extrait le texte (titres, corps, notes) d'un PPTX via python-pptx.""" + try: + from pptx import Presentation + prs = Presentation(str(path)) + chunks = [] + for i, slide in enumerate(prs.slides, 1): + texts = [] + for shape in slide.shapes: + if shape.has_text_frame and shape.text_frame.text.strip(): + texts.append(shape.text_frame.text.strip()) + elif shape.has_table: + for row in shape.table.rows: + cells = [c.text.strip() for c in row.cells] + if any(cells): + texts.append(" | ".join(cells)) + if slide.has_notes_slide: + notes = slide.notes_slide.notes_text_frame.text.strip() + if notes: + texts.append(f"[Notes] {notes}") + if texts: + chunks.append(f"-- Slide {i} --\n" + "\n".join(texts)) + return "\n\n".join(chunks) + except Exception as e: + warn(f"PPTX illisible ({path.name}) : {e}") + return "" + + def load_documents(proj: Project, already_loaded: set) -> tuple[str, set]: """ Charge les fichiers de inputs/ non encore injectés. @@ -328,6 +356,8 @@ def load_documents(proj: Project, already_loaded: set) -> tuple[str, set]: txt = _read_pdf(f) elif ext == ".docx": txt = _read_docx(f) + elif ext == ".pptx": + txt = _read_pptx(f) elif ext in (".txt", ".md", ".markdown", ".csv"): txt = f.read_text(encoding="utf-8", errors="replace") else: