Skip to content

Commit 897b99c

Browse files
authored
Merge pull request #770 from jepler/check-frontmatter-owners
Check frontmatter owners
2 parents 831736e + 0a45bb3 commit 897b99c

File tree

9 files changed

+42
-9
lines changed

9 files changed

+42
-9
lines changed

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ jobs:
99
- uses: actions/setup-python@v2
1010
with:
1111
python-version: '3.x'
12-
- run: python3 -m test.validate_pids
12+
- run: pip install -r requirements.txt; python3 -m test.validate_pids
1313

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
_site/
22
.sass-cache/
33
.DS_Store
4-
test/__pycache__
4+
/test/__pycache__
5+
/.bundle
6+
/vendor
7+
/Gemfile.lock
8+
/.jekyll-metadata

1209/414C/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: pid
3-
title: *uino-32u4
3+
title: "uino-32u4"
44
owner: adilinden
55
license: CC BY-SA
66
site: https://github.com/adilinden/uino-32u4

1209/414D/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: pid
3-
title: *uino-1284p
3+
title: "*uino-1284p"
44
owner: adilinden
55
license: CC BY-SA
66
site: https://github.com/adilinden/uino-1284p
@@ -10,4 +10,4 @@ source: https://github.com/adilinden/uino-arduino
1010

1111
The *uino-1284p board utilizes the ATmega1284P microcontroller. The main goal of this project is to be able to access more memory, both FLASH and RAM, while keeping the Arduino UNO compatible board size and I/O assignments.
1212

13-
The *uino-1284p uses a ATmega8U4 programmed with USB serial bridge firmware for uploading of scetches and serial console.
13+
The *uino-1284p uses a ATmega8U4 programmed with USB serial bridge firmware for uploading of scetches and serial console.

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

1209/FAB1/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
---
1+
---
22
layout: pid
33
title: LamDiNao
44
owner: PAPCoDienTu
55
license: Creative Commons ShareAlike 4.0 International
66
site: http://papcodientu.com
77
source: https://github.com/papcodientu/LamDiNao
88
---
9-
LamDiNao, in Vietnamese called Làm Ði Nào, is an electronic board allowing physical connection between people and computer. The board has 5 basic buttons, such as: UP, DOWN, LEFT, RIGHT, CLICK and SPACE; in addition, it also has 13 extra ports which has similar functionality as 5 basic buttons.
9+
LamDiNao, in Vietnamese called Làm Ði Nào, is an electronic board allowing physical connection between people and computer. The board has 5 basic buttons, such as: UP, DOWN, LEFT, RIGHT, CLICK and SPACE; in addition, it also has 13 extra ports which has similar functionality as 5 basic buttons.

org/PAPCoDienTu/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
---
1+
---
22
layout: org
33
title: PAP Mechatronic Technology
44
---
55
We would like to build a business to promote and drive the Maker movement and technology education at younger age in Vietnam. We aim to achieve this goal by selling products and providing teaching resources for the DIY/makers and education communities in Vietnam.
66

7-
Some example products are: Arduino, Raspberry Pi, sensors, 3D printers, robots, technology kits.
7+
Some example products are: Arduino, Raspberry Pi, sensors, 3D printers, robots, technology kits.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
python-frontmatter

test/validate_pids.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
from pathlib import Path
22
import sys
3+
import frontmatter
34

45
existing_0xxx = {'0006', '01C0', '0007', '053A', '0256', '0008', '000F', '0BAB', '0009', '0001', '000A',
56
'0010', '01CB', '000C', '0002', '000E', '0CBD', '000D', '000B', '0003', '0004', '0514',
67
'0005', '0070', '0D32'}
78
existing_1xxx = {'1AB6', '1005', '1776', '1001', '1007', '1AB5', '1002', '1006', '1004', '1003', '1986'}
89

10+
required_keys = ['title', 'license']
11+
912
vid_1209 = Path("1209")
1013
pid1xxx = vid_1209.glob("1*")
1114
pid1xxx = set([x.name for x in pid1xxx])
@@ -42,6 +45,29 @@
4245
ok = False
4346
print("Pid is too long: '" + pid + "'")
4447

48+
try:
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'. Note: File may not contain a Byte Order Mark (BOM)")
54+
ok = False
55+
owner = post.get('owner')
56+
if owner is None:
57+
print(f"{pid_path}:0: No owner specified")
58+
ok = False
59+
continue
60+
owner_path = Path("org") / owner / "index.md"
61+
if not owner_path.exists():
62+
print(f"{pid_path}:0: Owner file {owner} does not exist")
63+
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
68+
except Exception as e:
69+
print(f"{pid_path}: Failure parsing front matter: {e}")
70+
ok = False
4571
if pid1xxx - existing_1xxx:
4672
print("Cannot claim 1xxx PID:", pid1xxx - existing_1xxx)
4773
print("See here for more info: http://pid.codes/1209/")
@@ -54,6 +80,7 @@
5480

5581

5682
if not ok:
83+
print("Error(s) found")
5784
sys.exit(-1)
5885

5986
print("No errors found!")

0 commit comments

Comments
 (0)