-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfind-invalid-repo-json.py
More file actions
53 lines (41 loc) · 1.32 KB
/
find-invalid-repo-json.py
File metadata and controls
53 lines (41 loc) · 1.32 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import os
import json
import glob
REPO_DIR = "repo"
def extract_user_repo(filename):
base = os.path.basename(filename)
if not base.endswith(".json") or "@" not in base:
return None, None
repo_part, user_part = base[:-5].split("@", 1)
return user_part, repo_part
def main():
files = sorted(glob.glob(os.path.join(REPO_DIR, "*.json")))
for filepath in files:
user, repo = extract_user_repo(filepath)
if not user or not repo:
continue
url = f"https://github.com/{user}/{repo}"
try:
with open(filepath, "r", encoding="utf-8") as f:
data = json.load(f)
except Exception as e:
print(f"* {url} : Parse Error")
continue
if not isinstance(data, list):
print(f"* {url} : Not a List")
continue
for entry in data:
if not isinstance(entry, dict):
print(f"* {url} : No Dicts")
continue
found = False
if "Name" not in entry:
print(f"* {url} : No Name")
found = True
if "Description" not in entry:
print(f"* {url} : No Description")
found = True
if found:
continue
if __name__ == "__main__":
main()