2019-03-13 15:59:26 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
from glob import glob
|
2019-03-21 11:22:55 +00:00
|
|
|
import os
|
2019-03-21 11:30:37 +00:00
|
|
|
import re
|
2019-03-13 15:59:26 +00:00
|
|
|
import sys
|
|
|
|
|
|
|
|
error = False
|
|
|
|
|
2019-03-21 11:22:55 +00:00
|
|
|
MYDIR = os.path.dirname(__file__)
|
|
|
|
|
2019-03-21 11:30:37 +00:00
|
|
|
EXPECTED_PREFIX_RE = re.compile(r"messages-(\w+)\.proto")
|
|
|
|
|
2019-03-21 11:22:55 +00:00
|
|
|
for fn in sorted(glob(os.path.join(MYDIR, "messages-*.proto"))):
|
2019-03-13 15:59:26 +00:00
|
|
|
with open(fn, "rt") as f:
|
2019-03-21 11:30:37 +00:00
|
|
|
prefix = EXPECTED_PREFIX_RE.search(fn).group(1).capitalize()
|
2019-03-13 15:59:26 +00:00
|
|
|
if prefix in ["Bitcoin", "Bootloader", "Common", "Crypto", "Management"]:
|
|
|
|
continue
|
|
|
|
if prefix == "Nem":
|
|
|
|
prefix = "NEM"
|
|
|
|
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)
|