Created
June 23, 2026 10:06
-
-
Save kikito/36a4d90784c2961035bd64721255cefa to your computer and use it in GitHub Desktop.
List empty recipes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """List recipes whose kong_recipe section is incomplete (empty outcome field).""" | |
| import sys | |
| from pathlib import Path | |
| try: | |
| import yaml | |
| except ImportError: | |
| sys.exit("PyYAML is required: pip install pyyaml") | |
| RECIPES_DIR = Path(__file__).parent / "corpus" / "recipes" | |
| def is_incomplete(kong_recipe: dict) -> bool: | |
| """A recipe is incomplete when its outcome is absent or empty.""" | |
| outcome = kong_recipe.get("outcome", "") | |
| return not outcome or str(outcome).strip() == "" | |
| def main() -> None: | |
| recipe_files = sorted(RECIPES_DIR.glob("*.yaml")) | |
| if not recipe_files: | |
| sys.exit(f"No YAML files found in {RECIPES_DIR}") | |
| incomplete = [] | |
| errors = [] | |
| for path in recipe_files: | |
| try: | |
| data = yaml.safe_load(path.read_text()) | |
| except yaml.YAMLError as exc: | |
| errors.append((path.name, str(exc))) | |
| continue | |
| if not isinstance(data, dict): | |
| errors.append((path.name, "top-level is not a mapping")) | |
| continue | |
| kong_recipe = data.get("kong_recipe") | |
| if not isinstance(kong_recipe, dict): | |
| # Missing section entirely — treat as incomplete | |
| incomplete.append((path.name, data.get("use_case", "<unknown>"))) | |
| continue | |
| if is_incomplete(kong_recipe): | |
| incomplete.append((path.name, data.get("use_case", "<unknown>"))) | |
| print(f"Incomplete recipes: {len(incomplete)} / {len(recipe_files)}\n") | |
| for filename, use_case in incomplete: | |
| print(f" {filename} ({use_case})") | |
| if errors: | |
| print(f"\nParse errors ({len(errors)}):") | |
| for filename, msg in errors: | |
| print(f" {filename}: {msg}") | |
| if __name__ == "__main__": | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment