forked from adafruit/circuitpython-org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmissing-boards.py
executable file
·61 lines (52 loc) · 1.82 KB
/
missing-boards.py
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
54
55
56
57
58
59
60
61
#!/usr/bin/python3
# Print a list of hidden and missing boards
import os
import json
from pathlib import Path
import frontmatter
def get_files(folder):
return sorted(Path(folder).glob("*.md"), key=os.path.basename)
def find_hidden_boards(folder):
hidden_boards = []
for filename in get_files(folder):
with open(filename, "rt") as f:
metadata, _ = frontmatter.parse(f.read())
downloads_display = metadata.get('downloads_display')
if downloads_display is not None and not downloads_display:
board_id = metadata.get('board_id')
if board_id == "unknown":
continue
hidden_boards.append(board_id)
print("Hidden boards:")
print("----------------")
if hidden_boards:
print("\n".join(hidden_boards))
else:
print("No Hidden Boards")
def find_missing_boards(folder):
missing_boards = []
# Add all board ids to a list from data file
with open('./_data/files.json') as board_file:
boards = json.load(board_file)
for board in boards:
if not os.path.exists(f"./_boards/{board}.md"):
missing_boards.append(board["id"])
# Scan through files and remove board_ids from list
for filename in get_files(folder):
with open(filename, "rt") as f:
metadata, _ = frontmatter.parse(f.read())
board_id = metadata.get('board_id')
if board_id == "unknown":
continue
if board_id in missing_boards:
missing_boards.remove(board_id)
# Print out remaining board_ids
print("")
print("Missing boards:")
print("----------------")
if missing_boards:
print("\n".join(missing_boards))
else:
print("No Missing Boards")
find_hidden_boards("_board")
find_missing_boards("_board")