We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
First of all thank you soo much for creating and maintaining this repo.
I am looking for a match function/indicator that saves the linenumber of a matching variable.
My usecase is compliancy checking where i would like to highlight configuration lines in the original data.
from ttp import ttp data_to_parse = """ interface Loopback0 description Router-id-loopback ip address 192.168.0.113/24 ! interface Vlan778 description CPE_Acces_Vlan ip address 2002::fd37/124 ip vrf CPE1 ! """ ttp_template = """ interface {{ interface | linenumber('INTERFACE_LINENUMBER')}} ip address {{ ip }}/{{ mask }} description {{ description }} ip vrf {{ vrf | linenumber('VRF_LINENUMBER') }} """ # create parser object and parse data using template: parser = ttp(data=data_to_parse, template=ttp_template) parser.parse()
would result in:
[ [ { "description": "Router-id-loopback", "interface": "Loopback0", "INTERFACE_LINENUMBER": 1, "ip": "192.168.0.113", "mask": "24" }, { "description": "CPE_Acces_Vlan", "interface": "Vlan778", "ip": "2002::fd37", "mask": "124", "vrf": "CPE1", "VRF_LINENUMBER": 8, "INTERFACE_LINENUMBER": 5 } ] ]
The text was updated successfully, but these errors were encountered:
No branches or pull requests
First of all thank you soo much for creating and maintaining this repo.
I am looking for a match function/indicator that saves the linenumber of a matching variable.
My usecase is compliancy checking where i would like to highlight configuration lines in the original data.
would result in:
The text was updated successfully, but these errors were encountered: