-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignalFind.py
53 lines (42 loc) · 1.47 KB
/
signalFind.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
#!/usr/bin/env python
import sys
import utilsLib
import excelFunction as ex
# Default variable
outPath = "signalFind_gen.txt"
idLineComponentFilter = "\w" # Regular Expression for all
def help():
print("Error argv, argument passed was:")
print(sys.argv)
print(
"Correct usage:\n\tsignalFind.py <IOExcel.xls path> <replaceSignal.txt path> [out.xls path] [ID LINE COMPONENT filterText (Regular Expression Sintax)]")
print("replaceSignal.txt := First Columns ReplaceName (Find); Second Columns Description to search in IOExcel.xls")
print("To install dependence: \n pip3 install pandas openpyxl")
exit(-1)
if __name__ == '__main__':
# Input Read
if (len(sys.argv) < 3):
help()
IOexcelPath = sys.argv[1]
replaceSignalPath = sys.argv[2]
if (len(sys.argv) >= 4):
outPath = sys.argv[3]
# Data Load
searchList = utilsLib.loadDoubleList(replaceSignalPath, minColon=2)
# Sheet Data Load
ex.sheetLoadIO(IOexcelPath)
signalFindList = []
for signal in searchList:
replace = signal[0]
if len(signal) >= 3:
ioFilter = signal[2]
else:
ioFilter = "\w"
tag = ex.signalFound([signal[1]], idLineComponentFilter, defaultTag=signal[0], ioAddrFilter=ioFilter)
signalFindList.append([replace, tag[0]])
# Save
out = ""
for line in signalFindList:
out += line[0] + "\t" + line[1] + "\n"
print(out)
utilsLib.saveString(outPath, out)