-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_missing.py
More file actions
26 lines (22 loc) · 833 Bytes
/
Copy pathcheck_missing.py
File metadata and controls
26 lines (22 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import json
import os
import glob
content_dir = "public/content"
index_files = glob.glob(f"{content_dir}/*/index.json")
missing_files = []
for index_file in index_files:
category_dir = os.path.dirname(index_file)
with open(index_file, 'r') as f:
try:
data = json.load(f)
topics = data.get('topics', [])
for topic in topics:
topic_id = topic.get('id')
md_path = os.path.join(category_dir, f"{topic_id}.md")
if not os.path.exists(md_path):
missing_files.append((index_file, topic_id, md_path))
except Exception as e:
print(f"Error reading {index_file}: {e}")
print("Missing files:")
for m in missing_files:
print(f"Category: {os.path.basename(os.path.dirname(m[0]))}, Topic ID: {m[1]}")