multiple Records in same state support
Closed this issue · 2 comments
Ali-aqrabawi commented
in textFSM
you can have multiple records
in same state
, and when ever you reach to a cmd
/line
with a record
you should add a new record and move to the next line in data.
in go-textFSM
it continue on same line and add new record,
for example :
Value Slot (\d)
Value State (\w+)
Value Temperature (\d+)
Value DRAM (\d+)
Value Buffer (\d+)
Start
# We can't use .* for unused placeholders, as greedy matching will break it.
^\s+${Slot}\s+${State}\s+${Temperature}\s+\d+\s+\d+\s+${DRAM}\s+\d+\s+${Buffer} -> Record
^\s+${Slot}\s+${State} -> Record
data:
Slot State (C) Total Interrupt DRAM (MB) Heap Buffer
0 Online 24 7 0 256 38 51
1 Online 25 7 0 256 38 51
2 Online 24 3 0 256 37 49
3 Online 23 3 0 256 37 49
4 Empty
5 Empty
6 Empty
7 Empty
in go-textfsm
the results will be
[0 Online 24 256 51]
[0 Online ] <- duplicate record on same line
[1 Online 25 256 51]
[1 Online ] <- duplicate record on same line
[2 Online 24 256 49]
[2 Online ] <- duplicate record on same line
[3 Online 23 256 49]
[3 Online ] <- duplicate record on same line
[4 Empty ]
[5 Empty ]
[6 Empty ]
[7 Empty ]
it should be
[0 Online 24 256 51]
[1 Online 25 256 51]
[2 Online 24 256 49]
[3 Online 23 256 49]
[4 Empty ]
[5 Empty ]
[6 Empty ]
[7 Empty ]
Ali-aqrabawi commented
i found this while working on #17 , to solve this issue in unittest i had to be more precised in templates and added $$
like ^\s+${Slot}\s+${State}$$ -> Record
TobiEiss commented
Oh man.. this was brainfuck and then so easy to fix.
Thank you @Ali-aqrabawi for your detailed issue-description!