|
1 | 1 | #!/usr/bin/env python3 |
2 | 2 | import json |
| 3 | +from re import search |
3 | 4 | from pathlib import Path |
4 | 5 |
|
5 | 6 | ROOT_DIR = Path(__file__).resolve().parent.parent |
6 | 7 | EXERCISES_DIR = ROOT_DIR / "exercises" |
7 | 8 |
|
| 9 | + |
8 | 10 | def main(): |
9 | | - missing_images_count = 0 |
| 11 | + missing_images_count = "TODO Measure missing images and images directories" |
10 | 12 | empty_images_count = 0 |
11 | 13 | force_inconsistencies = 0 |
12 | | - |
| 14 | + |
13 | 15 | for file_path in EXERCISES_DIR.glob("*.json"): |
14 | 16 | with open(file_path, "r") as f: |
15 | 17 | data = json.load(f) |
16 | | - |
| 18 | + |
17 | 19 | id = data.get("id") |
18 | 20 | name = data.get("name", "").lower() |
19 | 21 | force = data.get("force") |
20 | 22 | images = data.get("images", []) |
21 | 23 |
|
22 | 24 | # 1. Check for empty images |
23 | 25 | if not images: |
24 | | - print(f"Warning: {id} has an empty images array.") |
| 26 | + print(f"Warning: {id} has an empty images array") |
25 | 27 | empty_images_count += 1 |
26 | 28 |
|
27 | 29 | # 2. Check for force consistency |
28 | | - if "press" in name and force != "push": |
29 | | - # Some stretches might have 'press' in name but be 'static' |
30 | | - if force != "static": |
31 | | - print(f"Potential force inconsistency: {id} ({name}) is '{force}' but has 'press' in name.") |
32 | | - force_inconsistencies += 1 |
33 | | - |
34 | | - if ("curl" in name or "row" in name or "pull" in name) and force != "pull": |
35 | | - if force != "static" and "pullover" not in name: # Pullover can be push/pull depending on technique |
36 | | - print(f"Potential force inconsistency: {id} ({name}) is '{force}' but has '{name}' in name (expected pull).") |
37 | | - force_inconsistencies += 1 |
| 30 | + if search("\bpress\b|\bthrow\b", name) and force not in ("push", "static"): |
| 31 | + print( |
| 32 | + f"Potential force inconsistency: {id} ({name}) is '{force}' but has '{name}' in name (expected push)" |
| 33 | + ) |
| 34 | + force_inconsistencies += 1 |
| 35 | + if (search("\bcurl\b|\brow\b|\bpull\b", name)) and force not in ( |
| 36 | + "pull", |
| 37 | + "static", |
| 38 | + ): |
| 39 | + print( |
| 40 | + f"Potential force inconsistency: {id} ({name}) is '{force}' but has '{name}' in name (expected pull)" |
| 41 | + ) |
| 42 | + force_inconsistencies += 1 |
38 | 43 |
|
39 | 44 | print("\nSummary:") |
40 | 45 | print(f"Empty images arrays: {empty_images_count}") |
| 46 | + print(f"Referenced but missing images: {missing_images_count}") |
41 | 47 | print(f"Potential force inconsistencies: {force_inconsistencies}") |
42 | 48 |
|
| 49 | + |
43 | 50 | if __name__ == "__main__": |
44 | 51 | main() |
0 commit comments