-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconvertTxtDatabaseToC.py
57 lines (44 loc) · 1.4 KB
/
convertTxtDatabaseToC.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3
#
# Understands the format of the Smark IC Tester database file.
# Converts this into a form that can be used by this tester.
#
import sys
import urllib.request
name = ""
desc = ""
tests=[]
readtests = False
src="https://raw.githubusercontent.com/akshaybaweja/Smart-IC-Tester/master/database.txt"
page = urllib.request.urlopen(src)
databaseTxtResp=page.read().decode("utf-8")
databaseTxt = databaseTxtResp.split("\n")
#databaseTxt = open("database.txt", "r")
chipsDatabaseIno = open("chipsDatabase.h", "w")
for line in databaseTxt:
line = line.strip()
if (line.startswith("$")):
if name != "":
print("Chip %s" % name)
chipsDatabaseIno.write("const char CHIP_%s[] PROGMEM = (\"%s:%s\" \\\n" % (name, name, desc))
for test in tests:
chipsDatabaseIno.write("\t\":%s:\" \\\n" % test)
chipsDatabaseIno.write(");\n");
name = ""
desc = ""
tests=[]
sys.stdout.flush()
readtests = False
if (line == "$"):
break
if (line.startswith("$")):
tests=[]
name = line.replace("$","",1)
else:
if desc == "":
desc = line
else:
if readtests == False:
readtests = True
else:
tests.append(line)