forked from trezor/trezor-firmware
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck.py
executable file
·33 lines (28 loc) · 940 Bytes
/
check.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
#!/usr/bin/env python3
import os
import re
import sys
from glob import glob
error = False
MYDIR = os.path.dirname(__file__)
EXPECTED_PREFIX_RE = re.compile(r"messages-(\w+)\.proto")
for fn in sorted(glob(os.path.join(MYDIR, "messages-*.proto"))):
with open(fn, "rt") as f:
prefix = EXPECTED_PREFIX_RE.search(fn).group(1).capitalize()
if prefix in ["Bitcoin", "Bootloader", "Common", "Crypto", "Management"]:
continue
if prefix == "Nem":
prefix = "NEM"
elif prefix == "Webauthn":
prefix = "WebAuthn"
for line in f:
line = line.strip().split(" ")
if line[0] not in ["enum", "message"]:
continue
if not line[1].startswith(prefix) and not line[1].startswith(
"Debug" + prefix
):
print("ERROR:", fn, line[1])
error = True
if error:
sys.exit(1)