Skip to content

Commit eae2428

Browse files
committed
Enforce more things in pid files:
* layout is present and "pid" * title, license are present Fix errors in several existing PID files. Also change the output format so that the affected files can be automatically visited by vim when the output of validate_pids is used as the error file.
1 parent 5d60355 commit eae2428

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

1209/2019/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: 2019
2+
layout: pid
33
title: PunchBOOT
44
owner: jop
55
license: BSD-3

1209/DE5C/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
layout: pid
3+
title: "Desk Viking"
34
owner: earth.li
45
license: GPLv3
56
site: https://github.com/u1f35c/desk-viking

test/validate_pids.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
'0005', '0070', '0D32'}
88
existing_1xxx = {'1AB6', '1005', '1776', '1001', '1007', '1AB5', '1002', '1006', '1004', '1003', '1986'}
99

10+
required_keys = ['title', 'license']
11+
1012
vid_1209 = Path("1209")
1113
pid1xxx = vid_1209.glob("1*")
1214
pid1xxx = set([x.name for x in pid1xxx])
@@ -44,18 +46,27 @@
4446
print("Pid is too long: '" + pid + "'")
4547

4648
try:
47-
post = frontmatter.load(vid_1209 / pid / "index.md")
49+
pid_path = vid_1209 / pid / "index.md"
50+
post = frontmatter.load(pid_path)
51+
layout = post.get('layout')
52+
if layout != "pid":
53+
print(f"{pid_path}:0: Layout must be 'pid'")
54+
ok = False
4855
owner = post.get('owner')
4956
if owner is None:
50-
print(f"No owner specified for {pid} @ {vid_1209 / pid / 'index.md'}")
57+
print(f"{pid_path}:0: No owner specified")
5158
ok = False
5259
continue
5360
owner_path = Path("org") / owner / "index.md"
5461
if not owner_path.exists():
55-
print(f"Owner file {owner} for pid {pid} does not exist")
62+
print(f"{pid_path}:0: Owner file {owner} does not exist")
5663
ok = False
64+
for k in required_keys:
65+
if k not in post.metadata:
66+
print(f"{pid_path}:0: Required key {k} not present in front matter")
67+
ok = False
5768
except Exception as e:
58-
print(f"Failure parsing front matter for {pid}: {e}")
69+
print(f"{pid_path}: Failure parsing front matter: {e}")
5970
ok = False
6071
if pid1xxx - existing_1xxx:
6172
print("Cannot claim 1xxx PID:", pid1xxx - existing_1xxx)

0 commit comments

Comments
 (0)