From cf0a9a63267acb6f1ed40d98df32a4e83a029c56 Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 16 Apr 2026 14:16:22 +0000 Subject: [PATCH] =?UTF-8?q?Load=20Windows=20from=20SiteNotes=20JSON=20?= =?UTF-8?q?=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/documents_parser/extractor.py | 34 ++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/documents_parser/extractor.py b/backend/documents_parser/extractor.py index f7da5d46..99c388e4 100644 --- a/backend/documents_parser/extractor.py +++ b/backend/documents_parser/extractor.py @@ -262,7 +262,39 @@ class PasHubRdSapSiteNotesExtractor: ) def extract_windows(self) -> List[Window]: - raise NotImplementedError + w_section = self._section("Windows", "Heating & Hot Water") + + windows = [] + n = 1 + while f"Window {n}" in w_section: + start = w_section.index(f"Window {n}") + end = ( + w_section.index(f"Window {n + 1}") + if f"Window {n + 1}" in w_section + else len(w_section) + ) + windows.append(self._parse_window(n, w_section[start:end])) + n += 1 + + return windows + + def _parse_window(self, window_id: int, data: List[str]) -> Window: + height_raw = self._get_in(data, "Window height:") + width_raw = self._get_in(data, "Window width:") + return Window( + id=window_id, + location=self._get_in(data, "Window location:") or "", + wall_type=self._get_in(data, "Window wall type:") or "", + glazing_type=self._get_in(data, "Glazing Type:") or "", + window_type=self._get_in(data, "Window type:") or "", + frame_type=self._get_in(data, "Window frame type:") or "", + glazing_gap=self._get_in(data, "What size is the glazing gap?") or "", + draught_proofed=self._bool_in(data, "Is the window draught proofed?"), + permanent_shutters=self._bool_in(data, "Are there permanent shutters present?"), + height_m=float(height_raw.split()[0]) if height_raw else 0.0, + width_m=float(width_raw.split()[0]) if width_raw else 0.0, + orientation=self._get_in(data, "Orientation:") or "", + ) def _parse_insulation_thickness( self, val: Optional[str]