-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathverify-keywords
More file actions
executable file
·29 lines (25 loc) · 915 Bytes
/
verify-keywords
File metadata and controls
executable file
·29 lines (25 loc) · 915 Bytes
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
#! /usr/bin/env python
import os
import sys
# Run arduino-keywords
os.system("mkdir keywords")
os.system("~/.local/bin/arduino-keywords src --output ../keywords > /dev/null 2>&1")
os.system("sed -i '/operator=/d' keywords/keywords.txt > /dev/null 2>&1")
# Get a set of the lines from a file
# Using a set to ignore order (as arduino-keyword search order is system dependent)
def get_keywords(filename):
results = set()
with open(filename, "r") as f:
for line in f:
results.add(line)
return results
# Read both keywords.txt
existing_set = get_keywords("keywords.txt")
new_set = get_keywords("keywords/keywords.txt")
# Are they the same?
if existing_set != new_set:
print("keywords.txt is not correct. Please run build.sh to generate keywords.txt!")
print("Differences:")
for keyword in existing_set.symmetric_difference(new_set):
print(keyword)
sys.exit(1)