Step 1: Fetch from EUR-Lex and parse standards list.
(args)
| 255 | |
| 256 | |
| 257 | def fetch_and_parse(args) -> list[dict]: |
| 258 | """Step 1: Fetch from EUR-Lex and parse standards list.""" |
| 259 | print("\n=== Step 1: Fetching consolidated Implementing Decision 2021/1182 ===") |
| 260 | |
| 261 | html = None |
| 262 | for url in CONSOLIDATED_VERSIONS: |
| 263 | html = fetch_html(url, "consolidated_2021_1182") |
| 264 | if html: |
| 265 | break |
| 266 | |
| 267 | if not html: |
| 268 | print("ERROR: Could not fetch any consolidated version") |
| 269 | return [] |
| 270 | |
| 271 | standards = parse_annex_table(html) |
| 272 | print(f" Parsed {len(standards)} standards from consolidated version") |
| 273 | |
| 274 | # Step 2: Fetch and apply 2026/193 amendment |
| 275 | print("\n=== Step 2: Checking 2026/193 amendment ===") |
| 276 | amend_html = fetch_html(AMENDMENT_2026_193_URL, "amendment_2026_193") |
| 277 | if amend_html: |
| 278 | new_stds = parse_amendment_additions(amend_html) |
| 279 | existing_numbers = {s["number"] for s in standards} |
| 280 | added = 0 |
| 281 | for std_num in new_stds: |
| 282 | if std_num not in existing_numbers: |
| 283 | # Check if this is an amendment to an existing standard |
| 284 | is_amendment = "/A" in std_num |
| 285 | if is_amendment: |
| 286 | # Find base standard and add as amendment |
| 287 | base = re.match(r"(EN\s+(?:ISO|IEC)\s+[\d\-]+(?::[\d]+)?)", std_num) |
| 288 | if base: |
| 289 | base_num = base.group(1) |
| 290 | for s in standards: |
| 291 | if s["number"] == base_num: |
| 292 | if "amendments" not in s: |
| 293 | s["amendments"] = [] |
| 294 | if std_num not in s["amendments"]: |
| 295 | s["amendments"].append(std_num) |
| 296 | break |
| 297 | else: |
| 298 | standards.append({ |
| 299 | "number": std_num, |
| 300 | "title": "", # Title needs manual review |
| 301 | "row_number": str(len(standards) + 1), |
| 302 | "source": "2026/193", |
| 303 | "needs_review": True, |
| 304 | }) |
| 305 | added += 1 |
| 306 | print(f" 2026/193: {added} new standards added, amendments updated") |
| 307 | else: |
| 308 | print(" WARNING: Could not fetch 2026/193 amendment") |
| 309 | |
| 310 | # Classify all standards |
| 311 | for s in standards: |
| 312 | s["category"] = classify_standard(s) |
| 313 | |
| 314 | # Save raw parsed data |
no test coverage detected