Skip to content

Commit b8a40d0

Browse files
committed
fix: check logic
1 parent f3cb31e commit b8a40d0

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

scripts/check_logic.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
11
#!/usr/bin/env python3
22
import json
3+
from re import search
34
from pathlib import Path
45

56
ROOT_DIR = Path(__file__).resolve().parent.parent
67
EXERCISES_DIR = ROOT_DIR / "exercises"
78

9+
810
def main():
9-
missing_images_count = 0
11+
missing_images_count = "TODO Measure missing images and images directories"
1012
empty_images_count = 0
1113
force_inconsistencies = 0
12-
14+
1315
for file_path in EXERCISES_DIR.glob("*.json"):
1416
with open(file_path, "r") as f:
1517
data = json.load(f)
16-
18+
1719
id = data.get("id")
1820
name = data.get("name", "").lower()
1921
force = data.get("force")
2022
images = data.get("images", [])
2123

2224
# 1. Check for empty images
2325
if not images:
24-
print(f"Warning: {id} has an empty images array.")
26+
print(f"Warning: {id} has an empty images array")
2527
empty_images_count += 1
2628

2729
# 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
3843

3944
print("\nSummary:")
4045
print(f"Empty images arrays: {empty_images_count}")
46+
print(f"Referenced but missing images: {missing_images_count}")
4147
print(f"Potential force inconsistencies: {force_inconsistencies}")
4248

49+
4350
if __name__ == "__main__":
4451
main()

0 commit comments

Comments
 (0)