dmulyalin / ttp

Template Text Parser
MIT License
350 stars 34 forks source link

matching irrelevant group #108

Open pdimop opened 1 year ago

pdimop commented 1 year ago

data_to_parse =

vlan 100
    interface "Eth1"
        description "management interface"
    exit
exit
vrf 200
    interface "Eth2"
        iplist
            address bbbb::::2/128
        exit
    exit
exit

ttp_template =

<group name="vlan.{{ vlan }}**">
vlan {{ vlan | _start_ }}
    <group name="{{ interface }}**">
    interface "{{ interface | _start_ }}" 
        description "{{ description | re(r".*") }}" 
        <group name="iplist**">
        iplist{{ _start_ }}
            <group>
            address {{ address | _start_ }}
            </group> ## end of addresses
        exit{{ _end_ }}
        </group> ## end of iplist
    exit{{ _end_ }}
    </group> ## end of interface
exit{{ _end_ }}
</group> ## end of vlan 

output=

[[{
    'vlan': {
        '100': {
            'Eth1': {
                'description': 'management interface',
                'iplist': {
                    'address': 'bbbb::::2/128'
                }
            }
        }
    }
}]]

Somehow it matches the IP of another interface. BR

pdimop commented 1 year ago

the issue is still there in 0.9.5