(filters: Iterable[str])
| 496 | |
| 497 | |
| 498 | def discover_examples(filters: Iterable[str]) -> list[ExampleScript]: |
| 499 | filters_lower = [f.lower() for f in filters] |
| 500 | examples: list[ExampleScript] = [] |
| 501 | |
| 502 | for path in EXAMPLES_DIR.rglob("*.py"): |
| 503 | if "__pycache__" in path.parts or path.name.startswith("__"): |
| 504 | continue |
| 505 | |
| 506 | try: |
| 507 | source = path.read_text(encoding="utf-8") |
| 508 | except OSError: |
| 509 | continue |
| 510 | |
| 511 | if not MAIN_PATTERN.search(source): |
| 512 | continue |
| 513 | |
| 514 | relpath = normalize_relpath(str(path.relative_to(ROOT_DIR))) |
| 515 | if relpath in DISCOVERY_EXCLUDE: |
| 516 | continue |
| 517 | |
| 518 | if filters_lower and not any( |
| 519 | f in str(path.relative_to(ROOT_DIR)).lower() for f in filters_lower |
| 520 | ): |
| 521 | continue |
| 522 | |
| 523 | tags = detect_tags(path, source) |
| 524 | examples.append(ExampleScript(path=path, tags=tags)) |
| 525 | |
| 526 | return sorted(examples, key=lambda item: item.relpath) |
| 527 | |
| 528 | |
| 529 | def should_skip( |
no test coverage detected