|
| 1 | +#!/usr/bin/env python3 |
| 2 | +import yaml |
| 3 | +import sys |
| 4 | + |
| 5 | +# Validate input arguments |
| 6 | +if len(sys.argv) != 3: |
| 7 | + print("Usage: python compare_yaml_keys.py <your.yaml> <reference.yaml>") |
| 8 | + sys.exit(1) |
| 9 | + |
| 10 | +your_path = sys.argv[1] |
| 11 | +reference_path = sys.argv[2] |
| 12 | + |
| 13 | +# Configured ignore/include lists |
| 14 | +# Gotten from https://github.com/meilisearch/integration-automations/blob/main/code-samples-checkers/missing-cs-in-integration.sh |
| 15 | +NOT_NEEDED_IN_INTEGRATION = { |
| 16 | + 'tenant_token_guide_search_no_sdk_1', |
| 17 | + 'updating_guide_check_version_new_authorization_header', |
| 18 | + 'updating_guide_check_version_old_authorization_header', |
| 19 | + 'updating_guide_get_displayed_attributes_old_authorization_header', |
| 20 | + 'updating_guide_reset_displayed_attributes_old_authorization_header', |
| 21 | + 'updating_guide_create_dump', |
| 22 | +} |
| 23 | + |
| 24 | +NOT_IN_DOCS_CODE_SAMPLES_FILE = { |
| 25 | + 'tenant_token_guide_generate_sdk_1', |
| 26 | + 'tenant_token_guide_search_sdk_1', |
| 27 | + 'landing_getting_started_1', |
| 28 | +} |
| 29 | + |
| 30 | +# Load YAML files |
| 31 | +with open(your_path) as f1, open(reference_path) as f2: |
| 32 | + your_yaml = yaml.safe_load(f1) or {} |
| 33 | + ref_yaml = yaml.safe_load(f2) or {} |
| 34 | + |
| 35 | +# Collect keys |
| 36 | +your_keys = set(your_yaml.keys()) |
| 37 | +ref_keys = set(ref_yaml.keys()) |
| 38 | + |
| 39 | +# Print results |
| 40 | +print("❌ Incorrect:") |
| 41 | +print("\n".join(sorted(your_keys - ref_keys - NOT_IN_DOCS_CODE_SAMPLES_FILE))) |
| 42 | + |
| 43 | +print("\n🔁 Missing:") |
| 44 | +print("\n".join(sorted(ref_keys - your_keys - NOT_NEEDED_IN_INTEGRATION))) |
0 commit comments