(pages_folder)
| 414 | |
| 415 | |
| 416 | def _import_layouts_from_pages(pages_folder): |
| 417 | for root, dirs, files in os.walk(pages_folder): |
| 418 | dirs[:] = [d for d in dirs if not d.startswith(".") and not d.startswith("_")] |
| 419 | for file in files: |
| 420 | if file.startswith("_") or file.startswith(".") or not file.endswith(".py"): |
| 421 | continue |
| 422 | page_path = os.path.join(root, file) |
| 423 | with open(page_path, encoding="utf-8") as f: |
| 424 | content = f.read() |
| 425 | if "register_page" not in content: |
| 426 | continue |
| 427 | |
| 428 | module_name = _infer_module_name(page_path) |
| 429 | spec = importlib.util.spec_from_file_location(module_name, page_path) |
| 430 | page_module = importlib.util.module_from_spec(spec) # type: ignore[reportArgumentType] |
| 431 | spec.loader.exec_module(page_module) # type: ignore[reportOptionalMemberAccess] |
| 432 | sys.modules[module_name] = page_module |
| 433 | |
| 434 | if ( |
| 435 | module_name in PAGE_REGISTRY |
| 436 | and not PAGE_REGISTRY[module_name]["supplied_layout"] |
| 437 | ): |
| 438 | _validate.validate_pages_layout(module_name, page_module) |
| 439 | PAGE_REGISTRY[module_name]["layout"] = getattr(page_module, "layout") |
no test coverage detected
searching dependent graphs…