forked from pidcodes/pidcodes.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalidate_pids.py
More file actions
59 lines (46 loc) · 1.6 KB
/
Copy pathvalidate_pids.py
File metadata and controls
59 lines (46 loc) · 1.6 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
54
55
56
57
58
59
from pathlib import Path
import sys
existing_0xxx = {'0006', '01C0', '0007', '053A', '0256', '0008', '000F', '0BAB', '0009', '0001', '000A',
'0010', '01CB', '000C', '0002', '000E', '0CBD', '000D', '000B', '0003', '0004', '0514',
'0005', '0070', '0D32'}
existing_1xxx = {'1AB6', '1005', '1776', '1001', '1007', '1AB5', '1002', '1006', '1004', '1003', '1986'}
vid_1209 = Path("1209")
pid1xxx = vid_1209.glob("1*")
pid1xxx = set([x.name for x in pid1xxx])
pid0xxx = vid_1209.glob("0*")
pid0xxx = set([x.name for x in pid0xxx])
ok = True
for index in vid_1209.glob("*/*"):
if index.name != "index.md":
ok = False
print("Invalid file:", index)
for index in Path("org").glob("*/*"):
if index.name != "index.md":
ok = False
print("Invalid file:", index)
for pid in vid_1209.iterdir():
pid = pid.name
if pid == "index.md":
continue
try:
int(pid, 16)
except ValueError:
ok = False
print("PID " + pid + " not valid hex. Must be 4 characters 0-9 or A-F.")
if pid.upper() != pid:
ok = False
print("PID must be upper case:", pid)
if len(pid) != 4:
ok = False
print("Pid is too long: '" + pid + "'")
if pid1xxx - existing_1xxx:
print("Cannot claim 1xxx PID:", pid1xxx - existing_1xxx)
print("See here for more info: http://pid.codes/1209/")
ok = False
if pid0xxx - existing_0xxx:
print("Cannot claim 0xxx PID:", pid0xxx - existing_0xxx)
print("See here for more info: http://pid.codes/1209/")
ok = False
if not ok:
sys.exit(-1)
print("No errors found!")