Skip to content

Commit 5fb50db

Browse files
committed
Update structure
1 parent 58337c8 commit 5fb50db

File tree

2 files changed

+63
-7
lines changed

2 files changed

+63
-7
lines changed

.github/scripts/check_syntax.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import json
4+
import csv
5+
from pathlib import Path
6+
7+
8+
def check_json(path: Path) -> bool:
9+
try:
10+
with path.open(encoding="utf-8") as f:
11+
json.load(f)
12+
except Exception as e:
13+
print(f"ERROR: Invalid JSON in {path}: {e}", file=sys.stderr)
14+
return False
15+
print(f"OK: {path} is valid JSON")
16+
return True
17+
18+
19+
def check_csv(path: Path, delimiter=';') -> bool:
20+
try:
21+
with path.open(encoding='utf-8', newline='') as f:
22+
reader = csv.reader(f, delimiter=delimiter)
23+
rows = list(reader)
24+
if not rows:
25+
print(f"ERROR: {path} is empty", file=sys.stderr)
26+
return False
27+
except Exception as e:
28+
print(f"ERROR: Failed to parse CSV {path}: {e}", file=sys.stderr)
29+
return False
30+
print(f"OK: {path} parsed as CSV with delimiter '{delimiter}' ({len(rows)} rows)")
31+
return True
32+
33+
34+
def main() -> int:
35+
root = Path('logo')
36+
37+
ok = True
38+
39+
# find all trafic.json files under logo/ recursively
40+
json_files = list(root.rglob('trafic.json'))
41+
if not json_files:
42+
print(f"ERROR: No trafic.json files found under {root}", file=sys.stderr)
43+
ok = False
44+
else:
45+
for p in json_files:
46+
ok = check_json(p) and ok
47+
48+
# find all lines_picto.csv files under logo/ recursively
49+
csv_files = list(root.rglob('lines_picto.csv'))
50+
if not csv_files:
51+
print(f"ERROR: No lines_picto.csv files found under {root}", file=sys.stderr)
52+
ok = False
53+
else:
54+
for p in csv_files:
55+
ok = check_csv(p) and ok
56+
57+
return 0 if ok else 2
58+
59+
60+
if __name__ == '__main__':
61+
sys.exit(main())

.github/workflows/deploy.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ jobs:
1414
- name: Checkout repository
1515
uses: actions/checkout@v6
1616

17-
- name: Check trafic.json syntax
18-
run: |
19-
python -m json.tool trafic.json
20-
21-
- name: Check lines_picto.csv syntax
22-
run: |
23-
python -c "import csv; f=open('lines_picto.csv', encoding='utf-8'); next(csv.reader(f, delimiter=';')); f.seek(0); [row for row in csv.reader(f, delimiter=';')]"
17+
- name: Run syntax checks
18+
run: python .github/scripts/check_syntax.py
2419

2520
- name: Check logo paths existence
2621
run: python .github/scripts/check_logo_path_existence.py

0 commit comments

Comments
 (0)