dmulyalin / ttp

Template Text Parser
MIT License
351 stars 34 forks source link

TTP not collecting some data #59

Closed dmulyalin closed 3 years ago

dmulyalin commented 3 years ago
data = """
interface TenGigE0/0/0/5.100 l2transport
!
interface BVI101
 ipv4 address 192.168.101.1 255.255.255.0
 mac-address 200.b19.4321
!
    """
template = """
<group name="interfaces">

## matches primary interfaces
<group>
interface {{ interface }}
 <group name="ipv4*" method="table" containsall="ipv4">
 ipv4 address {{ ipv4 | _line_ | _exact_ }}
 </group>
 mac-address {{ mac_address }}
</group>

## matches sub-interfaces
<group>
interface {{ interface }} l2transport
 mac-address {{ mac_address }}
</group>

</group>      
    """

Gives result:

    [[{'interfaces': [{'interface': 'TenGigE0/0/0/5.100'},
                      {'interface': 'BVI101',
                       'ipv4': [{'ipv4': '192.168.101.1 255.255.255.0'}]}]}]]

While should be:

[[{'interfaces': [{'interface': 'TenGigE0/0/0/5.100'},
                  {'interface': 'BVI101',
                   'ipv4': [{'ipv4': '192.168.101.1 255.255.255.0'}],
                   'mac_address': '200.b19.4321'}]}]]
dmulyalin commented 3 years ago

fixed